Skip to content

Commit d273061

Browse files
committed
Use LocalObjectReference instead of ObjectReference in VolumeSnapshot
Instead of using a field with the resource name, this patch uses LocalObjectReference in VolumeSnapshot too. This is being done for simmetry with VolumeGroupSnapshotContent. Signed-off-by: Leonardo Cecchi <[email protected]>
1 parent 05d7861 commit d273061

File tree

7 files changed

+42
-22
lines changed

7 files changed

+42
-22
lines changed

client/apis/volumegroupsnapshot/v1alpha1/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,11 @@ type VolumeGroupSnapshotContentStatus struct {
356356
// PVVolumeSnapshotContentPair represent a pair of PV names and
357357
// VolumeSnapshotContent names
358358
type PVVolumeSnapshotContentPair struct {
359-
// PersistentVolumeName is the name of the persistent volume
360-
PersistentVolumeName string `json:"persistentVolumeName,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeName"`
359+
// PersistentVolumeRef is a reference to the persistent volume resource
360+
PersistentVolumeRef core_v1.LocalObjectReference `json:"persistentVolumeRef,omitempty" protobuf:"bytes,1,opt,name=persistentVolumeRef"`
361361

362-
// VolumeSnapshotContentName is the name of the volume snapshot content resource
363-
VolumeSnapshotContentName string `json:"volumeSnapshotContentName,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotContentName"`
362+
// VolumeSnapshotContentRef is a reference to the volume snapshot content resource
363+
VolumeSnapshotContentRef core_v1.LocalObjectReference `json:"volumeSnapshotContentRef,omitempty" protobuf:"bytes,2,opt,name=volumeSnapshotContentRef"`
364364
}
365365

366366
// VolumeGroupSnapshotContentSource represents the CSI source of a group snapshot.

client/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,26 @@ spec:
235235
description: PVVolumeSnapshotContentPair represent a pair of PV
236236
names and VolumeSnapshotContent names
237237
properties:
238-
persistentVolumeName:
239-
description: PersistentVolumeName is the name of the persistent
240-
volume
241-
type: string
242-
volumeSnapshotContentName:
243-
description: VolumeSnapshotContentName is the name of the volume
244-
snapshot content resource
245-
type: string
238+
persistentVolumeRef:
239+
description: PersistentVolumeRef is a reference to the persistent
240+
volume resource
241+
properties:
242+
name:
243+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
244+
TODO: Add other useful fields. apiVersion, kind, uid?'
245+
type: string
246+
type: object
247+
x-kubernetes-map-type: atomic
248+
volumeSnapshotContentRef:
249+
description: VolumeSnapshotContentRef is a reference to the
250+
volume snapshot content resource
251+
properties:
252+
name:
253+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
254+
TODO: Add other useful fields. apiVersion, kind, uid?'
255+
type: string
256+
type: object
257+
x-kubernetes-map-type: atomic
246258
type: object
247259
type: array
248260
readyToUse:

pkg/common-controller/groupsnapshot_controller_helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,9 @@ func (ctrl *csiSnapshotCommonController) updateGroupSnapshotStatus(groupSnapshot
567567
var pvcVolumeSnapshotRefList []crdv1alpha1.PVCVolumeSnapshotPair
568568
if groupSnapshotContent.Status != nil && len(groupSnapshotContent.Status.PVVolumeSnapshotContentList) != 0 {
569569
for _, contentRef := range groupSnapshotContent.Status.PVVolumeSnapshotContentList {
570-
groupSnapshotContent, err := ctrl.contentLister.Get(contentRef.VolumeSnapshotContentName)
570+
groupSnapshotContent, err := ctrl.contentLister.Get(contentRef.VolumeSnapshotContentRef.Name)
571571
if err != nil {
572-
return nil, fmt.Errorf("failed to get group snapshot content %s from group snapshot content store: %v", contentRef.VolumeSnapshotContentName, err)
572+
return nil, fmt.Errorf("failed to get group snapshot content %s from group snapshot content store: %v", contentRef.VolumeSnapshotContentRef.Name, err)
573573
}
574574
pvcVolumeSnapshotRefList = append(pvcVolumeSnapshotRefList, crdv1alpha1.PVCVolumeSnapshotPair{
575575
VolumeSnapshotRef: v1.LocalObjectReference{

pkg/sidecar-controller/groupsnapshot_helper.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ func (ctrl *csiSnapshotSideCarController) deleteCSIGroupSnapshotOperation(groupS
242242
var snapshotIDs []string
243243
if groupSnapshotContent.Status != nil && len(groupSnapshotContent.Status.PVVolumeSnapshotContentList) != 0 {
244244
for _, contentRef := range groupSnapshotContent.Status.PVVolumeSnapshotContentList {
245-
snapshotContent, err := ctrl.contentLister.Get(contentRef.VolumeSnapshotContentName)
245+
snapshotContent, err := ctrl.contentLister.Get(contentRef.VolumeSnapshotContentRef.Name)
246246
if err != nil {
247-
return fmt.Errorf("failed to get snapshot content %s from snapshot content store: %v", contentRef.VolumeSnapshotContentName, err)
247+
return fmt.Errorf("failed to get snapshot content %s from snapshot content store: %v", contentRef.VolumeSnapshotContentRef.Name, err)
248248
}
249249
snapshotIDs = append(snapshotIDs, *snapshotContent.Status.SnapshotHandle)
250250
}
@@ -651,7 +651,9 @@ func (ctrl *csiSnapshotSideCarController) updateGroupSnapshotContentStatus(
651651
}
652652
for _, name := range snapshotContentNames {
653653
newStatus.PVVolumeSnapshotContentList = append(newStatus.PVVolumeSnapshotContentList, crdv1alpha1.PVVolumeSnapshotContentPair{
654-
VolumeSnapshotContentName: name,
654+
VolumeSnapshotContentRef: v1.LocalObjectReference{
655+
Name: name,
656+
},
655657
})
656658
}
657659
updated = true
@@ -675,7 +677,9 @@ func (ctrl *csiSnapshotSideCarController) updateGroupSnapshotContentStatus(
675677
if len(newStatus.PVVolumeSnapshotContentList) == 0 {
676678
for _, name := range snapshotContentNames {
677679
newStatus.PVVolumeSnapshotContentList = append(newStatus.PVVolumeSnapshotContentList, crdv1alpha1.PVVolumeSnapshotContentPair{
678-
VolumeSnapshotContentName: name,
680+
VolumeSnapshotContentRef: v1.LocalObjectReference{
681+
Name: name,
682+
},
679683
})
680684
}
681685
updated = true

vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumegroupsnapshot/v1alpha1/types.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/kubernetes-csi/external-snapshotter/client/v7/apis/volumegroupsnapshot/v1alpha1/zz_generated.deepcopy.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)