Skip to content

fix: reduce size of terraform modules archive #17749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 12, 2025
Prev Previous commit
windows:|
  • Loading branch information
aslilac committed May 12, 2025
commit c386885fbd1d1658e503105e5c87f30cc06183d6
6 changes: 5 additions & 1 deletion coderd/files/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ func (c *Cache) Acquire(ctx context.Context, fileID uuid.UUID) (fs.FS, error) {
// mutex has been released, or we would continue to hold the lock until the
// entire file has been fetched, which may be slow, and would prevent other
// files from being fetched in parallel.
return c.prepare(ctx, fileID).Load()
it, err := c.prepare(ctx, fileID).Load()
if err != nil {
c.Release(fileID)
}
return it, err
}

func (c *Cache) prepare(ctx context.Context, fileID uuid.UUID) *lazy.ValueWithError[fs.FS] {
Expand Down
2 changes: 1 addition & 1 deletion coderd/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ func (api *API) templateVersionDynamicParameters(rw http.ResponseWriter, r *http
}

fs, err := api.FileCache.Acquire(fileCtx, fileID)
defer api.FileCache.Release(fileID)
if err != nil {
httpapi.Write(ctx, rw, http.StatusNotFound, codersdk.Response{
Message: "Internal error fetching template version Terraform.",
Detail: err.Error(),
})
return
}
defer api.FileCache.Release(fileID)

// Having the Terraform plan available for the evaluation engine is helpful
// for populating values from data blocks, but isn't strictly required. If
Expand Down
2 changes: 1 addition & 1 deletion provisioner/terraform/modules_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestGetModulesArchive(t *testing.T) {
if runtime.GOOS != "windows" {
require.Equal(t, "05d2994c1a50ce573fe2c2b29507e5131ba004d15812d8bb0a46dc732f3211f5", hash)
} else {
require.Equal(t, "09a30ffc30138f9a411b280ef4581dcf22ffab8f0ca9de982329226400ec8520", hash)
require.Equal(t, "c219943913051e4637527cd03ae2b7303f6945005a262cdd420f9c2af490d572", hash)
}
})

Expand Down
Loading