Skip to content

feat(executor): executor.cache block for provider + module caching (chart 4.8.0) - #293

Draft
TigranKhudav wants to merge 2 commits into
terrakube-io:mainfrom
TigranKhudav:feat/executor-cache
Draft

feat(executor): executor.cache block for provider + module caching (chart 4.8.0)#293
TigranKhudav wants to merge 2 commits into
terrakube-io:mainfrom
TigranKhudav:feat/executor-cache

Conversation

@TigranKhudav

Copy link
Copy Markdown

Summary

Adds an executor.cache block that sets up job-to-job caching for the executor in one place:

executor:
  cache:
    enabled: true
    path: /home/cnb/.terraform.d   # mount point of the cache volume
    sizeLimit: 2Gi                 # emptyDir size; or
    existingClaim: ""              #   an existing PVC (RWX when replicaCount > 1)
    providers: true                # TF_PLUGIN_CACHE_DIR=<path>/plugin-cache
    ignoreLockFile: false          # TF_PLUGIN_CACHE_MAY_BREAK_DEPENDENCY_LOCK_FILE=1
    modules: true                  # TerraformDataDirCacheRoot=<path>/data  (executor support: terrakube-io/terrakube#3478)

Today the Provider Cache docs tell users to add a volume, a mount and the env var by hand; it is easy to end up with the volume mounted and the variable missing (which is exactly what we found in our own deployment — the cache dir stayed empty). modules: true wires the new executor setting that also keeps the modules between jobs of the same workspace; older executor images simply ignore that variable.

Disabled by default: rendering is byte-for-byte unchanged for existing values files (helm template diff is empty). values.schema.json, the README values table and the chart version (4.8.0) are updated.

Test plan

  • helm lint
  • helm template with the default values → no cache env/volume rendered
  • --set executor.cache.enabled=true --set executor.cache.ignoreLockFile=true → emptyDir volume with sizeLimit, mount at /home/cnb/.terraform.d, the three env vars
  • --set executor.cache.existingClaim=tf-cache --set executor.cache.path=/cache/ --set executor.cache.providers=false → PVC volume, trailing slash trimmed, only TerraformDataDirCacheRoot set

🤖 Generated with Claude Code

Adds executor.cache.{enabled,path,sizeLimit,existingClaim,providers,
ignoreLockFile,modules}. When enabled the chart mounts one cache volume
(emptyDir with a size limit, or an existing PVC) at executor.cache.path
and sets, in one place, the variables that today have to be assembled
by hand from the docs:

  TF_PLUGIN_CACHE_DIR=<path>/plugin-cache
  TF_PLUGIN_CACHE_MAY_BREAK_DEPENDENCY_LOCK_FILE=1   (ignoreLockFile)
  TerraformDataDirCacheRoot=<path>/data              (modules; executor support required)

Disabled by default; rendering is unchanged for existing values files.
Bumps the chart to 4.8.0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ntainer

Terraform/OpenTofu do not create TF_PLUGIN_CACHE_DIR ("the directory must
already exist") and a freshly mounted volume is empty, so init reported
'The specified plugin cache dir ... cannot be opened'. When the cache is
enabled the chart now runs a tiny init container (the executor image
itself, same user) that creates <path>/plugin-cache and <path>/data.
User-supplied executor.initContainers are still rendered after it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@TigranKhudav

Copy link
Copy Markdown
Author

Follow-up commit: when executor.cache.enabled the chart now also renders an init container (executor image, same user) that creates <path>/plugin-cache and <path>/data. Terraform/OpenTofu do not create TF_PLUGIN_CACHE_DIR themselves and a fresh volume is empty, so without it every init reported The specified plugin cache dir ... cannot be opened — found while dogfooding the values on our cluster. User-supplied executor.initContainers are still rendered after it; nothing renders when the cache is disabled.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant