Skip to content

Commit 67c2800

Browse files
authored
[content-service] remove s5cmd integration (#18863)
* [ws-daemon] log download and extract times * Revert "[content-service] log duration for s3 download and tar extract (#18829)" This reverts commit ac8d3e2. * Revert "[content-service] download s3 content using s5cmd (#18783)" This reverts commit 4fb2677.
1 parent cf4f468 commit 67c2800

File tree

3 files changed

+23
-37
lines changed

3 files changed

+23
-37
lines changed

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

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import (
99
"errors"
1010
"fmt"
1111
"os"
12-
"os/exec"
1312
"path/filepath"
1413
"strings"
15-
"time"
1614

1715
"github.com/gitpod-io/gitpod/common-go/log"
1816
"github.com/gitpod-io/gitpod/content-service/pkg/archive"
@@ -291,48 +289,36 @@ func (s3st *s3Storage) DownloadSnapshot(ctx context.Context, destination string,
291289
return s3st.download(ctx, destination, name, mappings)
292290
}
293291

294-
// download object using s5cmd (prior to which we used aws sdk)
295292
func (s3st *s3Storage) download(ctx context.Context, destination string, obj string, mappings []archive.IDMapping) (found bool, err error) {
296-
tempFile, err := os.CreateTemp("", "temporal-s3-file")
293+
downloader := s3manager.NewDownloader(s3st.client, func(d *s3manager.Downloader) {
294+
d.Concurrency = defaultCopyConcurrency
295+
d.PartSize = defaultPartSize * megabytes
296+
d.BufferProvider = s3manager.NewPooledBufferedWriterReadFromProvider(25 * megabytes)
297+
})
298+
299+
s3File, err := os.CreateTemp("", "temporal-s3-file")
297300
if err != nil {
298301
return true, xerrors.Errorf("creating temporal file: %s", err.Error())
299302
}
300-
tempFile.Close()
301-
302-
args := []string{
303-
"cp",
304-
// # of file parts to download at once
305-
"--concurrency", "20",
306-
// size in MB of each part
307-
"--part-size", "25",
308-
destination,
309-
tempFile.Name(),
310-
}
311-
cmd := exec.Command("s5cmd", args...)
312-
downloadStart := time.Now()
313-
out, err := cmd.CombinedOutput()
303+
defer os.Remove(s3File.Name())
304+
305+
_, err = downloader.Download(ctx, s3File, &s3.GetObjectInput{
306+
Bucket: aws.String(s3st.Config.Bucket),
307+
Key: aws.String(obj),
308+
})
314309
if err != nil {
315-
log.WithError(err).WithField("out", string(out)).Error("unexpected error downloading file")
316-
return false, xerrors.Errorf("unexpected error downloading file")
310+
return false, err
317311
}
318-
downloadDuration := time.Since(downloadStart)
319-
log.WithField("downloadDuration", downloadDuration.String()).Info("S3 download duration")
320312

321-
tempFile, err = os.Open(tempFile.Name())
313+
_, err = s3File.Seek(0, 0)
322314
if err != nil {
323-
return true, xerrors.Errorf("unexpected error opening downloaded file")
315+
return false, err
324316
}
325317

326-
defer os.Remove(tempFile.Name())
327-
defer tempFile.Close()
328-
329-
extractStart := time.Now()
330-
err = archive.ExtractTarbal(ctx, tempFile, destination, archive.WithUIDMapping(mappings), archive.WithGIDMapping(mappings))
318+
err = archive.ExtractTarbal(ctx, s3File, destination, archive.WithUIDMapping(mappings), archive.WithGIDMapping(mappings))
331319
if err != nil {
332320
return true, xerrors.Errorf("tar %s: %s", destination, err.Error())
333321
}
334-
extractDuration := time.Since(extractStart)
335-
log.WithField("extractdDuration", extractDuration.String()).Info("tarbar extraction duration")
336322

337323
return true, nil
338324
}

components/ws-daemon/leeway.Dockerfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ RUN apk add --no-cache curl file \
99
&& chmod +x runc.amd64 \
1010
&& if ! file runc.amd64 | grep -iq "ELF 64-bit LSB pie executable"; then echo "runc.amd64 is not a binary file"; exit 1;fi
1111

12-
RUN curl -OsSL https://github.com/peak/s5cmd/releases/download/v2.2.2/s5cmd_2.2.2_Linux-64bit.tar.gz \
13-
&& tar -xzvf s5cmd_2.2.2_Linux-64bit.tar.gz s5cmd \
14-
&& chmod +x s5cmd \
15-
&& if ! file s5cmd | grep -iq "ELF 64-bit LSB executable"; then echo "s5cmd is not a binary file"; exit 1;fi
16-
1712
FROM ubuntu:22.04
1813

1914
# trigger manual rebuild increasing the value
@@ -51,7 +46,6 @@ RUN apt update \
5146
/var/tmp/*
5247

5348
COPY --from=dl /dl/runc.amd64 /usr/bin/runc
54-
COPY --from=dl /dl/s5cmd /usr/bin/s5cmd
5549

5650
# Add gitpod user for operations (e.g. checkout because of the post-checkout hook!)
5751
RUN groupadd -r -g 33333 gitpod \

components/ws-daemon/pkg/content/initializer.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,15 @@ func (rs *remoteContentStorage) Download(ctx context.Context, destination string
406406
"-o", tempFile.Name(),
407407
}
408408

409+
downloadStart := time.Now()
409410
cmd := exec.Command("aria2c", args...)
410411
out, err := cmd.CombinedOutput()
411412
if err != nil {
412413
log.WithError(err).WithField("out", string(out)).Error("unexpected error downloading file")
413414
return true, xerrors.Errorf("unexpected error downloading file")
414415
}
416+
downloadDuration := time.Since(downloadStart)
417+
log.WithField("downloadDuration", downloadDuration.String()).Info("aria2c download duration")
415418

416419
tempFile, err = os.Open(tempFile.Name())
417420
if err != nil {
@@ -421,10 +424,13 @@ func (rs *remoteContentStorage) Download(ctx context.Context, destination string
421424
defer os.Remove(tempFile.Name())
422425
defer tempFile.Close()
423426

427+
extractStart := time.Now()
424428
err = archive.ExtractTarbal(ctx, tempFile, destination, archive.WithUIDMapping(mappings), archive.WithGIDMapping(mappings))
425429
if err != nil {
426430
return true, xerrors.Errorf("tar %s: %s", destination, err.Error())
427431
}
432+
extractDuration := time.Since(extractStart)
433+
log.WithField("extractDuration", extractDuration.String()).Info("extract tarbal duration")
428434

429435
return true, nil
430436
}

0 commit comments

Comments
 (0)