Merge pull request #33 from xing-yang/update_snapshotclass

Update snapshot class in the content spec
This commit is contained in:
k8s-ci-robot
2018-09-24 14:08:16 -07:00
committed by GitHub

View File

@@ -401,21 +401,22 @@ func (ctrl *csiSnapshotController) checkandBindSnapshotContent(snapshot *crdv1.V
return fmt.Errorf("Could not bind snapshot %s and content %s, the VolumeSnapshotRef does not match", snapshot.Name, content.Name) return fmt.Errorf("Could not bind snapshot %s and content %s, the VolumeSnapshotRef does not match", snapshot.Name, content.Name)
} else if content.Spec.VolumeSnapshotRef.UID != "" && content.Spec.VolumeSnapshotRef.UID != snapshot.UID { } else if content.Spec.VolumeSnapshotRef.UID != "" && content.Spec.VolumeSnapshotRef.UID != snapshot.UID {
return fmt.Errorf("Could not bind snapshot %s and content %s, the VolumeSnapshotRef does not match", snapshot.Name, content.Name) return fmt.Errorf("Could not bind snapshot %s and content %s, the VolumeSnapshotRef does not match", snapshot.Name, content.Name)
} else if content.Spec.VolumeSnapshotRef.UID == "" { } else if content.Spec.VolumeSnapshotRef.UID != "" && content.Spec.VolumeSnapshotClassName != nil {
contentClone := content.DeepCopy() return nil
contentClone.Spec.VolumeSnapshotRef.UID = snapshot.UID }
className := *(snapshot.Spec.VolumeSnapshotClassName) contentClone := content.DeepCopy()
contentClone.Spec.VolumeSnapshotClassName = &className contentClone.Spec.VolumeSnapshotRef.UID = snapshot.UID
newContent, err := ctrl.clientset.VolumesnapshotV1alpha1().VolumeSnapshotContents().Update(contentClone) className := *(snapshot.Spec.VolumeSnapshotClassName)
if err != nil { contentClone.Spec.VolumeSnapshotClassName = &className
glog.V(4).Infof("updating VolumeSnapshotContent[%s] error status failed %v", newContent.Name, err) newContent, err := ctrl.clientset.VolumesnapshotV1alpha1().VolumeSnapshotContents().Update(contentClone)
return err if err != nil {
} glog.V(4).Infof("updating VolumeSnapshotContent[%s] error status failed %v", newContent.Name, err)
_, err = ctrl.storeContentUpdate(newContent) return err
if err != nil { }
glog.V(4).Infof("updating VolumeSnapshotContent[%s] error status: cannot update internal cache %v", newContent.Name, err) _, err = ctrl.storeContentUpdate(newContent)
return err if err != nil {
} glog.V(4).Infof("updating VolumeSnapshotContent[%s] error status: cannot update internal cache %v", newContent.Name, err)
return err
} }
return nil return nil
} }