Skip to content

Commit ac8d3e2

Browse files
authored
[content-service] log duration for s3 download and tar extract (#18829)
* [content-service] log the duration for download and extraction for S3 The DirectDownloader interface does not differentiate between downloading and extract tarbal...when youdownload, you also extract. https://github.com/gitpod-io/gitpod/blob/9a38b607055780fa7b2cd61c1379143d6c7b3715/components/content-service/pkg/storage/storage.go#L133 In the context of a prebuild initializer: https://github.com/gitpod-io/gitpod/blob/9a38b607055780fa7b2cd61c1379143d6c7b3715/components/content-service/pkg/initializer/prebuild.go#L69 When we Run, we do DownloadSnapshot: https://github.com/gitpod-io/gitpod/blob/9a38b607055780fa7b2cd61c1379143d6c7b3715/components/content-service/pkg/initializer/snapshot.go#L48 It does both operations: https://github.com/gitpod-io/gitpod/blob/9a38b607055780fa7b2cd61c1379143d6c7b3715/components/content-service/pkg/storage/s3.go#L290 Supervisor, which records initializer metrics, reads them from /workspace/.gitpod/ready file: https://github.com/gitpod-io/gitpod/blob/55414729fab00fa23888c1868579425907518a68/components/supervisor/pkg/supervisor/supervisor.go#L1639 * [content-service] denote when download is found
1 parent ea6fd88 commit ac8d3e2

File tree

1 file changed

+8
-1
lines changed
  • components/content-service/pkg/storage

1 file changed

+8
-1
lines changed

components/content-service/pkg/storage/s3.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"os/exec"
1313
"path/filepath"
1414
"strings"
15+
"time"
1516

1617
"github.com/gitpod-io/gitpod/common-go/log"
1718
"github.com/gitpod-io/gitpod/content-service/pkg/archive"
@@ -308,11 +309,14 @@ func (s3st *s3Storage) download(ctx context.Context, destination string, obj str
308309
tempFile.Name(),
309310
}
310311
cmd := exec.Command("s5cmd", args...)
312+
downloadStart := time.Now()
311313
out, err := cmd.CombinedOutput()
312314
if err != nil {
313315
log.WithError(err).WithField("out", string(out)).Error("unexpected error downloading file")
314-
return true, xerrors.Errorf("unexpected error downloading file")
316+
return false, xerrors.Errorf("unexpected error downloading file")
315317
}
318+
downloadDuration := time.Since(downloadStart)
319+
log.WithField("downloadDuration", downloadDuration.String()).Info("S3 download duration")
316320

317321
tempFile, err = os.Open(tempFile.Name())
318322
if err != nil {
@@ -322,10 +326,13 @@ func (s3st *s3Storage) download(ctx context.Context, destination string, obj str
322326
defer os.Remove(tempFile.Name())
323327
defer tempFile.Close()
324328

329+
extractStart := time.Now()
325330
err = archive.ExtractTarbal(ctx, tempFile, destination, archive.WithUIDMapping(mappings), archive.WithGIDMapping(mappings))
326331
if err != nil {
327332
return true, xerrors.Errorf("tar %s: %s", destination, err.Error())
328333
}
334+
extractDuration := time.Since(extractStart)
335+
log.WithField("extractdDuration", extractDuration.String()).Info("tarbar extraction duration")
329336

330337
return true, nil
331338
}

0 commit comments

Comments
 (0)