Skip to content

Commit

Permalink
feat: copy labels from Disk to Snapshot
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
opdude committed Apr 11, 2024
1 parent 07c222c commit d270fe7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ These permissions are required by Velero to manage snapshot resources in the GCP
compute.snapshots.create
compute.snapshots.useReadOnly
compute.snapshots.delete
compute.snapshots.setLabels
compute.zones.get
storage.objects.create
storage.objects.delete
Expand Down
3 changes: 3 additions & 0 deletions velero-plugin-for-gcp/volume_snapshotter.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ func (b *VolumeSnapshotter) CreateVolumeFromSnapshot(snapshotID, volumeType, vol
SourceSnapshot: res.SelfLink,
Type: volumeType,
Description: res.Description,
Labels: res.Labels,
}

if isMultiZone(volumeAZ) {
Expand Down Expand Up @@ -318,6 +319,7 @@ func (b *VolumeSnapshotter) createSnapshot(snapshotName, volumeID, volumeAZ stri
Description: getSnapshotTags(tags, disk.Description, b.log),
SourceDisk: disk.SelfLink,
SnapshotType: b.snapshotType,
Labels: disk.Labels,
}

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

if b.snapshotLocation != "" {
Expand Down

0 comments on commit d270fe7

Please sign in to comment.