Skip to content

refactor: consolidate file locking - #2856

Merged
Andriy Knysh (aknysh) merged 12 commits into
mainfrom
osterman/consolidate-file-locking
Aug 5, 2026
Merged

Andriy Knysh (aknysh) merged 12 commits into
mainfrom
osterman/consolidate-file-locking

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

what

  • Consolidate production file locking behind pkg/cache.FileLock, covering cloud configuration, Helm repositories, and workdir metadata.
  • Add explicit lock-path and nonblocking shared-read APIs with Unix and Windows coverage.

why

  • Preserve each caller's existing lock paths and timeouts while removing duplicated gofrs/flock acquisition and release logic.
  • Standardize Windows graceful degradation and prevent contended metadata reads from falling back to unlocked access.

references

  • None.

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability when credential, configuration, cache, repository, and metadata files are accessed simultaneously.
    • Added consistent lock timeouts and clearer handling when files are temporarily unavailable.
    • Preserved existing updates, cleanup behavior, and error reporting during file operations.
  • New Features

    • Added non-blocking read-lock support for safer access to shared files.
    • Improved coordination of file access across supported platforms.

@atmos-pro

atmos-pro Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@github-actions github-actions Bot added the size/l Large size PR label Aug 3, 2026
@mergify

mergify Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏

@mergify mergify Bot added the conflict This PR has conflicts label Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR replaces custom flock polling with shared, context-aware cache locks. It adds non-blocking read locks and migrates cloud credential, Docker, Helm, and workdir metadata operations.

Changes

Shared file-lock migration

Layer / File(s) Summary
Cache lock API
pkg/cache/filelock*, pkg/cache/file_cache_test.go
Adds explicit lock-path construction and TryWithRLock support for Unix, Windows, mocks, and tests.
Cloud credential file operations
pkg/auth/cloud/aws/*, pkg/auth/cloud/gcp/*, pkg/auth/providers/azure/*
Moves credential reads, writes, profile updates, and cleanup into shared context-bound lock callbacks.
Azure cache and setup writes
pkg/auth/cloud/azure/*
Uses private shared-lock helpers for credentials, MSAL caches, profiles, and service-principal entries.
Application lock integration
pkg/auth/cloud/docker/*, pkg/component/helm/*, pkg/provisioner/workdir/*
Migrates Docker, Helm, and workdir metadata operations to shared locks, including non-blocking metadata reads.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested labels: patch

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: consolidating file locking across multiple components.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch osterman/consolidate-file-locking

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.

❤️ Share

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

@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: 4

🧹 Nitpick comments (10)
pkg/auth/cloud/gcp/files.go (1)

305-321: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

The cleanup lock does not exclude concurrent writers, and it leaves a lock file behind.

Two small points, both non-blocking:

  1. lockTarget is a synthetic path, so its lock is disjoint from the locks that WriteADCFile, WritePropertiesFile, and WriteAccessTokenFile take on their own file paths. Cleanup and a concurrent write are therefore not mutually exclusive. The outcome is still benign, because deletion is the intended result.
  2. cache.NewFileLock creates <identity>.cleanup.lock inside providerDir, and cleanup never removes it. One stale file remains per cleaned identity, so providerDir never becomes empty.

If either matters for your directory-emptiness checks, add a best-effort removal of the lock file after the callback returns.

🤖 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/auth/cloud/gcp/files.go` around lines 305 - 321, Update the cleanup flow
around withFileLock so it uses the same lock coordination as WriteADCFile,
WritePropertiesFile, and WriteAccessTokenFile, and best-effort removes the
generated cleanup lock file after the callback completes. Preserve the existing
cleanup error aggregation and return behavior while ensuring the lock artifact
does not remain in providerDir.
pkg/auth/providers/azure/device_code_cache.go (1)

567-578: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Name the timeout constant.

The 10*time.Second value is a magic number here, while the sibling helpers in pkg/auth/cloud/aws/files.go and pkg/auth/cloud/azure/files.go use a fileLockTimeout constant. Declare a package-level constant in this package for the same value. Purely cosmetic; take it or leave it.

🤖 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/auth/providers/azure/device_code_cache.go` around lines 567 - 578,
Replace the magic 10*time.Second value in withAzureFileLock with a package-level
fileLockTimeout constant set to the same duration, matching the sibling helpers’
naming and usage.
pkg/auth/cloud/azure/msal_cache.go (1)

54-69: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

The MSAL context is checked but not propagated.

Line 50 checks ctx.Err(), then withFileLock builds a fresh background context with its own timeout. If the MSAL caller cancels while the lock is contended, Replace still blocks for the full fileLockTimeout. If withFileLock gains a context parameter, pass ctx here. Optional, and it pairs with the same note on pkg/auth/cloud/aws/files.go.

🤖 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/auth/cloud/azure/msal_cache.go` around lines 54 - 69, Update the cache
replacement flow around withFileLock in Replace to accept and propagate the
caller’s ctx instead of creating an independent background context, so
cancellation while waiting for the file lock stops the operation promptly.
Preserve the existing read, unmarshal, and error-handling behavior inside the
lock callback.
pkg/auth/cloud/aws/files.go (1)

70-81: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider accepting a context.Context parameter.

withFileLock always creates a fresh background context. Callers such as DeleteIdentity (line 644) already hold a ctx, so caller cancellation cannot abort lock acquisition. Passing the caller context keeps cancellation working and matches the guideline that context.Context is for cancellation and deadlines.

♻️ Proposed signature change
-func withFileLock(path string, fn func() error) error {
-	ctx, cancel := context.WithTimeout(context.Background(), fileLockTimeout)
+func withFileLock(ctx context.Context, path string, fn func() error) error {
+	ctx, cancel := context.WithTimeout(ctx, fileLockTimeout)
 	defer cancel()

This one is optional; the current form is safe.

🤖 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/auth/cloud/aws/files.go` around lines 70 - 81, Update withFileLock to
accept a caller-provided context.Context and derive the existing timeout context
from it instead of context.Background(). Pass the relevant caller context, such
as DeleteIdentity’s ctx, through every withFileLock call while preserving the
timeout and error-wrapping behavior.

Source: Coding guidelines

pkg/auth/cloud/azure/files.go (1)

153-169: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Consider a shared read lock here.

LoadCredentials performs a read only, but it takes the exclusive lock. Concurrent reads across processes now serialize. The cache lock layer in this stack adds a shared-lock API, so this call site is a natural fit for it. Not a blocker; the current form is correct.

🤖 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/auth/cloud/azure/files.go` around lines 153 - 169, Update LoadCredentials
to use the cache lock layer’s shared/read-lock API around the read-only
credential loading callback instead of withFileLock’s exclusive lock. Preserve
the existing file reading, JSON unmarshalling, logging, and error propagation
behavior.
pkg/cache/file_cache_test.go (1)

46-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Let the mock represent contention without an error.

The production API has a distinct (false, nil) result. This mock only returns false when withRLockErr is set and otherwise always invokes fn. Add a separate acquisition-status field that defaults to true, then add coverage for (false, nil).

🤖 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/cache/file_cache_test.go` around lines 46 - 51, Update
mockFileLock.TryWithRLock to use a separate acquisition-status field that
defaults to true, returning false with a nil error when configured to simulate
contention and invoking fn only when the lock is acquired. Add test coverage for
the (false, nil) result while preserving existing error behavior through
withRLockErr.

Source: Coding guidelines

pkg/cache/filelock_unix_test.go (1)

212-230: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the complete TryWithRLock result matrix.

This test covers only (false, nil) under contention. Add or retain table-driven cases for successful Unix acquisition, callback-error propagation, and acquisition errors. The Windows test covers only the no-op success path.

🤖 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/cache/filelock_unix_test.go` around lines 212 - 230, Expand
TestTryWithRLock_SkipsContendedRead into table-driven coverage for the complete
TryWithRLock result matrix: successful Unix acquisition, callback-error
propagation, contention returning (false, nil), and acquisition errors. Assert
acquired status, callback execution, and returned errors for each case, and
retain the existing contention behavior; also add equivalent Windows coverage
beyond the current no-op success path if supported by the test structure.

Source: Coding guidelines

pkg/provisioner/workdir/metadata_lock_unix.go (1)

23-24: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Name the timeout.

500*time.Millisecond is a magic value on the write path. A named package constant such as metadataLockTimeout documents the intent and keeps the Unix and Windows implementations aligned. Also confirm 500 ms matches the previous flock polling budget, because a shorter budget turns contention into a hard error for callers.

🤖 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/provisioner/workdir/metadata_lock_unix.go` around lines 23 - 24, Replace
the inline 500*time.Millisecond timeout in the metadata lock write path with a
named package constant such as metadataLockTimeout, and use that constant in
both Unix and Windows implementations. Verify the constant remains 500
milliseconds so it preserves the previous flock polling budget and existing
contention behavior.
pkg/component/helm/repository.go (2)

47-87: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Lock scope and path handling look right.

The call uses cache.NewFileLockAtPath with the existing repositoryLockPath helper, so the lock path stays <repoFile without ext>.lock and no second .lock suffix is appended. All read-modify-write work now runs inside the lock, which closes the earlier gap between load and write.

One optional cleanup: the callback body is the bulk of the function. Extracting it into a named helper such as updateRepositories(settings, repoFile, repositories) would keep setupHelmRepositories a short, linear pipeline.

🤖 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/component/helm/repository.go` around lines 47 - 87, Optionally extract
the lock callback body from setupHelmRepositories into a named helper such as
updateRepositories(settings, repoFile, repositories), preserving the existing
load, repository update, index download, and write behavior. Keep
setupHelmRepositories focused on context creation, lock acquisition, and error
handling.

43-45: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Tighten the directory permissions.

os.ModePerm requests 0777. The Helm repository file written at Line 77 can hold Username and Password values from repo.Entry, so the parent directory should not be world-writable. Use 0o700 (or 0o755 if other tools must read it). The !os.IsExist(err) guard is also redundant, because os.MkdirAll returns nil when the directory already exists.

🔒 Suggested change
-	if err := os.MkdirAll(filepath.Dir(repoFile), os.ModePerm); err != nil && !os.IsExist(err) {
+	if err := os.MkdirAll(filepath.Dir(repoFile), repositoryDirPerm); err != nil {
 		return err
 	}

Declare repositoryDirPerm next to the existing repositoryFilePerm constant.

🤖 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/component/helm/repository.go` around lines 43 - 45, In the repository
directory creation logic, replace os.ModePerm with a dedicated repositoryDirPerm
constant declared beside repositoryFilePerm, using 0o700 (or 0o755 when shared
read access is required). Simplify the MkdirAll error handling by removing the
redundant os.IsExist guard while preserving error returns from MkdirAll.
🤖 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 `@pkg/auth/cloud/azure/setup.go`:
- Around line 628-634: Widen each Azure profile read-modify-write critical
section so the lock callback owns the complete operation: in
pkg/auth/cloud/azure/setup.go lines 628-634, move the read,
UpdateSubscriptionsInProfile merge, and marshal inside withFileLock; apply the
same change to the entry merge loop and marshal at lines 753-759; in
pkg/auth/providers/azure/device_code_cache.go lines 534-541, move the read,
UpdateSubscriptionsInProfile merge, and marshal inside withAzureFileLock. Use
the AWS WriteCredentials flow as the model, with only the final write and
logging remaining after the callback as appropriate.

In `@pkg/auth/cloud/docker/config.go`:
- Around line 137-145: Update ConfigManager.withConfigLock to use a context with
a finite deadline instead of context.Background when calling WithLockContext,
ensuring WriteAuth and RemoveAuth cannot wait indefinitely on a stale or
long-held lock. Preserve existing ErrCacheLocked wrapping and error propagation,
including converting a background timeout into the established lock error where
appropriate.

In `@pkg/auth/providers/azure/device_code_cache.go`:
- Around line 557-562: Update the error handling around withAzureFileLock in the
device-code cache write path so failures from both lock acquisition and
os.WriteFile are reported accurately. Replace the lock-specific log message with
a generic cache-write failure message, or distinguish
azureCloud.ErrFileLockTimeout before logging, while preserving the existing
return-false behavior.

In `@pkg/provisioner/workdir/metadata_lock_unix.go`:
- Around line 65-71: Update the error handling around TryWithRLock to check
acquired before interpreting err: when the lock was acquired, return the
callback error unchanged, preserving the precise errors built by the read and
unmarshal paths; only wrap err with the read-lock acquisition explanation and
ErrWorkdirMetadata when acquired is false.

---

Nitpick comments:
In `@pkg/auth/cloud/aws/files.go`:
- Around line 70-81: Update withFileLock to accept a caller-provided
context.Context and derive the existing timeout context from it instead of
context.Background(). Pass the relevant caller context, such as DeleteIdentity’s
ctx, through every withFileLock call while preserving the timeout and
error-wrapping behavior.

In `@pkg/auth/cloud/azure/files.go`:
- Around line 153-169: Update LoadCredentials to use the cache lock layer’s
shared/read-lock API around the read-only credential loading callback instead of
withFileLock’s exclusive lock. Preserve the existing file reading, JSON
unmarshalling, logging, and error propagation behavior.

In `@pkg/auth/cloud/azure/msal_cache.go`:
- Around line 54-69: Update the cache replacement flow around withFileLock in
Replace to accept and propagate the caller’s ctx instead of creating an
independent background context, so cancellation while waiting for the file lock
stops the operation promptly. Preserve the existing read, unmarshal, and
error-handling behavior inside the lock callback.

In `@pkg/auth/cloud/gcp/files.go`:
- Around line 305-321: Update the cleanup flow around withFileLock so it uses
the same lock coordination as WriteADCFile, WritePropertiesFile, and
WriteAccessTokenFile, and best-effort removes the generated cleanup lock file
after the callback completes. Preserve the existing cleanup error aggregation
and return behavior while ensuring the lock artifact does not remain in
providerDir.

In `@pkg/auth/providers/azure/device_code_cache.go`:
- Around line 567-578: Replace the magic 10*time.Second value in
withAzureFileLock with a package-level fileLockTimeout constant set to the same
duration, matching the sibling helpers’ naming and usage.

In `@pkg/cache/file_cache_test.go`:
- Around line 46-51: Update mockFileLock.TryWithRLock to use a separate
acquisition-status field that defaults to true, returning false with a nil error
when configured to simulate contention and invoking fn only when the lock is
acquired. Add test coverage for the (false, nil) result while preserving
existing error behavior through withRLockErr.

In `@pkg/cache/filelock_unix_test.go`:
- Around line 212-230: Expand TestTryWithRLock_SkipsContendedRead into
table-driven coverage for the complete TryWithRLock result matrix: successful
Unix acquisition, callback-error propagation, contention returning (false, nil),
and acquisition errors. Assert acquired status, callback execution, and returned
errors for each case, and retain the existing contention behavior; also add
equivalent Windows coverage beyond the current no-op success path if supported
by the test structure.

In `@pkg/component/helm/repository.go`:
- Around line 47-87: Optionally extract the lock callback body from
setupHelmRepositories into a named helper such as updateRepositories(settings,
repoFile, repositories), preserving the existing load, repository update, index
download, and write behavior. Keep setupHelmRepositories focused on context
creation, lock acquisition, and error handling.
- Around line 43-45: In the repository directory creation logic, replace
os.ModePerm with a dedicated repositoryDirPerm constant declared beside
repositoryFilePerm, using 0o700 (or 0o755 when shared read access is required).
Simplify the MkdirAll error handling by removing the redundant os.IsExist guard
while preserving error returns from MkdirAll.

In `@pkg/provisioner/workdir/metadata_lock_unix.go`:
- Around line 23-24: Replace the inline 500*time.Millisecond timeout in the
metadata lock write path with a named package constant such as
metadataLockTimeout, and use that constant in both Unix and Windows
implementations. Verify the constant remains 500 milliseconds so it preserves
the previous flock polling budget and existing contention behavior.
🪄 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 Plus

Run ID: 9450e2c3-95b1-4ca7-8ca9-8e5a5af19bbd

📥 Commits

Reviewing files that changed from the base of the PR and between 9343caf and c4b91dd.

📒 Files selected for processing (15)
  • pkg/auth/cloud/aws/files.go
  • pkg/auth/cloud/azure/files.go
  • pkg/auth/cloud/azure/msal_cache.go
  • pkg/auth/cloud/azure/setup.go
  • pkg/auth/cloud/docker/config.go
  • pkg/auth/cloud/gcp/files.go
  • pkg/auth/providers/azure/device_code_cache.go
  • pkg/cache/file_cache_test.go
  • pkg/cache/filelock.go
  • pkg/cache/filelock_unix.go
  • pkg/cache/filelock_unix_test.go
  • pkg/cache/filelock_windows.go
  • pkg/cache/filelock_windows_test.go
  • pkg/component/helm/repository.go
  • pkg/provisioner/workdir/metadata_lock_unix.go

Comment thread pkg/auth/cloud/azure/setup.go Resolved
Comment thread pkg/auth/cloud/docker/config.go Resolved
@github-actions

github-actions Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@osterman Erik Osterman (Cloud Posse) (osterman) added the minor New features that do not break anything label Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Warning

Release Documentation Required

This PR is labeled minor or major and requires documentation updates:

  • Changelog entry - Add a blog post in website/blog/YYYY-MM-DD-feature-name.mdx
  • Roadmap update - Update website/src/data/roadmap.js with the new milestone

Alternatively: If this change doesn't require release documentation, remove the minor or major label.

@mergify mergify Bot removed the conflict This PR has conflicts label Aug 3, 2026
@codecov

codecov Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.36403% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.75%. Comparing base (ce380f0) to head (96da953).

Files with missing lines Patch % Lines
pkg/auth/cloud/gcp/files.go 72.97% 11 Missing and 9 partials ⚠️
pkg/auth/cloud/aws/files.go 90.00% 8 Missing and 7 partials ⚠️
pkg/auth/cloud/azure/setup.go 92.30% 2 Missing and 2 partials ⚠️
pkg/auth/cloud/azure/files.go 95.65% 1 Missing and 1 partial ⚠️
pkg/auth/cloud/docker/config.go 91.66% 1 Missing and 1 partial ⚠️
pkg/auth/providers/azure/device_code_cache.go 94.87% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2856      +/-   ##
==========================================
+ Coverage   82.62%   82.75%   +0.12%     
==========================================
  Files        1860     1860              
  Lines      180353   180240     -113     
==========================================
+ Hits       149025   149159     +134     
+ Misses      23445    23295     -150     
+ Partials     7883     7786      -97     
Flag Coverage Δ
unittests 82.75% <90.36%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/auth/cloud/azure/msal_cache.go 100.00% <100.00%> (+41.81%) ⬆️
pkg/cache/filelock_unix.go 100.00% <100.00%> (ø)
pkg/component/helm/repository.go 100.00% <100.00%> (+32.43%) ⬆️
pkg/provisioner/workdir/metadata_lock_unix.go 100.00% <100.00%> (+27.86%) ⬆️
pkg/auth/cloud/azure/files.go 96.22% <95.65%> (+19.30%) ⬆️
pkg/auth/cloud/docker/config.go 92.68% <91.66%> (+15.30%) ⬆️
pkg/auth/providers/azure/device_code_cache.go 80.07% <94.87%> (+6.42%) ⬆️
pkg/auth/cloud/azure/setup.go 92.56% <92.30%> (+7.93%) ⬆️
pkg/auth/cloud/aws/files.go 85.25% <90.00%> (+12.59%) ⬆️
pkg/auth/cloud/gcp/files.go 76.13% <72.97%> (+10.33%) ⬆️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@osterman Erik Osterman (Cloud Posse) (osterman) added no-release Do not create a new release (wait for additional code changes) and removed minor New features that do not break anything labels Aug 3, 2026
The file-locking consolidation refactor introduced new lock-wrapper
helpers (withFileLock, withConfigLock, withAzureFileLock,
withMetadataFileLockUnix, TryWithRLock) across aws/azure/gcp/docker
auth, helm repositories, and workdir metadata, but none of their
lock-failure branches were exercised, dropping PR patch coverage to
68% against the 85% gate. Add deterministic, fast lock-denial tests
(unlockable lock paths, no real timeouts) for each wrapper's error path.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
pkg/cache/filelock_windows.go intentionally always executes fn() and
never returns ErrCacheLocked (native Windows locks previously caused
cache-operation timeouts). The lock-denial tests added for the file
locking consolidation assumed a real lock attempt, so they failed CI
on windows: TestWithFileLock_WrapsErrCacheLocked (aws),
TestConfigManager_WithConfigLock_WrapsErrCacheLocked (docker), and
TestWithAzureFileLock_WrapsErrCacheLocked /
TestDeviceCodeProvider_updateAzureProfile_LockFailure (providers/azure).
Skip them on windows, matching the pattern already used in the gcp,
helm, and azure/files sibling tests.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 4, 2026
Widens lock-timeout coverage (docker config, AWS/Azure ctx propagation),
adds a shared read-lock path for Azure credential loads, fixes a leaked
GCP cleanup lock file, replaces magic lock-timeout literals with named
constants, and extracts a helm repository-update helper for testability.
Adds targeted failure-injection tests across the touched packages to
close the Codecov patch-coverage gap (76.13% -> 85.57%).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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: 4

🧹 Nitpick comments (6)
pkg/cache/filelock_unix_test.go (1)

260-268: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

The "lock acquisition error" case depends on 1ms timing.

TryWithRLock uses a 1ms context. It returns (false, cacheLockError(err)) only when ctx.Err() is still nil after the failed open. If the 1ms budget expires first on a loaded CI machine, the same case returns (false, nil) and the ErrCacheLocked assertion fails. The ENOENT open is normally far faster than 1ms, so this is a narrow flake window, not a current defect. If flakes appear, consider asserting the union of both allowed outcomes for this case only.

🤖 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/cache/filelock_unix_test.go` around lines 260 - 268, The “lock
acquisition error” test is timing-sensitive because TryWithRLock may return
either ErrCacheLocked or nil when its 1ms context expires. Update this test
case’s assertion to accept both outcomes while preserving wantAcquired=false and
wantExecuted=false, without changing other lock behavior tests.
pkg/auth/cloud/aws/files.go (1)

221-221: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

The write paths still pass context.Background() while removal paths now thread the caller context.

RemoveConfigProfile and RemoveCredentialsProfile accept ctx and forward it, so a cancelled command aborts a contended removal. WriteCredentials and WriteConfig keep context.Background(), so a cancelled command still waits the full fileLockTimeout on a contended write. That asymmetry is not a bug today, but it makes the locking contract uneven across the same file manager. Threading ctx through the two write methods would need signature changes at their callers, so it fits a follow-up.

Also applies to: 315-315

🤖 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/auth/cloud/aws/files.go` at line 221, Update the write paths in
WriteCredentials and WriteConfig to accept caller-provided context and pass it
to withFileLock instead of using context.Background(). Propagate the signature
changes through all callers so cancelled commands can abort contended writes
consistently with RemoveConfigProfile and RemoveCredentialsProfile.
pkg/auth/cloud/docker/config_test.go (1)

309-315: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider extracting the Windows and root skip pair into a helper.

This same two-check pattern appears as skipIfCannotDenyDirWrite in pkg/auth/cloud/gcp/files_test.go, pkg/auth/cloud/azure/setup_test.go, and pkg/auth/providers/azure/device_code_cache_test.go. A local helper in this package keeps the intent in one place if more permission tests land here. Test helpers are not importable across packages, so a small per-package copy is the expected shape.

🤖 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/auth/cloud/docker/config_test.go` around lines 309 - 315, The
permission-test setup in TestConfigManager_SaveConfig_WriteFailure should be
extracted into a package-local skipIfCannotDenyDirWrite helper, matching the
existing helper pattern in the referenced test packages. Replace the duplicated
Windows and root checks with a call to this helper, preserving both skip
conditions and messages.
pkg/auth/cloud/azure/setup_test.go (1)

25-33: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

This package now has two helpers for the same job.

skipIfCannotDenyDirWrite here uses os.Getuid(), while requireLockDenied in pkg/auth/cloud/azure/msal_cache_test.go Lines 175-187 performs the same Windows and root checks with os.Geteuid() plus a chmod. Both live in package azure, so either can call the other. Folding the skip logic into one helper removes the drift. The requireLockDenied name also reads like a testify require assertion, while it actually skips.

🤖 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/auth/cloud/azure/setup_test.go` around lines 25 - 33, Consolidate the
duplicate Windows/root permission-skip logic by reusing a single helper between
skipIfCannotDenyDirWrite and requireLockDenied, and remove the redundant helper
implementation. Rename requireLockDenied to a skip-oriented name if it remains
the shared helper, preserving its existing effective-UID and chmod behavior and
updating all callers.
pkg/auth/cloud/gcp/files_test.go (1)

497-499: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

The Windows skip message no longer matches every caller.

skipIfCannotDenyDirWrite now guards write-permission tests such as TestWriteADCFile_WriteFailure_WrapsSentinel, where the reason is that Windows does not enforce directory write bits, not that file locking is a no-op. The sibling helper in pkg/auth/cloud/azure/setup_test.go uses the accurate wording. Aligning the message keeps skip output honest.

✏️ Proposed message tweak
 	if runtime.GOOS == "windows" {
-		t.Skip("Windows file locking is a no-op fallback and never returns ErrCacheLocked")
+		t.Skip("directory write-permission bits are not enforced the same way on Windows")
 	}
🤖 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/auth/cloud/gcp/files_test.go` around lines 497 - 499, Update the Windows
skip message in skipIfCannotDenyDirWrite to accurately describe that Windows
does not enforce directory write permissions, rather than referring only to file
locking or ErrCacheLocked; preserve the existing skip condition and behavior.
pkg/auth/cloud/azure/files_test.go (1)

588-605: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

This read-lock test depends on the 1ms fallback window.

cache.WithRLock runs the callback without a lock when the acquire error is ErrAcquire and its 1ms context has already expired (pkg/cache/filelock_unix.go Lines 49-61). The test relies on the ENOENT open finishing inside that 1ms so the hard-error path is taken. If a loaded runner expires the context first, withFileRLock returns nil and executed becomes true, flipping both assertions.

The window is small, so this is not a defect today. Flag it here because the same shape appears in pkg/cache/filelock_unix_test.go. If flakes show up, the deterministic alternative is to make the lock path unopenable for a reason that cannot race, such as an unsearchable parent directory.

🤖 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/auth/cloud/azure/files_test.go` around lines 588 - 605, Make
TestWithFileRLock_WrapsErrCacheLocked deterministic by replacing the
nonexistent-subdirectory setup with a lock path under an unsearchable parent
directory, avoiding reliance on the 1ms acquisition window. Preserve the
assertions that withFileRLock returns ErrFileLockTimeout and does not execute
the callback, and apply the same pattern to the corresponding file-lock test if
applicable.
🤖 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 `@pkg/auth/cloud/aws/files_test.go`:
- Around line 1108-1111: Guard permission-based failure tests against
environments where permission bits are ineffective: in
pkg/auth/cloud/aws/files_test.go, add a package-local skipIfCannotDenyDirWrite
helper and call it from all six permission-based tests at lines 1108, 1134,
1187, 1209, 1233, and 1254, replacing their Windows-only skips. In
pkg/component/helm/repository_test.go lines 122-131 and 256-271, add an
os.Getuid() == 0 skip alongside the existing Windows checks so root does not
proceed with the lock-file or repositories.yaml permission tests.

In `@pkg/auth/cloud/azure/files.go`:
- Around line 127-145: Update WriteCredentials to replace the truncating
os.WriteFile call with the existing atomic file-writing helper, such as
WriteFileAtomic, while preserving PermissionRW and existing error wrapping.
Apply the same change to the other credentials-writing path around the
referenced symbol so readers never observe partially written files.

In `@pkg/auth/cloud/azure/msal_cache_test.go`:
- Around line 239-251: Update TestNewMSALCache_RealmIsolatesDefaultPath to use
the existing temporary-home setup pattern from TestNewMSALCache, redirecting the
relevant home-directory environment variables before calling NewMSALCache and
restoring them afterward. Build expectedPath from that temporary home so the
test does not create directories under the real user home.

In `@pkg/auth/cloud/gcp/files.go`:
- Around line 202-211: Replace the file-specific locking around withFileLock and
the other write operations with one persistent per-identity lock target located
outside directories removed by CleanupIdentityFiles. Use that same target in all
three write functions and CleanupIdentityFiles, and preserve the lock file after
WithLockContext returns so concurrent callers cannot bypass mutual exclusion.
Add contention coverage for cleanup racing with each write operation.

---

Nitpick comments:
In `@pkg/auth/cloud/aws/files.go`:
- Line 221: Update the write paths in WriteCredentials and WriteConfig to accept
caller-provided context and pass it to withFileLock instead of using
context.Background(). Propagate the signature changes through all callers so
cancelled commands can abort contended writes consistently with
RemoveConfigProfile and RemoveCredentialsProfile.

In `@pkg/auth/cloud/azure/files_test.go`:
- Around line 588-605: Make TestWithFileRLock_WrapsErrCacheLocked deterministic
by replacing the nonexistent-subdirectory setup with a lock path under an
unsearchable parent directory, avoiding reliance on the 1ms acquisition window.
Preserve the assertions that withFileRLock returns ErrFileLockTimeout and does
not execute the callback, and apply the same pattern to the corresponding
file-lock test if applicable.

In `@pkg/auth/cloud/azure/setup_test.go`:
- Around line 25-33: Consolidate the duplicate Windows/root permission-skip
logic by reusing a single helper between skipIfCannotDenyDirWrite and
requireLockDenied, and remove the redundant helper implementation. Rename
requireLockDenied to a skip-oriented name if it remains the shared helper,
preserving its existing effective-UID and chmod behavior and updating all
callers.

In `@pkg/auth/cloud/docker/config_test.go`:
- Around line 309-315: The permission-test setup in
TestConfigManager_SaveConfig_WriteFailure should be extracted into a
package-local skipIfCannotDenyDirWrite helper, matching the existing helper
pattern in the referenced test packages. Replace the duplicated Windows and root
checks with a call to this helper, preserving both skip conditions and messages.

In `@pkg/auth/cloud/gcp/files_test.go`:
- Around line 497-499: Update the Windows skip message in
skipIfCannotDenyDirWrite to accurately describe that Windows does not enforce
directory write permissions, rather than referring only to file locking or
ErrCacheLocked; preserve the existing skip condition and behavior.

In `@pkg/cache/filelock_unix_test.go`:
- Around line 260-268: The “lock acquisition error” test is timing-sensitive
because TryWithRLock may return either ErrCacheLocked or nil when its 1ms
context expires. Update this test case’s assertion to accept both outcomes while
preserving wantAcquired=false and wantExecuted=false, without changing other
lock behavior tests.
🪄 Autofix

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 Plus

Run ID: 98e91bea-33f6-4d34-96a3-96bf32d15265

📥 Commits

Reviewing files that changed from the base of the PR and between 814fbdd and 89f7294.

📒 Files selected for processing (24)
  • pkg/auth/cloud/aws/files.go
  • pkg/auth/cloud/aws/files_test.go
  • pkg/auth/cloud/azure/files.go
  • pkg/auth/cloud/azure/files_test.go
  • pkg/auth/cloud/azure/msal_cache.go
  • pkg/auth/cloud/azure/msal_cache_test.go
  • pkg/auth/cloud/azure/setup.go
  • pkg/auth/cloud/azure/setup_test.go
  • pkg/auth/cloud/docker/config.go
  • pkg/auth/cloud/docker/config_test.go
  • pkg/auth/cloud/gcp/files.go
  • pkg/auth/cloud/gcp/files_test.go
  • pkg/auth/providers/azure/device_code_cache.go
  • pkg/auth/providers/azure/device_code_cache_test.go
  • pkg/cache/file_cache_test.go
  • pkg/cache/filelock.go
  • pkg/cache/filelock_unix.go
  • pkg/cache/filelock_unix_test.go
  • pkg/cache/filelock_windows.go
  • pkg/cache/filelock_windows_test.go
  • pkg/component/helm/repository.go
  • pkg/component/helm/repository_test.go
  • pkg/provisioner/workdir/metadata_lock_unix.go
  • pkg/provisioner/workdir/metadata_lock_unix_test.go
🚧 Files skipped from review as they are similar to previous changes (11)
  • pkg/cache/filelock_windows_test.go
  • pkg/auth/cloud/azure/msal_cache.go
  • pkg/cache/filelock.go
  • pkg/cache/file_cache_test.go
  • pkg/auth/cloud/docker/config.go
  • pkg/cache/filelock_unix.go
  • pkg/auth/providers/azure/device_code_cache.go
  • pkg/cache/filelock_windows.go
  • pkg/provisioner/workdir/metadata_lock_unix.go
  • pkg/component/helm/repository.go
  • pkg/auth/cloud/azure/setup.go

Comment thread pkg/auth/cloud/aws/files_test.go Resolved
Comment thread pkg/auth/cloud/azure/files.go Resolved
Comment thread pkg/auth/cloud/azure/msal_cache_test.go Resolved
Comment thread pkg/auth/cloud/gcp/files.go Resolved
…-safe tests

Addresses a second round of CodeRabbit review findings on the file-locking
PR: GCP write helpers and CleanupIdentityFiles now share a single persistent
per-identity lock (previously each locked a different path, so cleanup could
race a concurrent write and delete a directory out from under it -- also
reverts the prior fix that removed the lock file after use, which itself
introduced an unlink race for waiters). Azure credential writes now use an
atomic write so a best-effort concurrent read never observes a truncated
file. Permission-based failure-injection tests in aws/files_test.go and
helm/repository_test.go gain a root-uid guard, matching the pattern already
used in the azure/gcp test packages. A realm-isolation test no longer
creates directories under the real user home.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Bump fast-uri (transitive, via the pnpm.overrides entry) from 3.1.4 to
3.1.5, patching GHSA-7p8r-x3mc-p8w7 (CVE-2026-18446): a host-confusion
parsing bug where fast-uri and Node's WHATWG URL disagree on the host
extracted from a backslash-authority reference, which can defeat
host-based allowlist/SSRF checks built on fast-uri. Verified the website
still builds after the bump.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

@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)
pkg/auth/cloud/gcp/files_test.go (1)

514-524: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Table-drive the repeated lock-failure writer cases.

The three writer cases repeat the same permission and provider-directory setup. Use a table with the path initializer, operation, and expected sentinel. Keep TestCleanupIdentityFiles_LockFailure_WrapsError separate because it checks a different error contract.

Verify that each table entry preserves its operation-specific sentinel assertion. As per coding guidelines, “Use table-driven tests for testing multiple scenarios in Go.”

Also applies to: 543-550, 566-573

🤖 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/auth/cloud/gcp/files_test.go` around lines 514 - 524, Convert the three
repeated writer lock-failure test cases into a table-driven test with entries
for the path initializer, write operation, and expected sentinel error. Apply
the shared provider-directory permission setup and execute each case through the
table, preserving each operation-specific sentinel assertion. Keep
TestCleanupIdentityFiles_LockFailure_WrapsError separate because it validates a
different error contract.

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 `@pkg/auth/cloud/gcp/files.go`:
- Around line 215-220: Update WriteADCFile, WritePropertiesFile, and
WriteAccessTokenFile in pkg/auth/cloud/gcp/files.go (anchor lines 215-220;
sibling lines 245-250 and 298-303) so each creates or resolves its parent
credential directory inside the withFileLock callback, after acquiring the
shared identity lock. Ensure transient missing-parent errors are handled before
returning the corresponding ErrWrite*File error, while preserving the existing
write behavior.

In `@pkg/component/helm/repository_test.go`:
- Around line 21-33: Update skipIfCannotDenyDirWrite to check os.Geteuid() == 0
instead of os.Getuid() == 0, and replace the duplicated Windows/root permission
checks in TestSetupHelmRepositories_LockUnavailable with a call to this shared
helper.

---

Nitpick comments:
In `@pkg/auth/cloud/gcp/files_test.go`:
- Around line 514-524: Convert the three repeated writer lock-failure test cases
into a table-driven test with entries for the path initializer, write operation,
and expected sentinel error. Apply the shared provider-directory permission
setup and execute each case through the table, preserving each
operation-specific sentinel assertion. Keep
TestCleanupIdentityFiles_LockFailure_WrapsError separate because it validates a
different error contract.
🪄 Autofix

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 Plus

Run ID: 9df5147b-19b0-4273-9c18-0031826b7f22

📥 Commits

Reviewing files that changed from the base of the PR and between 89f7294 and 29126b7.

📒 Files selected for processing (6)
  • pkg/auth/cloud/aws/files_test.go
  • pkg/auth/cloud/azure/files.go
  • pkg/auth/cloud/azure/msal_cache_test.go
  • pkg/auth/cloud/gcp/files.go
  • pkg/auth/cloud/gcp/files_test.go
  • pkg/component/helm/repository_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • pkg/auth/cloud/azure/files.go
  • pkg/auth/cloud/aws/files_test.go
  • pkg/auth/cloud/azure/msal_cache_test.go

Comment thread pkg/auth/cloud/gcp/files.go Resolved
Comment thread pkg/component/helm/repository_test.go Resolved
…ot skip

GCP's WriteADCFile/WritePropertiesFile/WriteAccessTokenFile resolved their
credential paths (which create the parent identity directory) before
acquiring the shared identity lock added in the prior commit, leaving a
window where a concurrent CleanupIdentityFiles could remove that directory
between creation and the write. Path resolution now happens inside the
lock callback so directory creation and the write are atomic with respect
to cleanup. Also switches the shared skipIfCannotDenyDirWrite test helper
(and one remaining duplicated inline check) from os.Getuid() to
os.Geteuid(): permission checks are gated on the effective UID, not the
real one.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@aknysh
Andriy Knysh (aknysh) merged commit c14ce82 into main Aug 5, 2026
140 of 141 checks passed
@aknysh
Andriy Knysh (aknysh) deleted the osterman/consolidate-file-locking branch August 5, 2026 08:29
@atmos-pro

atmos-pro Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

Erik Osterman (Cloud Posse) (osterman) added a commit that referenced this pull request Aug 5, 2026
TryWithRLock (and its WithRLock sibling) gave the shared-lock attempt only
1ms before giving up. That's tight enough that ordinary scheduling/IO
jitter on a loaded CI runner -- not actual lock contention -- could miss
the deadline, and loadMetadataWithReadLockUnix treats a missed deadline
identically to "another process holds the lock": it silently returns
nil, nil. DefaultWorkdirManager.ListWorkdirs then drops that workdir from
the listing entirely, which is what caused
TestDefaultWorkdirManager_ListWorkdirs to intermittently fail in CI
(#2856 introduced the 1ms budget).

Bump the internal timeout to 50ms, comfortably above filelock's 10ms
retry interval, so a fast writer's exclusive lock also has a real chance
to clear within budget while still failing far faster than the 500ms/2s
timeouts used for actual blocking waits elsewhere in these packages.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

These changes were released in v1.225.0.

Andriy Knysh (aknysh) added a commit that referenced this pull request Aug 6, 2026
* feat(toolchain): support Aqua github_archive package type

Adds the github_archive package type to the Aqua-compatible toolchain
registry, matching upstream aquaproj/aqua behavior. Resolves the URL as
https://github.com/{owner}/{repo}/archive/refs/tags/{version}.tar.gz and
mirrors aqua's GetFormat() by hardcoding tar.gz (Asset, URL, Format, and
FormatOverrides are ignored for this type). Files[].src supports the
documented {{trimV .Version}}/path idiom via existing template expansion.

Unblocks Aqua registry entries for tools shipped as repository archives
(adr-tools, tfenv, tgswitch, etc.) without registry-level workarounds.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

* style(toolchain): reformat ar.ListAll calls per gofumpt

CI's gofumpt flagged three pre-existing ar.ListAll(ctx, ...) call sites in
aqua_test.go that the local hook had been missing. Apply the suggested
fix so the file passes the CI pre-commit step.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

* Address aqua github archive review comments

* feat(toolchain): support Aqua github_content package type

Adds the github_content package type to the Aqua-compatible toolchain
registry, matching upstream aquaproj/aqua behavior. Resolves the URL as
https://raw.githubusercontent.com/{owner}/{repo}/{version}/{path} for
single-file downloads from a GitHub repo at a tag. The Asset, URL,
Format, and FormatOverrides fields are intentionally ignored; the new
Path field on the Tool struct holds the file path inside the repo.

Field plumbing extends through AquaPackage -> Tool conversion, version
override application, and resetByPkgType (which now also clears Path
when switching away from github_content). New pure helpers
(validateGitHubContentFields, formatGitHubContentURL) split validation
from formatting for trivial unit testing without an Installer instance.

Unblocks Aqua registry entries for tools shipped as a single raw file
(kubens, kubectx, and many one-file shell-script projects) without
registry-level workarounds.

The remaining unsupported Aqua types (go_install, go_build_install,
cargo) require invoking a language toolchain at install time rather
than downloading an artifact and are deferred to a follow-up issue.

Co-Authored-By: Claude Opus 4.7 <[email protected]>

* fix(toolchain): validate github_content Path and correct unsupported-type doc

Reject absolute or ..-traversal Path values for github_content tools, and
stop recommending the also-unsupported go_install as an alternative to
go_build_install in the toolchain docs. Addresses CodeRabbit review on #2416.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* docs(toolchain): don't describe github_archive as a pre-built release

github_archive downloads GitHub's auto-generated source tarball, not a
compiled binary, so it doesn't belong alongside github_release/http as a
pre-built alternative to go_build_install. Addresses CodeRabbit follow-up
review on #2416.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* docs(toolchain): list format_overrides as ignored, fix comment periods

Blog post said only asset/url/format are ignored for github_archive, but
the code doc comments also ignore format_overrides -- make the two match.
Also adds trailing periods to two floating section-banner comments in
aqua_test.go per the godot comment-style convention. Addresses CodeRabbit
follow-up review on #2416.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* fix(workdir): widen try-read-lock timeout to stop spurious CI drops

TryWithRLock (and its WithRLock sibling) gave the shared-lock attempt only
1ms before giving up. That's tight enough that ordinary scheduling/IO
jitter on a loaded CI runner -- not actual lock contention -- could miss
the deadline, and loadMetadataWithReadLockUnix treats a missed deadline
identically to "another process holds the lock": it silently returns
nil, nil. DefaultWorkdirManager.ListWorkdirs then drops that workdir from
the listing entirely, which is what caused
TestDefaultWorkdirManager_ListWorkdirs to intermittently fail in CI
(#2856 introduced the 1ms budget).

Bump the internal timeout to 50ms, comfortably above filelock's 10ms
retry interval, so a fast writer's exclusive lock also has a real chance
to clear within budget while still failing far faster than the 500ms/2s
timeouts used for actual blocking waits elsewhere in these packages.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 <[email protected]>
Co-authored-by: Andriy Knysh <[email protected]>

This branch was successfully deployed

1 active (outdated) and 1 inactive deployments
screengrabs — 96da953c Deployed Aug 5, 2026 by aknysh via build #1062
preview — 36fa1798 Deployed Aug 5, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-release Do not create a new release (wait for additional code changes) size/l Large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants