Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use gsutil rsync instead of cp for buckets #737

Merged
merged 1 commit into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/apis/pipeline/v1alpha1/gcs_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (s *GCSResource) GetUploadContainerSpec() ([]corev1.Container, error) {
}
var args []string
if s.TypeDir {
args = []string{"-args", fmt.Sprintf("cp -r %s %s", filepath.Join(s.DestinationDir, "*"), s.Location)}
args = []string{"-args", fmt.Sprintf("rsync -d -r %s %s", s.DestinationDir, s.Location)}
} else {
args = []string{"-args", fmt.Sprintf("cp %s %s", filepath.Join(s.DestinationDir, "*"), s.Location)}
}
Expand All @@ -135,7 +135,7 @@ func (s *GCSResource) GetDownloadContainerSpec() ([]corev1.Container, error) {
}
var args []string
if s.TypeDir {
args = []string{"-args", fmt.Sprintf("cp -r %s %s", fmt.Sprintf("%s/*", s.Location), s.DestinationDir)}
args = []string{"-args", fmt.Sprintf("rsync -d -r %s %s", s.Location, s.DestinationDir)}
} else {
args = []string{"-args", fmt.Sprintf("cp %s %s", s.Location, s.DestinationDir)}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/pipeline/v1alpha1/gcs_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func Test_GetDownloadContainerSpec(t *testing.T) {
Name: "fetch-gcs-valid-mz4c7",
Image: "override-with-gsutil-image:latest",
Command: []string{"/ko-app/gsutil"},
Args: []string{"-args", "cp -r gs://some-bucket/* /workspace"},
Args: []string{"-args", "rsync -d -r gs://some-bucket /workspace"},
Env: []corev1.EnvVar{{
Name: "GOOGLE_APPLICATION_CREDENTIALS",
Value: "/var/secret/secretName/key.json",
Expand Down Expand Up @@ -329,7 +329,7 @@ func Test_GetUploadContainerSpec(t *testing.T) {
Name: "upload-gcs-valid-9l9zj",
Image: "override-with-gsutil-image:latest",
Command: []string{"/ko-app/gsutil"},
Args: []string{"-args", "cp -r /workspace/* gs://some-bucket"},
Args: []string{"-args", "rsync -d -r /workspace/ gs://some-bucket"},
Env: []corev1.EnvVar{{Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/secretName/key.json"}},
VolumeMounts: []corev1.VolumeMount{{
Name: "volume-gcs-valid-secretName",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ func TestStorageInputResource(t *testing.T) {
Name: "fetch-storage-gcs-keys-mz4c7",
Image: "override-with-gsutil-image:latest",
Command: []string{"/ko-app/gsutil"},
Args: []string{"-args", "cp -r gs://fake-bucket/rules.zip/* /workspace/gcs-input-resource"},
Args: []string{"-args", "rsync -d -r gs://fake-bucket/rules.zip /workspace/gcs-input-resource"},
VolumeMounts: []corev1.VolumeMount{
{Name: "volume-storage-gcs-keys-secret-name", MountPath: "/var/secret/secret-name"},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func TestValidOutputResources(t *testing.T) {
MountPath: "/var/secret/sname",
}},
Command: []string{"/ko-app/gsutil"},
Args: []string{"-args", "cp -r /workspace/faraway-disk/* gs://some-bucket"},
Args: []string{"-args", "rsync -d -r /workspace/faraway-disk gs://some-bucket"},
Env: []corev1.EnvVar{{
Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/sname/key.json",
}},
Expand Down Expand Up @@ -444,7 +444,7 @@ func TestValidOutputResources(t *testing.T) {
Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/sname/key.json",
}},
Command: []string{"/ko-app/gsutil"},
Args: []string{"-args", "cp -r /workspace/output/source-workspace/* gs://some-bucket"},
Args: []string{"-args", "rsync -d -r /workspace/output/source-workspace gs://some-bucket"},
}, {
Name: "source-mkdir-source-gcs-mz4c7",
Image: "override-with-bash-noop:latest",
Expand Down Expand Up @@ -508,7 +508,7 @@ func TestValidOutputResources(t *testing.T) {
Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/sname/key.json",
}},
Command: []string{"/ko-app/gsutil"},
Args: []string{"-args", "cp -r /workspace/output/source-workspace/* gs://some-bucket"},
Args: []string{"-args", "rsync -d -r /workspace/output/source-workspace gs://some-bucket"},
}},
wantVolumes: []corev1.Volume{{
Name: "volume-source-gcs-sname",
Expand Down Expand Up @@ -559,7 +559,7 @@ func TestValidOutputResources(t *testing.T) {
Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/sname/key.json",
}},
Command: []string{"/ko-app/gsutil"},
Args: []string{"-args", "cp -r /workspace/output/source-workspace/* gs://some-bucket"},
Args: []string{"-args", "rsync -d -r /workspace/output/source-workspace gs://some-bucket"},
}},
wantVolumes: []corev1.Volume{{
Name: "volume-source-gcs-sname",
Expand Down