mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-21 06:36:06 +00:00
Avoid io.ReadAll in buildFinalTarball() (#10311)
Run the E2E test on kind / setup-test-matrix (push) Successful in 3s
e2e-test-kind.yaml / extract (push) Failing after 10s
Run the E2E test on kind / get-go-version (push) Failing after 11s
Run the E2E test on kind / build (push) Skipped
Run the E2E test on kind / run-e2e-test (push) Skipped
push.yml / extract (push) Failing after 8s
Main CI / get-go-version (push) Failing after 9s
Main CI / Build (push) Skipped
Run the E2E test on kind / setup-test-matrix (push) Successful in 3s
e2e-test-kind.yaml / extract (push) Failing after 10s
Run the E2E test on kind / get-go-version (push) Failing after 11s
Run the E2E test on kind / build (push) Skipped
Run the E2E test on kind / run-e2e-test (push) Skipped
push.yml / extract (push) Failing after 8s
Main CI / get-go-version (push) Failing after 9s
Main CI / Build (push) Skipped
This commit updates the func buildFinalTarball so it won't use io.ReadAll, in order to optimize memory usage. Signed-off-by: Daniel Jiang <daniel.jiang@broadcom.com>
This commit is contained in:
+1
-10
@@ -1263,21 +1263,12 @@ func buildFinalTarball(tr *tar.Reader, tw tarWriter, updateFiles map[string]File
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
delete(updateFiles, header.Name)
|
||||
// skip over file contents from old tarball
|
||||
_, err := io.ReadAll(tr)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
} else {
|
||||
// Add original content to new tarball, as item wasn't updated
|
||||
oldContents, err := io.ReadAll(tr)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
if err := tw.WriteHeader(header); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
if _, err := tw.Write(oldContents); err != nil {
|
||||
if _, err := io.Copy(tw, tr); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user