Skip to content

chore(dev): add go.work for gopls multi-module workspace (closes #516)#858

Open
cristim wants to merge 6 commits into
mainfrom
fix/516-wave17
Open

chore(dev): add go.work for gopls multi-module workspace (closes #516)#858
cristim wants to merge 6 commits into
mainfrom
fix/516-wave17

Conversation

@cristim

@cristim cristim commented May 30, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds a committed go.work listing only the primary module (.) so gopls resolves imports for all standard clones with no local config needed.
  • Documents a go.work.local (gitignored) per-developer pattern in CONTRIBUTING.md for developers working across multiple git worktrees simultaneously; includes a quick-regeneration snippet using git worktree list.
  • Updates .gitignore: removes the former go.work / go.work.sum entries (they are now committed), adds go.work.local / go.work.local.sum (developer-local, gitignored).

Test plan

  • go build ./... passes in a fresh clone with only the committed go.work present.
  • Creating a go.work.local with an additional use path and setting GOWORK=$PWD/go.work.local causes gopls to resolve imports in that sibling worktree without errors.
  • go.work.local does not appear in git status (correctly gitignored).
  • go.work and go.work.sum do appear in git status as tracked (no longer gitignored).

Summary by CodeRabbit

  • Bug Fixes
    • Improved GCP recommendation handling so context cancellations return immediately and aren’t obscured by downstream permission logic.
  • Chores
    • Updated Go module dependencies across the project and providers (including AWS SDK and OpenTelemetry packages).
    • Added contributor documentation for Go workspace and worktrees (gopls setup) using a generated local workspace file.
    • Updated .gitignore to ignore go.work.local artifacts.
    • Adjusted test setup to disable AWS EC2 metadata IMDS during command tests.

@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/internal Team-internal only effort/xs Trivial / one-liner type/chore Maintenance / non-user-visible labels May 30, 2026
@cristim

cristim commented May 30, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 39 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2884c87a-b88b-4f4f-b9d5-e23d97d67bf8

📥 Commits

Reviewing files that changed from the base of the PR and between 52e2152 and 5e1a0f5.

⛔ Files ignored due to path filters (3)
  • go.sum is excluded by !**/*.sum
  • go.work is excluded by !**/*.work
  • go.work.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • .gitignore
  • CONTRIBUTING.md
  • go.mod
📝 Walkthrough

Walkthrough

Go workspace local files are excluded via gitignore, with contributor guidance added for multi-module development. Test execution is configured to disable AWS EC2 metadata to prevent retry delays. Dependencies across the root and all provider modules are updated to newer AWS SDK v2, OpenTelemetry, and Google Cloud versions. A context cancellation guard is added to GCP recommendations to prevent error swallowing.

Changes

Go Workspace Setup, Dependency Maintenance, Test Configuration, and Context Cancellation Fix

Layer / File(s) Summary
Go workspace setup
.gitignore, CONTRIBUTING.md
Gitignore is updated to exclude local go.work.local and go.work.local.sum files. Contributing documentation explains using a local workspace copy for multi-module development without modifying the committed go.work, including GOWORK environment setup and worktree regeneration instructions.
Test environment configuration
cmd/multi_service_test_common_test.go
TestMain is added to disable AWS EC2 metadata during test runs via AWS_EC2_METADATA_DISABLED=true, preventing IMDS retry delays in the test suite.
Root and package-level dependency updates
go.mod, pkg/go.mod
Root go.mod is bumped to newer AWS SDK v2 config, credentials, STS, and OpenTelemetry instrumentation versions. pkg/go.mod direct and indirect requirements are updated to match, including AWS SDK v2 and golang.org/x/sync versions.
Provider-specific dependency updates
providers/aws/go.mod, providers/azure/go.mod, providers/gcp/go.mod
AWS provider dependencies are updated with AWS SDK v2 and smithy-go versions. Azure provider indirect dependencies are refreshed with newer AWS and utility library versions. GCP provider Go toolchain is bumped to 1.25.0 and all direct and indirect dependencies are updated, including Google Cloud, OpenTelemetry, and AWS SDK v2 packages.
GCP recommendations context cancellation guard
providers/gcp/recommendations.go
GetRecommendations adds an early context error check that returns before region fan-out, preventing context cancellation from being swallowed by permission-error handling. Error comments are clarified to document this guard.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • LeanerCloud/CUDly#269: Both PRs modify providers/gcp/recommendations.go's GetRecommendations control flow around context cancellation, with the main PR adding an early guard and #269 targeting propagation after region fan-out.
  • LeanerCloud/CUDly#800: The context cancellation guard added in this PR to GetRecommendations aligns with the pagination and cancellation fix strategy addressed in that PR.

Poem

🐰 Workspaces arranged in harmony and care,
Dependencies polished, version numbers pair,
Tests run faster, no metadata affair,
Context guards catch what wasn't caught there! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a go.work file for gopls multi-module workspace support, which aligns with the primary objective of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/516-wave17

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Jun 6, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
CONTRIBUTING.md (1)

112-114: ⚡ Quick win

Clarify gopls discovery of go.work.local.

Option B suggests that gopls will "auto-discover" go.work.local, but this is misleading. By default, gopls searches for go.work by walking up the directory tree. It does not automatically discover go.work.local unless GOWORK is explicitly set to point to it.

The earlier text (line 106) mentions "symlinking it over go.work temporarily" as an alternative, but Option B doesn't demonstrate this approach. Consider either:

  • Removing Option B and keeping only Option A (setting GOWORK)
  • Rewriting Option B to demonstrate the symlink approach: ln -sf go.work.local go.work
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CONTRIBUTING.md` around lines 112 - 114, Option B currently misstates gopls
behavior for go.work.local; update the Option B text to either remove it
(leaving only the GOWORK approach in Option A) or rewrite it to show the symlink
approach so gopls sees the workfile (e.g., describe creating a symlink from
go.work.local to go.work using a command like ln -sf go.work.local go.work), and
explicitly note that gopls only auto-discovers go.work by walking up directories
unless GOWORK is set to point to go.work.local.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CONTRIBUTING.md`:
- Around line 119-121: The current regen command uses word-splitting-prone
substitution: go work edit -use $(git worktree list --porcelain | awk
'/^worktree/{print $2}' | tail -n +2 | tr '\n' ' '), which fails on worktree
paths with spaces/special chars; change the pipeline to emit and consume
null-delimited paths (e.g., git worktree list --porcelain | awk
'/^worktree/{print $2 "\\0"}' or use git worktree list -z) and pass them safely
to go work edit via xargs -0 or a while IFS= read -r -d '' loop so paths aren’t
split, and update the verification snippet/test data to include at least one
worktree path containing a space (e.g., "work with space") to cover the failure
mode.

In `@go.mod`:
- Line 9: The go.mod currently pins github.com/aws/aws-sdk-go-v2/config but the
review asks you to verify module versions and run the same security checks for
OpenTelemetry and Google Cloud Storage; confirm the exact versions for
github.com/aws/aws-sdk-go-v2/config, github.com/aws/aws-sdk-go-v2/credentials,
github.com/aws/aws-sdk-go-v2/service/sts,
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
(otelgrpc) and cloud.google.com/go/storage are correct and present in go.mod,
then run a Go vulnerability scan (e.g., govulncheck or go list -m -u -json all
plus GitHub advisory queries) against those modules and update go.mod to bump or
replace any vulnerable versions you find; reference the module names
(github.com/aws/aws-sdk-go-v2/config, otelgrpc, cloud.google.com/go/storage)
when making changes so reviewers can re-run the security check.

---

Nitpick comments:
In `@CONTRIBUTING.md`:
- Around line 112-114: Option B currently misstates gopls behavior for
go.work.local; update the Option B text to either remove it (leaving only the
GOWORK approach in Option A) or rewrite it to show the symlink approach so gopls
sees the workfile (e.g., describe creating a symlink from go.work.local to
go.work using a command like ln -sf go.work.local go.work), and explicitly note
that gopls only auto-discovers go.work by walking up directories unless GOWORK
is set to point to go.work.local.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eaae2872-d6f1-4217-81ac-248e75f63743

📥 Commits

Reviewing files that changed from the base of the PR and between 4108e51 and 803c2e4.

⛔ Files ignored due to path filters (7)
  • go.sum is excluded by !**/*.sum
  • go.work is excluded by !**/*.work
  • go.work.sum is excluded by !**/*.sum
  • pkg/go.sum is excluded by !**/*.sum
  • providers/aws/go.sum is excluded by !**/*.sum
  • providers/azure/go.sum is excluded by !**/*.sum
  • providers/gcp/go.sum is excluded by !**/*.sum
📒 Files selected for processing (8)
  • .gitignore
  • CONTRIBUTING.md
  • go.mod
  • pkg/go.mod
  • providers/aws/go.mod
  • providers/azure/go.mod
  • providers/gcp/go.mod
  • providers/gcp/recommendations.go

Comment thread CONTRIBUTING.md Outdated
Comment thread go.mod
@cristim

cristim commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

cristim added 4 commits July 17, 2026 21:14
Commit a minimal go.work listing only the primary module so gopls
resolves imports for standard clones without any local config.

Per-developer worktree paths go in a gitignored go.work.local file;
the pattern and a quick-regeneration snippet are documented in
CONTRIBUTING.md under the new "Go workspace and worktrees" section.

.gitignore is updated to track go.work and go.work.sum (committed)
while ignoring go.work.local and go.work.local.sum (developer-local).
…lings (refs #516)

The initial go.work only listed the root module, leaving the sibling modules
unresolved by gopls. Add all six modules (root, pkg, providers/aws,
providers/azure, providers/gcp, tests/e2e) to the use block, run go work sync
to align module go.mod files with the workspace-selected versions, and go mod
tidy in each module. Update the CONTRIBUTING.md workspace section to match
the multi-module go.work.

All modules verified: go build ./... succeeds for each, go vet ./... from
root is clean, and tests/e2e passes go vet -tags=e2e.
Aligning providers/gcp deps with the workspace (cloud.google.com/go/compute
v1.23.3 -> v1.54.0, the version the root binary already builds against)
surfaced a latent gap: the newer REST client can complete the regions List
call and return a real 403 even when the caller's ctx is already cancelled.
That 403 was then swallowed by the permission-warning branch, returning
(nil-error, empty recs) instead of context.Canceled and breaking the
contract pinned by
TestRecommendationsClientAdapter_GetRecommendations_PropagatesContextCancellation.

Guard GetRecommendations with an explicit ctx.Err() check before any API
fan-out so cancellation propagates deterministically and no network call is
attempted on an already-dead context.
The documented regeneration one-liner used an unquoted command
substitution plus awk '{print $2}', which truncates worktree paths at
the first space and word-splits the result before passing it to
go work edit -use. Replace it with a sed extraction that keeps the
full path and a while IFS= read -r loop that adds one -use entry per
worktree, verified against a worktree path containing a space.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/internal Team-internal only priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/chore Maintenance / non-user-visible urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant