Skip to content

TPT-4471: deduplicate logger setup and retry-loop body seek#976

Merged
zliang-akamai merged 2 commits into
linode:proj/linodego_v2from
ChihweiLHBird:zhiwei/client-simplified
May 27, 2026
Merged

TPT-4471: deduplicate logger setup and retry-loop body seek#976
zliang-akamai merged 2 commits into
linode:proj/linodego_v2from
ChihweiLHBird:zhiwei/client-simplified

Conversation

@ChihweiLHBird
Copy link
Copy Markdown
Contributor

@ChihweiLHBird ChihweiLHBird commented May 22, 2026

Changes

  • Drop duplicate SetLogger(createLogger()) from NewClient chain (client.go:215). The same setter at line 186 already installed an identical logger, and no intermediate call reads or replaces it.
  • Drop the body-seek block at the top of doRequest's retry loop. createRequest (called immediately after) performs the same params.Body.Seek(0) on the same buffer, so the outer seek was always a no-op.
  • Inline json.Unmarshal's error check in formatBody. Standard if err := json.Unmarshal(...); err != nil form, err is only used inside the immediately following branch.

Test plan

make test-int
make test-unit

Copilot AI review requested due to automatic review settings May 22, 2026 04:09
@ChihweiLHBird ChihweiLHBird requested review from a team as code owners May 22, 2026 04:09
@ChihweiLHBird ChihweiLHBird requested review from jriddle-linode and mawilk90 and removed request for a team May 22, 2026 04:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR adjusts request/response logging and retry handling in the Go client, primarily by simplifying retry behavior and changing how debug logs are formatted/emitted.

Changes:

  • Removes explicit request-body seeking in the retry loop and relies on createRequest to reset the body.
  • Refactors request/response logging to remove sanitization and simplify JSON formatting/log emission.
  • Removes the Resty logger configuration (SetLogger(createLogger())) during client construction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread client.go Outdated
Comment thread client.go Outdated
Comment thread client.go
Comment thread client.go Outdated
Comment thread client.go Outdated
Comment thread client.go Outdated
Comment thread client.go Outdated
@zliang-akamai zliang-akamai added the community-contribution for contributions made by a non-DX author label May 22, 2026
Comment thread client.go Fixed
@ChihweiLHBird ChihweiLHBird force-pushed the zhiwei/client-simplified branch from 89f7377 to d54d126 Compare May 22, 2026 05:51
Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
@ChihweiLHBird ChihweiLHBird force-pushed the zhiwei/client-simplified branch from d54d126 to db4352a Compare May 22, 2026 05:57
@zliang-akamai zliang-akamai changed the title client: dedupe logger setup, log sanitization, and retry-loop body seek client: deduplicate logger setup and retry-loop body seek May 22, 2026
@zliang-akamai zliang-akamai changed the title client: deduplicate logger setup and retry-loop body seek TPT-4471: deduplicate logger setup and retry-loop body seek May 22, 2026
@zliang-akamai zliang-akamai removed the community-contribution for contributions made by a non-DX author label May 22, 2026
Copy link
Copy Markdown
Contributor

@ezilber-akamai ezilber-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

Copy link
Copy Markdown
Contributor

@lgarber-akamai lgarber-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't able to find any bugs hiding in this, great work!

@zliang-akamai zliang-akamai merged commit 2e3feb3 into linode:proj/linodego_v2 May 27, 2026
8 checks passed
zliang-akamai added a commit that referenced this pull request May 27, 2026
* TPT-4423: Drop resty as a dependency (#938)

* Ported resty removal changes to new branch from up-to-date main and made additional changes to monitor client

* Fixed lint

* Updated log formatting to more closely resemble Resty's

* Fixed lint

* redact request header log

* Fixes

* Fixed CoPilot suggestions

* Sanitize log output

* Addressed CoPilot comments

---------

Co-authored-by: Zhiwei Liang <zliang@akamai.com>

* TPT-4421: Remove deprecated fields and methods (#946)

* Removed deprecated fields and methods and updated tests

* Fix lint

* Addressed copilot suggestion

* Fixed lint

* Removed V2 suffix from various fields and methods

* Addressed CoPilot suggestions

* Added separate struct for Instance IP Address update options

* Address PR suggestions

* TPT-4414: Refactor JSON tags to use "omitzero" for optional fields across multiple files (#947)

* Refactor JSON struct tags to use "omitzero" for optional fields

* Remove url tags in pagination structs

* TPT-4414: Change slice pointer types with `omitzero` to be slice (#954)

* Refactor: Change pointer slices to slices for various fields with omitzero

* Refresh fixtures

* Update TestLKECluster_Update to remove pinned lke versions in test

* TPT-4434: Added custom type for Region Capabilities and updated tests (#953)

* Added custom type for Region Capabilities and updated tests

* Fix formatting

* Added disctinction between Object Storage Bucket Access POST/PUT endpoints (#951)

* TPT-3454: Refactor wait functions to use context for timeouts and polling (#964)

* Refactor wait functions to use context for timeouts and polling

* fix context cancelled in cleanup

* nolint generic return type

* Fix grammar

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Make preTask a private function; cleanup unnecessary previousEvents allocation

* Fix error msg format

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* TPT-4422: Added options structs for POST/PUT endpoints that were missing them (#968)

* Added options structs for POST/PUT endpoints that were missing them

* Address PR comments

* Address PR comments

* TPT-3483: Update NewClient method to return an error rather than just logging errors (#967)

* refactor: update NewClient and related functions to handle errors properly

* refactor: update SetRootCertificate to return errors and enhance logging

* update NewClient instantiation to handle errors

* Export PaginatedResponse type in request_helpers (#970)

* TPT-3388: Separated GET and POST/PUT options structs where needed (#969)

* Separated GET and POST/PUT options structs where needed

* Separated additional structs that were reused for options and response

* More struct fixes

* Fix lint

* Rename FirewallRule structs

* integration test fixes

* Addressed PR comments

* FirewallRuleSetRule options; test updates; fixture refreshed

* Address more PR comments

---------

Co-authored-by: Zhiwei Liang <zliang@akamai.com>

* TPT-4464: Update FirewallDeviceEntity Label field to be a pointer (#971)

* Update FirewallDeviceEntity Label field to be a pointer and adjust tests accordingly

* Fix unit tests

* fmt

* Fix another unit test

* Change `[]*T` to `[]T` in all structs (#972)

* Remove LKE cluster dashboard function, tests, and related fixture (#975)

* Simplify client.go (#976)

Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>

* Apply suggestion from @zliang-akamai

* Update region capability in TestImageSharing_Suite to use Linodes

---------

Signed-off-by: Zhiwei Liang <zhiwei.liang@zliang.me>
Co-authored-by: Erik Zilber <ezilber@akamai.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Zhiwei Liang <zhiwei.liang@zliang.me>
@zliang-akamai zliang-akamai added the improvement for improvements in existing functionality in the changelog. label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement for improvements in existing functionality in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants