Address review comments
This commit is contained in:
@@ -247,23 +247,9 @@ func (ctrl *csiSnapshotController) getMatchSnapshotContent(snapshot *crdv1.Volum
|
||||
if content.Spec.VolumeSnapshotRef != nil &&
|
||||
content.Spec.VolumeSnapshotRef.Name == snapshot.Name &&
|
||||
content.Spec.VolumeSnapshotRef.Namespace == snapshot.Namespace &&
|
||||
content.Spec.VolumeSnapshotRef.UID == snapshot.UID {
|
||||
if content.Spec.VolumeSnapshotClassName != nil &&
|
||||
snapshot.Spec.VolumeSnapshotClassName != nil &&
|
||||
*(content.Spec.VolumeSnapshotClassName) != *(snapshot.Spec.VolumeSnapshotClassName) {
|
||||
glog.Errorf("volumeSnapshotClassName do not match. No VolumeSnapshotContent for VolumeSnapshot %s found", snapshotKey(snapshot))
|
||||
return nil
|
||||
}
|
||||
if content.Spec.VolumeSnapshotClassName != nil &&
|
||||
snapshot.Spec.VolumeSnapshotClassName == nil {
|
||||
glog.Errorf("volumeSnapshot does not have VolumeSnapshotClassName. No VolumeSnapshotContent for VolumeSnapshot %s found", snapshotKey(snapshot))
|
||||
return nil
|
||||
}
|
||||
if content.Spec.VolumeSnapshotClassName == nil &&
|
||||
snapshot.Spec.VolumeSnapshotClassName != nil {
|
||||
glog.Errorf("volumeSnapshotContent does not have VolumeSnapshotClassName. No VolumeSnapshotContent for VolumeSnapshot %s found", snapshotKey(snapshot))
|
||||
return nil
|
||||
}
|
||||
content.Spec.VolumeSnapshotRef.UID == snapshot.UID &&
|
||||
content.Spec.VolumeSnapshotClassName != nil && snapshot.Spec.VolumeSnapshotClassName != nil &&
|
||||
*(content.Spec.VolumeSnapshotClassName) == *(snapshot.Spec.VolumeSnapshotClassName) {
|
||||
found = true
|
||||
snapshotContentObj = content
|
||||
break
|
||||
@@ -596,7 +582,7 @@ func (ctrl *csiSnapshotController) deleteSnapshotContentOperation(content *crdv1
|
||||
var snapshotterCredentials map[string]string
|
||||
snapshotClassName := content.Spec.VolumeSnapshotClassName
|
||||
if snapshotClassName != nil {
|
||||
if snapshotClass, err := ctrl.clientset.VolumesnapshotV1alpha1().VolumeSnapshotClasses().Get(*snapshotClassName, metav1.GetOptions{}); err == nil {
|
||||
if snapshotClass, err := ctrl.classLister.Get(*snapshotClassName); err == nil {
|
||||
// Resolve snapshotting secret credentials.
|
||||
// No VolumeSnapshot is provided when resolving delete secret names, since the VolumeSnapshot may or may not exist at delete time.
|
||||
snapshotterSecretRef, err := GetSecretReference(snapshotClass.Parameters, content.Name, nil)
|
||||
@@ -766,7 +752,7 @@ func (ctrl *csiSnapshotController) GetSnapshotClass(className string) (*crdv1.Vo
|
||||
return class, nil
|
||||
}
|
||||
}
|
||||
class, err := ctrl.clientset.VolumesnapshotV1alpha1().VolumeSnapshotClasses().Get(className, metav1.GetOptions{})
|
||||
class, err := ctrl.classLister.Get(className)
|
||||
if err != nil {
|
||||
glog.Errorf("failed to retrieve snapshot class %s from the API server: %q", className, err)
|
||||
return nil, fmt.Errorf("failed to retrieve snapshot class %s from the API server: %q", className, err)
|
||||
@@ -795,7 +781,7 @@ func (ctrl *csiSnapshotController) SetDefaultSnapshotClass(snapshot *crdv1.Volum
|
||||
defaultClasses := []*crdv1.VolumeSnapshotClass{}
|
||||
|
||||
for _, class := range list {
|
||||
if IsDefaultAnnotation(class.ObjectMeta) && storageclass.Provisioner == class.Snapshotter {
|
||||
if IsDefaultAnnotation(class.ObjectMeta) && storageclass.Provisioner == class.Snapshotter && ctrl.snapshotterName == class.Snapshotter {
|
||||
defaultClasses = append(defaultClasses, class)
|
||||
glog.V(5).Infof("get defaultClass added: %s", class.Name)
|
||||
}
|
||||
|
Reference in New Issue
Block a user