Skip to content

Commit d270fe7

Browse files
committed
feat: copy labels from Disk to Snapshot
It can be very useful to be able to track your snapshots using the same labels are you have on your original disks, this PR copies over all of the labels of the disk and adds a new permission requirement of `compute.snapshots.setLabels` to allow for that.
1 parent 07c222c commit d270fe7

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ These permissions are required by Velero to manage snapshot resources in the GCP
117117
compute.snapshots.create
118118
compute.snapshots.useReadOnly
119119
compute.snapshots.delete
120+
compute.snapshots.setLabels
120121
compute.zones.get
121122
storage.objects.create
122123
storage.objects.delete

velero-plugin-for-gcp/volume_snapshotter.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ func (b *VolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID, volumeType, vol
210210
SourceSnapshot: res.SelfLink,
211211
Type: volumeType,
212212
Description: res.Description,
213+
Labels: res.Labels,
213214
}
214215

215216
if isMultiZone(volumeAZ) {
@@ -318,6 +319,7 @@ func (b *VolumeSnapshotter) createSnapshot(snapshotName, volumeID, volumeAZ stri
318319
Description: getSnapshotTags(tags, disk.Description, b.log),
319320
SourceDisk: disk.SelfLink,
320321
SnapshotType: b.snapshotType,
322+
Labels: disk.Labels,
321323
}
322324

323325
if b.snapshotLocation != "" {
@@ -343,6 +345,7 @@ func (b *VolumeSnapshotter) createRegionSnapshot(snapshotName, volumeID, volumeR
343345
Description: getSnapshotTags(tags, disk.Description, b.log),
344346
SourceDisk: disk.SelfLink,
345347
SnapshotType: b.snapshotType,
348+
Labels: disk.Labels,
346349
}
347350

348351
if b.snapshotLocation != "" {

0 commit comments

Comments
 (0)