@@ -423,18 +423,10 @@ func (ctrl *csiSnapshotCommonController) syncUnreadySnapshot(snapshot *crdv1.Vol
423423		}
424424
425425		// update snapshot status 
426- 		for  i  :=  0 ; i  <  ctrl .createSnapshotContentRetryCount ; i ++  {
427- 			klog .V (5 ).Infof ("syncUnreadySnapshot [%s]: trying to update snapshot status" , utils .SnapshotKey (snapshot ))
428- 			_ , err  =  ctrl .updateSnapshotStatus (snapshot , newContent )
429- 			if  err  ==  nil  {
430- 				break 
431- 			}
432- 			klog .V (4 ).Infof ("failed to update snapshot %s status: %v" , utils .SnapshotKey (snapshot ), err )
433- 			time .Sleep (ctrl .createSnapshotContentInterval )
434- 		}
435- 
436- 		if  err  !=  nil  {
426+ 		klog .V (5 ).Infof ("syncUnreadySnapshot [%s]: trying to update snapshot status" , utils .SnapshotKey (snapshot ))
427+ 		if  _ , err  =  ctrl .updateSnapshotStatus (snapshot , newContent ); err  !=  nil  {
437428			// update snapshot status failed 
429+ 			klog .V (4 ).Infof ("failed to update snapshot %s status: %v" , utils .SnapshotKey (snapshot ), err )
438430			ctrl .updateSnapshotErrorStatusWithEvent (snapshot , v1 .EventTypeWarning , "SnapshotStatusUpdateFailed" , fmt .Sprintf ("Snapshot status update failed, %v" , err ))
439431			return  err 
440432		}
@@ -474,17 +466,8 @@ func (ctrl *csiSnapshotCommonController) syncUnreadySnapshot(snapshot *crdv1.Vol
474466		}
475467
476468		// Update snapshot status with BoundVolumeSnapshotContentName 
477- 		for  i  :=  0 ; i  <  ctrl .createSnapshotContentRetryCount ; i ++  {
478- 			klog .V (5 ).Infof ("syncUnreadySnapshot [%s]: trying to update snapshot status" , utils .SnapshotKey (snapshot ))
479- 			_ , err  =  ctrl .updateSnapshotStatus (snapshot , content )
480- 			if  err  ==  nil  {
481- 				break 
482- 			}
483- 			klog .V (4 ).Infof ("failed to update snapshot %s status: %v" , utils .SnapshotKey (snapshot ), err )
484- 			time .Sleep (ctrl .createSnapshotContentInterval )
485- 		}
486- 
487- 		if  err  !=  nil  {
469+ 		klog .V (5 ).Infof ("syncUnreadySnapshot [%s]: trying to update snapshot status" , utils .SnapshotKey (snapshot ))
470+ 		if  _ , err  =  ctrl .updateSnapshotStatus (snapshot , content ); err  !=  nil  {
488471			// update snapshot status failed 
489472			ctrl .updateSnapshotErrorStatusWithEvent (snapshot , v1 .EventTypeWarning , "SnapshotStatusUpdateFailed" , fmt .Sprintf ("Snapshot status update failed, %v" , err ))
490473			return  err 
@@ -656,24 +639,18 @@ func (ctrl *csiSnapshotCommonController) createSnapshotContent(snapshot *crdv1.V
656639	}
657640
658641	var  updateContent  * crdv1.VolumeSnapshotContent 
659- 	klog .V (3 ).Infof ("volume snapshot content %#v" , snapshotContent )
660- 	// Try to create the VolumeSnapshotContent object several times 
661- 	for  i  :=  0 ; i  <  ctrl .createSnapshotContentRetryCount ; i ++  {
662- 		klog .V (5 ).Infof ("createSnapshotContent [%s]: trying to save volume snapshot content %s" , utils .SnapshotKey (snapshot ), snapshotContent .Name )
663- 		if  updateContent , err  =  ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshotContents ().Create (context .TODO (), snapshotContent , metav1.CreateOptions {}); err  ==  nil  ||  apierrs .IsAlreadyExists (err ) {
664- 			// Save succeeded. 
665- 			if  err  !=  nil  {
666- 				klog .V (3 ).Infof ("volume snapshot content %q for snapshot %q already exists, reusing" , snapshotContent .Name , utils .SnapshotKey (snapshot ))
667- 				err  =  nil 
668- 				updateContent  =  snapshotContent 
669- 			} else  {
670- 				klog .V (3 ).Infof ("volume snapshot content %q for snapshot %q saved, %v" , snapshotContent .Name , utils .SnapshotKey (snapshot ), snapshotContent )
671- 			}
672- 			break 
642+ 	klog .V (5 ).Infof ("volume snapshot content %#v" , snapshotContent )
643+ 	// Try to create the VolumeSnapshotContent object 
644+ 	klog .V (5 ).Infof ("createSnapshotContent [%s]: trying to save volume snapshot content %s" , utils .SnapshotKey (snapshot ), snapshotContent .Name )
645+ 	if  updateContent , err  =  ctrl .clientset .SnapshotV1beta1 ().VolumeSnapshotContents ().Create (context .TODO (), snapshotContent , metav1.CreateOptions {}); err  ==  nil  ||  apierrs .IsAlreadyExists (err ) {
646+ 		// Save succeeded. 
647+ 		if  err  !=  nil  {
648+ 			klog .V (3 ).Infof ("volume snapshot content %q for snapshot %q already exists, reusing" , snapshotContent .Name , utils .SnapshotKey (snapshot ))
649+ 			err  =  nil 
650+ 			updateContent  =  snapshotContent 
651+ 		} else  {
652+ 			klog .V (3 ).Infof ("volume snapshot content %q for snapshot %q saved, %v" , snapshotContent .Name , utils .SnapshotKey (snapshot ), snapshotContent )
673653		}
674- 		// Save failed, try again after a while. 
675- 		klog .V (3 ).Infof ("failed to save volume snapshot content %q for snapshot %q: %v" , snapshotContent .Name , utils .SnapshotKey (snapshot ), err )
676- 		time .Sleep (ctrl .createSnapshotContentInterval )
677654	}
678655
679656	if  err  !=  nil  {
@@ -982,19 +959,14 @@ func (ctrl *csiSnapshotCommonController) bindandUpdateVolumeSnapshot(snapshotCon
982959	snapshotCopy  :=  snapshotObj .DeepCopy ()
983960	// update snapshot status 
984961	var  updateSnapshot  * crdv1.VolumeSnapshot 
985- 	for  i  :=  0 ; i  <  ctrl .createSnapshotContentRetryCount ; i ++  {
986- 		klog .V (5 ).Infof ("bindandUpdateVolumeSnapshot [%s]: trying to update snapshot status" , utils .SnapshotKey (snapshotCopy ))
987- 		updateSnapshot , err  =  ctrl .updateSnapshotStatus (snapshotCopy , snapshotContent )
988- 		if  err  ==  nil  {
989- 			snapshotCopy  =  updateSnapshot 
990- 			break 
991- 		}
992- 		klog .V (4 ).Infof ("failed to update snapshot %s status: %v" , utils .SnapshotKey (snapshot ), err )
993- 		time .Sleep (ctrl .createSnapshotContentInterval )
962+ 	klog .V (5 ).Infof ("bindandUpdateVolumeSnapshot [%s]: trying to update snapshot status" , utils .SnapshotKey (snapshotCopy ))
963+ 	updateSnapshot , err  =  ctrl .updateSnapshotStatus (snapshotCopy , snapshotContent )
964+ 	if  err  ==  nil  {
965+ 		snapshotCopy  =  updateSnapshot 
994966	}
995- 
996967	if  err  !=  nil  {
997968		// update snapshot status failed 
969+ 		klog .V (4 ).Infof ("failed to update snapshot %s status: %v" , utils .SnapshotKey (snapshot ), err )
998970		ctrl .updateSnapshotErrorStatusWithEvent (snapshotCopy , v1 .EventTypeWarning , "SnapshotStatusUpdateFailed" , fmt .Sprintf ("Snapshot status update failed, %v" , err ))
999971		return  nil , err 
1000972	}
0 commit comments