Repository navigation
feat(toolchain): parallel installs with safe locking - #2758
Conversation
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
Dependency Review✅ No vulnerabilities or license issues found.Scanned FilesNone |
|
Warning Release Documentation RequiredThis PR is labeled
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR adds cross-process file locking, bounded concurrent toolchain installation with progress rendering, Cosign compatibility and retry handling, concurrency configuration, coordinated toolchain state updates, and related documentation and output changes. ChangesToolchain concurrency and verification
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant InstallCommand
participant BatchWorkers
participant Installer
participant Renderer
CLI->>InstallCommand: provide max concurrency
InstallCommand->>BatchWorkers: start bounded tool installs
BatchWorkers->>Installer: install and report download progress
Installer-->>Renderer: emit progress and result events
Renderer-->>CLI: render install status and summary
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 12
🧹 Nitpick comments (1)
pkg/toolchain/install_test.go (1)
30-41: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRefactor to use a table-driven test.
As per coding guidelines, use table-driven tests for testing multiple scenarios in Go.
♻️ Proposed refactor
-func TestRightAlignInstallProgress(t *testing.T) { - t.Run("shows downloaded and total bytes at the terminal edge", func(t *testing.T) { - line := rightAlignInstallProgress("⣾ Installing owner/[email protected]", 85*1024*1024, 100*1024*1024, 80) - assert.True(t, strings.HasSuffix(line, "85.0 MB/100.0 MB")) - assert.Equal(t, 80, lipgloss.Width(line)) - }) - - t.Run("does not wrap a narrow terminal", func(t *testing.T) { - left := "⣾ Installing owner/[email protected]" - assert.Equal(t, left, rightAlignInstallProgress(left, 85*1024*1024, 100*1024*1024, len(left))) - }) -} +func TestRightAlignInstallProgress(t *testing.T) { + tests := []struct { + name string + left string + downloaded int64 + total int64 + width int + verify func(t *testing.T, line string) + }{ + { + name: "shows downloaded and total bytes at the terminal edge", + left: "⣾ Installing owner/[email protected]", + downloaded: 85 * 1024 * 1024, + total: 100 * 1024 * 1024, + width: 80, + verify: func(t *testing.T, line string) { + assert.True(t, strings.HasSuffix(line, "85.0 MB/100.0 MB")) + assert.Equal(t, 80, lipgloss.Width(line)) + }, + }, + { + name: "does not wrap a narrow terminal", + left: "⣾ Installing owner/[email protected]", + downloaded: 85 * 1024 * 1024, + total: 100 * 1024 * 1024, + width: len("⣾ Installing owner/[email protected]"), + verify: func(t *testing.T, line string) { + assert.Equal(t, "⣾ Installing owner/[email protected]", line) + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + line := rightAlignInstallProgress(tt.left, tt.downloaded, tt.total, tt.width) + tt.verify(t, line) + }) + } +}🤖 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 `@pkg/toolchain/install_test.go` around lines 30 - 41, Refactor TestRightAlignInstallProgress into a table-driven test with named cases for the terminal-edge and narrow-terminal scenarios. Store each case’s input and expected output, then iterate with t.Run while preserving the existing suffix, width, and unchanged-line assertions.Source: Coding guidelines
🤖 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 `@cmd/toolchain/install.go`:
- Around line 40-43: Add the ATMOS_TOOLCHAIN_MAX_CONCURRENCY
environment-variable mapping alongside the existing registrations in the install
command, associating it with the max-concurrency flag/config key so environment
values participate in the established flag/env/config precedence.
In `@cmd/toolchain/toolchain.go`:
- Around line 147-155: Remove bindToolchainEnvironment and its invocation,
avoiding direct viper.BindEnv usage. In PersistentPreRunE, use os.LookupEnv for
ATMOS_TOOL_VERSIONS and ATMOS_TOOLCHAIN_PATH alongside the corresponding flag
Changed checks before copying viper values into atmosCfg.Toolchain; add the os
import and preserve the existing initialization behavior.
In `@pkg/filelock/filelock_test.go`:
- Around line 20-27: The file-lock tests discard errors from asynchronous
WithExclusive/WithShared calls and helper processes, allowing channel waits to
hang indefinitely. Update the affected test goroutines and helper-process
handling to send failures through buffered error channels, and replace unbounded
waits on held/release signals with bounded select-based waits that fail loudly
on errors or timeouts; preserve successful callback synchronization.
In `@pkg/toolchain/install.go`:
- Around line 338-347: Update the concurrent installation branch around
InstallSingleTool and the direct installer.Install call by extracting a shared
lifecycle helper that accepts the worker-configured Installer. Have the helper
perform the same latest-version resolution and handleInstallSuccess processing
as InstallSingleTool, while retaining the configured progress callback; route
both sequential and concurrent paths through this helper.
- Around line 684-686: Update startBatchInstallWorkers so progress callbacks do
not block downloads on terminal rendering: coalesce progress events by tool,
retaining only the latest state, and make intermediate event delivery
non-blocking or throttled. Have the existing ticker render the coalesced latest
progress for all active tools rather than redrawing on every received event,
while preserving completion and error event handling.
In `@pkg/toolchain/installer/installer.go`:
- Around line 946-948: In the uninstall flow around versionDir and filelock.New,
create the parent directory with os.MkdirAll(filepath.Dir(versionDir),
defaultMkdirPermissions) before opening the lock, handling any resulting error
consistently with Install. Preserve the existing lock and FindBinaryPath
behavior afterward.
In `@pkg/toolchain/installer/lockfile_update.go`:
- Around line 39-40: Update the directory-creation error handling in the
installer lockfile update method to wrap the static ErrLockfileIO domain error
while preserving the underlying MkdirAll error as contextual wrapping. Keep the
existing directory context and ensure callers can classify this failure
consistently with the load/save paths.
In `@pkg/toolchain/tool_versions_test.go`:
- Line 19: Replace require.NoError with assert.NoError in the background
goroutines at pkg/toolchain/tool_versions_test.go:19-19 and
pkg/toolchain/installer/lockfile_update_test.go:28-28, preserving the existing
error checks while avoiding FailNow from concurrent test goroutines.
In `@pkg/toolchain/tool_versions.go`:
- Around line 59-64: The public LoadToolVersions path in
pkg/toolchain/tool_versions.go must acquire a shared lock, while exclusive
transactions should call an unlocked loader to avoid recursive locking; update
the relevant load/save helpers accordingly. In
pkg/toolchain/installer/version.go, update ReadLatestFile to acquire
latestFilePath+".lock" in shared mode, or replace the write flow with atomic
replacement. Apply the corresponding change at both identified sites.
In `@pkg/toolchain/verification/signature_test.go`:
- Around line 100-102: Update both signature verification tests around the
existing runner.calls assertions to store the test asset path in an AssetPath
variable and assert that runner.calls[0].args[len(runner.calls[0].args)-1]
equals AssetPath. Retain the existing argument and sidecar assertions while
adding this final positional-argument check in both tests.
In `@pkg/toolchain/verification/signature.go`:
- Around line 115-117: Update the error handling after
downloadCosignOptionSidecars in the verification flow to pass failures through
the same signature-policy branch used by downloadCosignSidecars, rather than
returning immediately. Preserve optional-verification skip recording and ensure
required verification applies the ErrSignatureRequired wrapper.
- Around line 149-152: Update Verifier.downloadCosignOptionSidecars to proceed
whenever any supported remote Cosign sidecar option is present, including
standalone --certificate, --signature, --key, --bundle, and mixed local/remote
combinations, instead of requiring hasRemoteCertificateSignaturePair(args).
Ensure all such remote options are localized through the existing Atmos download
and retry handling.
---
Nitpick comments:
In `@pkg/toolchain/install_test.go`:
- Around line 30-41: Refactor TestRightAlignInstallProgress into a table-driven
test with named cases for the terminal-edge and narrow-terminal scenarios. Store
each case’s input and expected output, then iterate with t.Run while preserving
the existing suffix, width, and unchanged-line assertions.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 29370ded-bce8-4cbe-8333-09a564d7fc19
📒 Files selected for processing (32)
.atmos.d/dev.yaml.gitignorecmd/toolchain/install.gocmd/toolchain/toolchain.gopkg/cache/file_cache.gopkg/cache/filelock.gopkg/cache/filelock_unix.gopkg/cache/filelock_windows.gopkg/filelock/filelock.gopkg/filelock/filelock_test.gopkg/schema/schema.gopkg/toolchain/filemanager/lockfile.gopkg/toolchain/install.gopkg/toolchain/install_test.gopkg/toolchain/installer/download.gopkg/toolchain/installer/download_test.gopkg/toolchain/installer/installer.gopkg/toolchain/installer/lockfile_update.gopkg/toolchain/installer/lockfile_update_test.gopkg/toolchain/installer/verifier_command_test.gopkg/toolchain/installer/version.gopkg/toolchain/remove.gopkg/toolchain/tool_versions.gopkg/toolchain/tool_versions_test.gopkg/toolchain/types.gopkg/toolchain/uninstall.gopkg/toolchain/uninstall_test.gopkg/toolchain/verification/checksum_test.gopkg/toolchain/verification/signature.gopkg/toolchain/verification/signature_rekor.gopkg/toolchain/verification/signature_rekor_test.gopkg/toolchain/verification/signature_test.go
💤 Files with no reviewable changes (2)
- pkg/cache/filelock_unix.go
- pkg/cache/filelock_windows.go
|
💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏 |
…kage-installs # Conflicts: # .atmos.d/dev.yaml
|
Important Cloud Posse Engineering Team Review RequiredThis pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes. To expedite this process, reach out to us on Slack in the |
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (75.94%) is below the target coverage (85.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #2758 +/- ##
========================================
Coverage 81.88% 81.89%
========================================
Files 1720 1721 +1
Lines 162234 162657 +423
========================================
+ Hits 132853 133209 +356
- Misses 22114 22165 +51
- Partials 7267 7283 +16
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
These changes were released in v1.223.1-rc.1. |
what
.tool-versions, and uninstall mutations.why
references
Summary by CodeRabbit
--max-concurrency/toolchain.max_concurrency(requires ≥ 1), plus enhanced batch progress and download progress reporting..tool-versions, and tool lockfiles; serialized trust repair and improved macOS retry classification..tool-versions.lockfiles.