Skip to content

Commit

Permalink
fix(cli): correctly use cache dir for provisionerd work dir (#7651)
Browse files Browse the repository at this point in the history
  • Loading branch information
coadler committed May 23, 2023
1 parent ba02dc8 commit c8ea76c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions cli/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,12 @@ func newProvisionerDaemon(
return nil, xerrors.Errorf("mkdir %q: %w", cacheDir, err)
}

tfDir := filepath.Join(cacheDir, "terraform")
err = os.MkdirAll(tfDir, 0o700)
if err != nil {
return nil, xerrors.Errorf("mkdir terraform dir: %w", err)
}

tracer := coderAPI.TracerProvider.Tracer(tracing.TracerName)
terraformClient, terraformServer := provisionersdk.MemTransportPipe()
wg.Add(1)
Expand All @@ -1201,7 +1207,7 @@ func newProvisionerDaemon(
ServeOptions: &provisionersdk.ServeOptions{
Listener: terraformServer,
},
CachePath: cacheDir,
CachePath: tfDir,
Logger: logger,
Tracer: tracer,
})
Expand All @@ -1213,9 +1219,10 @@ func newProvisionerDaemon(
}
}()

tempDir, err := os.MkdirTemp("", "provisionerd")
workDir := filepath.Join(cacheDir, "work")
err = os.MkdirAll(workDir, 0o700)
if err != nil {
return nil, err
return nil, xerrors.Errorf("mkdir work dir: %w", err)
}

provisioners := provisionerd.Provisioners{
Expand Down Expand Up @@ -1259,7 +1266,7 @@ func newProvisionerDaemon(
UpdateInterval: time.Second,
ForceCancelInterval: cfg.Provisioner.ForceCancelInterval.Value(),
Provisioners: provisioners,
WorkDirectory: tempDir,
WorkDirectory: workDir,
TracerProvider: coderAPI.TracerProvider,
Metrics: &metrics,
}), nil
Expand Down

0 comments on commit c8ea76c

Please sign in to comment.