-
Notifications
You must be signed in to change notification settings - Fork 397
Closed as not planned
Closed as not planned
Copy link
Labels
lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Description
external-snapshotter/pkg/sidecar-controller/groupsnapshot_helper.go
Lines 433 to 497 in fa9de9c
for _, snapshot := range snapshots { | |
volumeSnapshotContentName := GetSnapshotContentNameForVolumeGroupSnapshotContent(string(groupSnapshotContent.UID), snapshot.SourceVolumeId) | |
volumeSnapshotName := GetSnapshotNameForVolumeGroupSnapshotContent(string(groupSnapshotContent.UID), snapshot.SourceVolumeId) | |
volumeSnapshotNamespace := groupSnapshotContent.Spec.VolumeGroupSnapshotRef.Namespace | |
volumeSnapshotContent := &crdv1.VolumeSnapshotContent{ | |
ObjectMeta: metav1.ObjectMeta{ | |
Name: volumeSnapshotContentName, | |
}, | |
Spec: crdv1.VolumeSnapshotContentSpec{ | |
VolumeSnapshotRef: v1.ObjectReference{ | |
Kind: "VolumeSnapshots", | |
Name: volumeSnapshotName, | |
Namespace: volumeSnapshotNamespace, | |
}, | |
DeletionPolicy: groupSnapshotContent.Spec.DeletionPolicy, | |
Driver: groupSnapshotContent.Spec.Driver, | |
Source: crdv1.VolumeSnapshotContentSource{ | |
SnapshotHandle: &snapshot.SnapshotId, | |
}, | |
// TODO: Populate this field when volume mode conversion is enabled by default | |
SourceVolumeMode: nil, | |
}, | |
Status: &crdv1.VolumeSnapshotContentStatus{ | |
VolumeGroupSnapshotHandle: &groupSnapshotContent.Name, | |
}, | |
} | |
if groupSnapshotSecret != nil { | |
klog.V(5).Infof("createGroupSnapshotContent: set annotation [%s] on volume snapshot content [%s].", utils.AnnDeletionSecretRefName, volumeSnapshotContent.Name) | |
metav1.SetMetaDataAnnotation(&volumeSnapshotContent.ObjectMeta, utils.AnnDeletionSecretRefName, groupSnapshotSecret.Name) | |
klog.V(5).Infof("createGroupSnapshotContent: set annotation [%s] on volume snapshot content [%s].", utils.AnnDeletionSecretRefNamespace, volumeSnapshotContent.Name) | |
metav1.SetMetaDataAnnotation(&volumeSnapshotContent.ObjectMeta, utils.AnnDeletionSecretRefNamespace, groupSnapshotSecret.Namespace) | |
} | |
label := make(map[string]string) | |
label["volumeGroupSnapshotName"] = groupSnapshotContent.Spec.VolumeGroupSnapshotRef.Name | |
volumeSnapshot := &crdv1.VolumeSnapshot{ | |
ObjectMeta: metav1.ObjectMeta{ | |
Name: volumeSnapshotName, | |
Namespace: volumeSnapshotNamespace, | |
Labels: label, | |
Finalizers: []string{utils.VolumeSnapshotInGroupFinalizer}, | |
}, | |
Spec: crdv1.VolumeSnapshotSpec{ | |
Source: crdv1.VolumeSnapshotSource{ | |
VolumeSnapshotContentName: &volumeSnapshotContentName, | |
}, | |
}, | |
} | |
vsc, err := ctrl.clientset.SnapshotV1().VolumeSnapshotContents().Create(context.TODO(), volumeSnapshotContent, metav1.CreateOptions{}) | |
if err != nil { | |
return groupSnapshotContent, err | |
} | |
snapshotContentNames = append(snapshotContentNames, vsc.Name) | |
_, err = ctrl.clientset.SnapshotV1().VolumeSnapshots(volumeSnapshotNamespace).Create(context.TODO(), volumeSnapshot, metav1.CreateOptions{}) | |
if err != nil { | |
return groupSnapshotContent, err | |
} | |
_, err = ctrl.updateSnapshotContentStatus(volumeSnapshotContent, snapshot.SnapshotId, snapshot.ReadyToUse, snapshot.CreationTime.AsTime().UnixNano(), snapshot.SizeBytes, groupSnapshotID) | |
if err != nil { | |
return groupSnapshotContent, err | |
} | |
} |
The above code seems to be buggy and i got around 200 volumesnapshots/volumesnapshotcontent created for a single volumegroupsnapshot with single PVC.
It works as below
- Create volumegroupsnapshot with csi driver
- Get the response and generate VS and VSC name based on the timestamp
- Create the volumesnapshotcontent
- Create the volumesnapshot
- Update volumesnapshotcontent
Repeat steps 3,4,5 for all the snapshots in the volumegroupsnapshot RPC response and at last update the volumegroupsnapshotcontent status with VSC names.
If there are any issues in 3,4,5 steps or if the csi-snapshotter is restarted we might end up having stale resources that need to be garbage collected.
Metadata
Metadata
Assignees
Labels
lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.Denotes an issue or PR that has aged beyond stale and will be auto-closed.