Skip to content

Commit 153f203

Browse files
ammariopull[bot]
authored andcommitted
chore: improve terraform install performance (#7478)
1 parent 9c9248c commit 153f203

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

cli/server.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,11 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
243243
notifyCtx, notifyStop := signal.NotifyContext(ctx, InterruptSignals...)
244244
defer notifyStop()
245245

246-
// Ensure we have a unique cache directory for this process.
247-
cacheDir := filepath.Join(cfg.CacheDir.String(), uuid.NewString())
246+
cacheDir := cfg.CacheDir.String()
248247
err = os.MkdirAll(cacheDir, 0o700)
249248
if err != nil {
250249
return xerrors.Errorf("create cache directory: %w", err)
251250
}
252-
defer os.RemoveAll(cacheDir)
253251

254252
// Clean up idle connections at the end, e.g.
255253
// embedded-postgres can leave an idle connection

coderd/coderd.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"crypto/tls"
66
"crypto/x509"
77
"encoding/json"
8+
"flag"
89
"fmt"
910
"io"
1011
"net/http"
@@ -878,7 +879,12 @@ func (api *API) Close() error {
878879
}
879880

880881
func compressHandler(h http.Handler) http.Handler {
881-
cmp := middleware.NewCompressor(5,
882+
level := 5
883+
if flag.Lookup("test.v") != nil {
884+
level = 1
885+
}
886+
887+
cmp := middleware.NewCompressor(level,
882888
"text/*",
883889
"application/*",
884890
"image/*",

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2636,7 +2636,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.1.2/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZa
26362636
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
26372637
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
26382638
software.sslmate.com/src/go-pkcs12 v0.2.0 h1:nlFkj7bTysH6VkC4fGphtjXRbezREPgrHuJG20hBGPE=
2639-
storj.io/drpc v0.0.33-0.20220622181519-9206537a4db7 h1:6jIp39oQGZMjfrG3kiafK2tcL0Fbprh2kvaoJNfhvuM=
2640-
storj.io/drpc v0.0.33-0.20220622181519-9206537a4db7/go.mod h1:6rcOyR/QQkSTX/9L5ZGtlZaE2PtXTTZl8d+ulSeeYEg=
26412639
storj.io/drpc v0.0.33-0.20230420154621-9716137f6037 h1:SYRl2YUthhsXNkrP30KwxkDGN9TESdNrbpr14rOxsnM=
26422640
storj.io/drpc v0.0.33-0.20230420154621-9716137f6037/go.mod h1:vR804UNzhBa49NOJ6HeLjd2H3MakC1j5Gv8bsOQT6N4=

provisioner/terraform/install.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func Install(ctx context.Context, log slog.Logger, dir string, wantVersion *vers
6262
log.Debug(
6363
ctx,
6464
"installing terraform",
65+
slog.F("prev_version", hasVersion),
6566
slog.F("dir", dir),
6667
slog.F("version", TerraformVersion),
6768
)

0 commit comments

Comments
 (0)