@@ -563,15 +563,15 @@ func (ctrl *csiSnapshotController) getCreateSnapshotInput(snapshot *crdv1.Volume
563563
564564func (ctrl * csiSnapshotController ) checkandUpdateBoundSnapshotStatusOperation (snapshot * crdv1.VolumeSnapshot , content * crdv1.VolumeSnapshotContent ) (* crdv1.VolumeSnapshot , error ) {
565565 var err error
566- var timestamp int64
566+ var creationTime time. Time
567567 var size int64
568568 var readyToUse = false
569569 var driverName string
570570 var snapshotID string
571571
572572 if snapshot .Spec .Source == nil {
573573 klog .V (5 ).Infof ("checkandUpdateBoundSnapshotStatusOperation: checking whether snapshot [%s] is pre-bound to content [%s]" , snapshot .Name , content .Name )
574- readyToUse , timestamp , size , err = ctrl .handler .GetSnapshotStatus (content )
574+ readyToUse , creationTime , size , err = ctrl .handler .GetSnapshotStatus (content )
575575 if err != nil {
576576 klog .Errorf ("checkandUpdateBoundSnapshotStatusOperation: failed to call get snapshot status to check whether snapshot is ready to use %q" , err )
577577 return nil , err
@@ -584,18 +584,18 @@ func (ctrl *csiSnapshotController) checkandUpdateBoundSnapshotStatusOperation(sn
584584 if err != nil {
585585 return nil , fmt .Errorf ("failed to get input parameters to create snapshot %s: %q" , snapshot .Name , err )
586586 }
587- driverName , snapshotID , timestamp , size , readyToUse , err = ctrl .handler .CreateSnapshot (snapshot , volume , class .Parameters , snapshotterCredentials )
587+ driverName , snapshotID , creationTime , size , readyToUse , err = ctrl .handler .CreateSnapshot (snapshot , volume , class .Parameters , snapshotterCredentials )
588588 if err != nil {
589589 klog .Errorf ("checkandUpdateBoundSnapshotStatusOperation: failed to call create snapshot to check whether the snapshot is ready to use %q" , err )
590590 return nil , err
591591 }
592592 }
593- klog .V (5 ).Infof ("checkandUpdateBoundSnapshotStatusOperation: driver %s, snapshotId %s, timestamp %d , size %d, readyToUse %t" , driverName , snapshotID , timestamp , size , readyToUse )
593+ klog .V (5 ).Infof ("checkandUpdateBoundSnapshotStatusOperation: driver %s, snapshotId %s, creationTime %v , size %d, readyToUse %t" , driverName , snapshotID , creationTime , size , readyToUse )
594594
595- if timestamp == 0 {
596- timestamp = time .Now (). UnixNano ()
595+ if creationTime . IsZero () {
596+ creationTime = time .Now ()
597597 }
598- newSnapshot , err := ctrl .updateSnapshotStatus (snapshot , readyToUse , timestamp , size , IsSnapshotBound (snapshot , content ))
598+ newSnapshot , err := ctrl .updateSnapshotStatus (snapshot , readyToUse , creationTime , size , IsSnapshotBound (snapshot , content ))
599599 if err != nil {
600600 return nil , err
601601 }
@@ -632,17 +632,18 @@ func (ctrl *csiSnapshotController) createSnapshotOperation(snapshot *crdv1.Volum
632632 return nil , fmt .Errorf ("failed to get input parameters to create snapshot %s: %q" , snapshot .Name , err )
633633 }
634634
635- driverName , snapshotID , timestamp , size , readyToUse , err := ctrl .handler .CreateSnapshot (snapshot , volume , class .Parameters , snapshotterCredentials )
635+ driverName , snapshotID , creationTime , size , readyToUse , err := ctrl .handler .CreateSnapshot (snapshot , volume , class .Parameters , snapshotterCredentials )
636636 if err != nil {
637637 return nil , fmt .Errorf ("failed to take snapshot of the volume, %s: %q" , volume .Name , err )
638638 }
639- klog .V (5 ).Infof ("Created snapshot: driver %s, snapshotId %s, timestamp %d, size %d, readyToUse %t" , driverName , snapshotID , timestamp , size , readyToUse )
639+
640+ klog .V (5 ).Infof ("Created snapshot: driver %s, snapshotId %s, creationTime %v, size %d, readyToUse %t" , driverName , snapshotID , creationTime , size , readyToUse )
640641
641642 var newSnapshot * crdv1.VolumeSnapshot
642- // Update snapshot status with timestamp
643+ // Update snapshot status with creationTime
643644 for i := 0 ; i < ctrl .createSnapshotContentRetryCount ; i ++ {
644645 klog .V (5 ).Infof ("createSnapshot [%s]: trying to update snapshot creation timestamp" , snapshotKey (snapshot ))
645- newSnapshot , err = ctrl .updateSnapshotStatus (snapshot , readyToUse , timestamp , size , false )
646+ newSnapshot , err = ctrl .updateSnapshotStatus (snapshot , readyToUse , creationTime , size , false )
646647 if err == nil {
647648 break
648649 }
@@ -666,6 +667,7 @@ func (ctrl *csiSnapshotController) createSnapshotOperation(snapshot *crdv1.Volum
666667 class .DeletionPolicy = new (crdv1.DeletionPolicy )
667668 * class .DeletionPolicy = crdv1 .VolumeSnapshotContentDelete
668669 }
670+ timestamp := creationTime .UnixNano ()
669671 snapshotContent := & crdv1.VolumeSnapshotContent {
670672 ObjectMeta : metav1.ObjectMeta {
671673 Name : contentName ,
@@ -819,12 +821,12 @@ func (ctrl *csiSnapshotController) updateSnapshotContentSize(content *crdv1.Volu
819821}
820822
821823// UpdateSnapshotStatus converts snapshot status to crdv1.VolumeSnapshotCondition
822- func (ctrl * csiSnapshotController ) updateSnapshotStatus (snapshot * crdv1.VolumeSnapshot , readyToUse bool , createdAt , size int64 , bound bool ) (* crdv1.VolumeSnapshot , error ) {
824+ func (ctrl * csiSnapshotController ) updateSnapshotStatus (snapshot * crdv1.VolumeSnapshot , readyToUse bool , createdAt time. Time , size int64 , bound bool ) (* crdv1.VolumeSnapshot , error ) {
823825 klog .V (5 ).Infof ("updating VolumeSnapshot[]%s, readyToUse %v, timestamp %v" , snapshotKey (snapshot ), readyToUse , createdAt )
824826 status := snapshot .Status
825827 change := false
826828 timeAt := & metav1.Time {
827- Time : time . Unix ( 0 , createdAt ) ,
829+ Time : createdAt ,
828830 }
829831
830832 snapshotClone := snapshot .DeepCopy ()
0 commit comments