@@ -367,7 +367,6 @@ func (ctrl *csiSnapshotController) createSnapshot(snapshot *crdv1.VolumeSnapshot
367367 // We will get an "snapshot update" event soon, this is not a big error
368368 klog .V (4 ).Infof ("createSnapshot [%s]: cannot update internal cache: %v" , snapshotKey (snapshotObj ), updateErr )
369369 }
370-
371370 return nil
372371 })
373372 return nil
@@ -556,15 +555,15 @@ func (ctrl *csiSnapshotController) getCreateSnapshotInput(snapshot *crdv1.Volume
556555
557556func (ctrl * csiSnapshotController ) checkandUpdateBoundSnapshotStatusOperation (snapshot * crdv1.VolumeSnapshot , content * crdv1.VolumeSnapshotContent ) (* crdv1.VolumeSnapshot , error ) {
558557 var err error
559- var timestamp int64
558+ var creationTime time. Time
560559 var size int64
561560 var readyToUse = false
562561 var driverName string
563562 var snapshotID string
564563
565564 if snapshot .Spec .Source == nil {
566565 klog .V (5 ).Infof ("checkandUpdateBoundSnapshotStatusOperation: checking whether snapshot [%s] is pre-bound to content [%s]" , snapshot .Name , content .Name )
567- readyToUse , timestamp , size , err = ctrl .handler .GetSnapshotStatus (content )
566+ readyToUse , creationTime , size , err = ctrl .handler .GetSnapshotStatus (content )
568567 if err != nil {
569568 klog .Errorf ("checkandUpdateBoundSnapshotStatusOperation: failed to call get snapshot status to check whether snapshot is ready to use %q" , err )
570569 return nil , err
@@ -577,18 +576,18 @@ func (ctrl *csiSnapshotController) checkandUpdateBoundSnapshotStatusOperation(sn
577576 if err != nil {
578577 return nil , fmt .Errorf ("failed to get input parameters to create snapshot %s: %q" , snapshot .Name , err )
579578 }
580- driverName , snapshotID , timestamp , size , readyToUse , err = ctrl .handler .CreateSnapshot (snapshot , volume , class .Parameters , snapshotterCredentials )
579+ driverName , snapshotID , creationTime , size , readyToUse , err = ctrl .handler .CreateSnapshot (snapshot , volume , class .Parameters , snapshotterCredentials )
581580 if err != nil {
582581 klog .Errorf ("checkandUpdateBoundSnapshotStatusOperation: failed to call create snapshot to check whether the snapshot is ready to use %q" , err )
583582 return nil , err
584583 }
585584 }
586- klog .V (5 ).Infof ("checkandUpdateBoundSnapshotStatusOperation: driver %s, snapshotId %s, timestamp %d , size %d, readyToUse %t" , driverName , snapshotID , timestamp , size , readyToUse )
585+ klog .V (5 ).Infof ("checkandUpdateBoundSnapshotStatusOperation: driver %s, snapshotId %s, creationTime %v , size %d, readyToUse %t" , driverName , snapshotID , creationTime , size , readyToUse )
587586
588- if timestamp == 0 {
589- timestamp = time .Now (). UnixNano ()
587+ if creationTime . IsZero () {
588+ creationTime = time .Now ()
590589 }
591- newSnapshot , err := ctrl .updateSnapshotStatus (snapshot , readyToUse , timestamp , size , IsSnapshotBound (snapshot , content ))
590+ newSnapshot , err := ctrl .updateSnapshotStatus (snapshot , readyToUse , creationTime , size , IsSnapshotBound (snapshot , content ))
592591 if err != nil {
593592 return nil , err
594593 }
@@ -617,17 +616,18 @@ func (ctrl *csiSnapshotController) createSnapshotOperation(snapshot *crdv1.Volum
617616 return nil , fmt .Errorf ("failed to get input parameters to create snapshot %s: %q" , snapshot .Name , err )
618617 }
619618
620- driverName , snapshotID , timestamp , size , readyToUse , err := ctrl .handler .CreateSnapshot (snapshot , volume , class .Parameters , snapshotterCredentials )
619+ driverName , snapshotID , creationTime , size , readyToUse , err := ctrl .handler .CreateSnapshot (snapshot , volume , class .Parameters , snapshotterCredentials )
621620 if err != nil {
622621 return nil , fmt .Errorf ("failed to take snapshot of the volume, %s: %q" , volume .Name , err )
623622 }
624- klog .V (5 ).Infof ("Created snapshot: driver %s, snapshotId %s, timestamp %d, size %d, readyToUse %t" , driverName , snapshotID , timestamp , size , readyToUse )
623+
624+ klog .V (5 ).Infof ("Created snapshot: driver %s, snapshotId %s, creationTime %v, size %d, readyToUse %t" , driverName , snapshotID , creationTime , size , readyToUse )
625625
626626 var newSnapshot * crdv1.VolumeSnapshot
627- // Update snapshot status with timestamp
627+ // Update snapshot status with creationTime
628628 for i := 0 ; i < ctrl .createSnapshotContentRetryCount ; i ++ {
629629 klog .V (5 ).Infof ("createSnapshot [%s]: trying to update snapshot creation timestamp" , snapshotKey (snapshot ))
630- newSnapshot , err = ctrl .updateSnapshotStatus (snapshot , readyToUse , timestamp , size , false )
630+ newSnapshot , err = ctrl .updateSnapshotStatus (snapshot , readyToUse , creationTime , size , false )
631631 if err == nil {
632632 break
633633 }
@@ -651,6 +651,7 @@ func (ctrl *csiSnapshotController) createSnapshotOperation(snapshot *crdv1.Volum
651651 class .DeletionPolicy = new (crdv1.DeletionPolicy )
652652 * class .DeletionPolicy = crdv1 .VolumeSnapshotContentDelete
653653 }
654+ timestamp := creationTime .UnixNano ()
654655 snapshotContent := & crdv1.VolumeSnapshotContent {
655656 ObjectMeta : metav1.ObjectMeta {
656657 Name : contentName ,
@@ -804,12 +805,12 @@ func (ctrl *csiSnapshotController) updateSnapshotContentSize(content *crdv1.Volu
804805}
805806
806807// UpdateSnapshotStatus converts snapshot status to crdv1.VolumeSnapshotCondition
807- func (ctrl * csiSnapshotController ) updateSnapshotStatus (snapshot * crdv1.VolumeSnapshot , readyToUse bool , createdAt , size int64 , bound bool ) (* crdv1.VolumeSnapshot , error ) {
808+ func (ctrl * csiSnapshotController ) updateSnapshotStatus (snapshot * crdv1.VolumeSnapshot , readyToUse bool , createdAt time. Time , size int64 , bound bool ) (* crdv1.VolumeSnapshot , error ) {
808809 klog .V (5 ).Infof ("updating VolumeSnapshot[]%s, readyToUse %v, timestamp %v" , snapshotKey (snapshot ), readyToUse , createdAt )
809810 status := snapshot .Status
810811 change := false
811812 timeAt := & metav1.Time {
812- Time : time . Unix ( 0 , createdAt ) ,
813+ Time : createdAt ,
813814 }
814815
815816 snapshotClone := snapshot .DeepCopy ()
0 commit comments