From f1d3b96728451efb17a7a7535a10bcdee79477f1 Mon Sep 17 00:00:00 2001 From: JenTing Hsiao Date: Fri, 21 Oct 2022 15:51:22 +0800 Subject: [PATCH 1/2] Support add the snapshot labels to images Signed-off-by: JenTing Hsiao --- pkg/gce-cloud-provider/compute/fake-gce.go | 1 + pkg/gce-cloud-provider/compute/gce-compute.go | 1 + 2 files changed, 2 insertions(+) diff --git a/pkg/gce-cloud-provider/compute/fake-gce.go b/pkg/gce-cloud-provider/compute/fake-gce.go index 42e4d41da..0f51640e1 100644 --- a/pkg/gce-cloud-provider/compute/fake-gce.go +++ b/pkg/gce-cloud-provider/compute/fake-gce.go @@ -424,6 +424,7 @@ func (cloud *FakeCloudProvider) CreateImage(ctx context.Context, project string, SourceType: "RAW", Status: "PENDING", StorageLocations: snapshotParams.StorageLocations, + Labels: snapshotParams.Labels, } switch volKey.Type() { diff --git a/pkg/gce-cloud-provider/compute/gce-compute.go b/pkg/gce-cloud-provider/compute/gce-compute.go index 1c14e6001..8f2512806 100644 --- a/pkg/gce-cloud-provider/compute/gce-compute.go +++ b/pkg/gce-cloud-provider/compute/gce-compute.go @@ -924,6 +924,7 @@ func (cloud *CloudProvider) CreateImage(ctx context.Context, project string, vol Name: imageName, StorageLocations: snapshotParams.StorageLocations, Description: description, + Labels: snapshotParams.Labels, } _, err = cloud.service.Images.Insert(project, image).Context(ctx).ForceCreate(true).Do() From caa7f4d80bd49121ac32ad626117b8171301095e Mon Sep 17 00:00:00 2001 From: JenTing Hsiao Date: Thu, 3 Nov 2022 11:12:12 +0800 Subject: [PATCH 2/2] e2e: add labels to VolumeSnapshotClass Signed-off-by: JenTing Hsiao --- test/k8s-integration/config/image-volumesnapshotclass.yaml | 2 ++ test/k8s-integration/config/pd-volumesnapshotclass.yaml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/test/k8s-integration/config/image-volumesnapshotclass.yaml b/test/k8s-integration/config/image-volumesnapshotclass.yaml index ee62f2150..fe704885f 100644 --- a/test/k8s-integration/config/image-volumesnapshotclass.yaml +++ b/test/k8s-integration/config/image-volumesnapshotclass.yaml @@ -7,3 +7,5 @@ deletionPolicy: Delete parameters: snapshot-type: images image-family: integration-test + # Add labels for testing. + labels: key1=value1,key2=value2 diff --git a/test/k8s-integration/config/pd-volumesnapshotclass.yaml b/test/k8s-integration/config/pd-volumesnapshotclass.yaml index bff9c3cde..427d4ebca 100644 --- a/test/k8s-integration/config/pd-volumesnapshotclass.yaml +++ b/test/k8s-integration/config/pd-volumesnapshotclass.yaml @@ -4,3 +4,6 @@ metadata: name: csi-gce-pd-snapshot-class driver: pd.csi.storage.gke.io deletionPolicy: Delete +parameters: + # Add labels for testing. + labels: key1=value1,key2=value2