Skip to content

fix: Use atmos_component for source provisioner workdir paths#2137

Merged
aknysh merged 6 commits intomainfrom
osterman/fix-jit-workdir-mismatch
Mar 4, 2026
Merged

fix: Use atmos_component for source provisioner workdir paths#2137
aknysh merged 6 commits intomainfrom
osterman/fix-jit-workdir-mismatch

Conversation

@osterman
Copy link
Member

@osterman osterman commented Mar 3, 2026

what

  • Fixed source provisioner (JIT vendoring) to use atmos_component (instance name) for workdir paths, matching the fix from PR Fix workdir collision for component instances sharing base component #2093
  • When metadata.component differs from the component instance name (e.g., instance demo-cluster-codepipeline-iac inheriting from base demo-cluster-codepipeline), both source pull and terraform plan/init now create the same workdir directory
  • Updated determineSourceTargetDirectory() and buildWorkdirPath() to check for atmos_component before falling back to the passed component name
  • Added comprehensive tests covering the atmos_component workdir isolation case

why

This is a follow-up to PR #2093 which fixed workdir collision for parallel component instances. However, that PR only updated the workdir provisioner. When both source and workdir are enabled, the workdir provisioner defers to the source provisioner (AutoProvisionSource), which was still using extractComponentName() that returns the base component name. This caused JIT vendoring to write source code to a different workdir path than terraform plan/init expects, breaking the fix.

references

Closes #2134
Follows PR #2093 (fix for issue #2091)

Summary by CodeRabbit

  • Refactor

    • Consolidated workdir path construction logic into a centralized utility for improved consistency.
    • Workdir paths now properly utilize component instance names when specified.
  • Tests

    • Added comprehensive test coverage for workdir path resolution and instance name handling.

Follow-up to PR #2093 - the source provisioner (JIT vendoring) was not updated
to use atmos_component (instance name) for workdir paths. This caused workdir
mismatch when metadata.component differs from the component instance name.

When both source and workdir are enabled, the workdir provisioner defers to the
source provisioner, which was still using extractComponentName() (base component).

Changes:
- determineSourceTargetDirectory(): Use atmos_component for workdir path
- buildWorkdirPath(): Use atmos_component for workdir path
- Add tests for atmos_component workdir path isolation

This ensures JIT vendoring uses the same workdir path as terraform plan/init.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@osterman osterman requested a review from a team as a code owner March 3, 2026 23:43
@github-actions github-actions bot added the size/m Medium size PR label Mar 3, 2026
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

Extract the duplicated workdir path logic into a single exported function
workdir.BuildPath() that handles atmos_component resolution. Both source
provisioner code paths now call this instead of reimplementing the logic.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@osterman osterman added the patch A minor, backward compatible change label Mar 3, 2026
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4f0f243 and 80719ba.

📒 Files selected for processing (6)
  • pkg/provisioner/source/provision_hook.go
  • pkg/provisioner/source/provision_hook_test.go
  • pkg/provisioner/source/source.go
  • pkg/provisioner/source/source_test.go
  • pkg/provisioner/workdir/types.go
  • pkg/provisioner/workdir/workdir.go
💤 Files with no reviewable changes (1)
  • pkg/provisioner/workdir/workdir.go

📝 Walkthrough

Walkthrough

This PR centralizes workdir path construction by introducing a new workdir.BuildPath() function that consistently uses atmos_component when available instead of the component instance name. The change replaces manual path assembly across multiple files with delegated calls to the centralized utility, addressing path divergence between vendoring and execution commands.

Changes

Cohort / File(s) Summary
Workdir Path Centralization
pkg/provisioner/source/provision_hook.go, pkg/provisioner/source/source.go, pkg/provisioner/workdir/types.go
Removed local WorkdirPath constant and manual path construction, replacing them with calls to new workdir.BuildPath() function. BuildPath accepts componentConfig and prioritizes atmos_component over the component instance name when constructing the path.
Test Coverage
pkg/provisioner/source/provision_hook_test.go, pkg/provisioner/source/source_test.go
Added tests verifying workdir path resolution with atmos_component handling, ensuring the target directory correctly incorporates the component instance name from componentConfig when present and falls back appropriately otherwise.
Cleanup
pkg/provisioner/workdir/workdir.go
Removed explanatory comment about stack-component naming isolation from createWorkdirDirectory.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • aknysh
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% 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 summarizes the main change: using atmos_component for source provisioner workdir paths, which is the core fix implemented across multiple files.
Linked Issues check ✅ Passed The PR directly addresses issue #2134 by making source provisioner and workdir provisioner use atmos_component consistently, ensuring both code paths resolve to the same directory regardless of metadata.component differences.
Out of Scope Changes check ✅ Passed All changes are scoped to the workdir path resolution logic: centralizing the BuildPath function, updating provisioner code to call it, and adding comprehensive tests. A single comment removal in workdir.go is part of cleanup.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch osterman/fix-jit-workdir-mismatch

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 and usage tips.

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.58%. Comparing base (3f3b552) to head (6b78683).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2137   +/-   ##
=======================================
  Coverage   76.57%   76.58%           
=======================================
  Files         832      832           
  Lines       79502    79507    +5     
=======================================
+ Hits        60879    60889   +10     
+ Misses      14824    14821    -3     
+ Partials     3799     3797    -2     
Flag Coverage Δ
unittests 76.58% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
pkg/provisioner/source/provision_hook.go 84.06% <100.00%> (-0.09%) ⬇️
pkg/provisioner/source/source.go 93.07% <100.00%> (-0.06%) ⬇️
pkg/provisioner/workdir/types.go 100.00% <100.00%> (ø)
pkg/provisioner/workdir/workdir.go 97.25% <ø> (ø)

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aknysh aknysh merged commit 82c6e20 into main Mar 4, 2026
56 checks passed
@aknysh aknysh deleted the osterman/fix-jit-workdir-mismatch branch March 4, 2026 15:07
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

These changes were released in v1.208.1-test.0.

goruha added a commit that referenced this pull request Mar 9, 2026
…raform-plan

* osterman/native-ci-terraform: (28 commits)
  feat: Add source cache TTL for JIT-vendored components (#2138)
  feat: Per-target version overrides in vendor manifests (#2141)
  docs: Add PRD for browser-based auth in aws/user identity (#1887)
  docs: Add EKS kubeconfig authentication integration PRD (#1884)
  fix: correct marketplace.json schema and update docs with install/uninstall commands (#2142)
  fix: propagate auth to all YAML functions in multi-component execution (#2140)
  fix: Use atmos_component for source provisioner workdir paths (#2137)
  Fix identity prompts to respect --interactive flag (#2130)
  Increase PR size thresholds to accommodate AI-assisted development (#2136)
  docs: Add Azure authentication provider documentation (#2132)
  fix: propagate component-type level dependencies through stack processor (#2127)
  fix: Add retry and missing workflow step properties to all schema copies (#2113)
  Exclude unsupported windows/arm from goreleaser build matrix (#2133)
  Add AI Agent Skills for LLM-Powered Infrastructure Development (#2121)
  Fix: Convert toolchain paths to absolute in PATH to resolve exec.LookPath failures (#2095)
  Fix workdir collision for component instances sharing base component (#2093)
  fix(auth): propagate TTY state to subprocesses for SSO device flow in workflows (#2126)
  fix(security): prevent SSRF in GitHub OIDC token URL handling (CWE-918) (#2106)
  Fix #2112: add workflow_retry definition and retry property to workflow step schema (#2114)
  fix(auth): auto-detect GitHub Actions WIF with proper audience, host validation, and lazy GSM init (#2109)
  ...
@github-actions
Copy link

github-actions bot commented Mar 9, 2026

These changes were released in v1.208.1-test.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/m Medium size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT vendoring (source pull) writes to a different workdir than terraform plan/init when metadata.component differs from the component instance name

2 participants