Skip to content

Commit c0cb7b7

Browse files
authored
Merge pull request kubernetes-csi#1235 from leonardoce/metatime
Change CreationTime in VolumeGroupSnapshotContentStatus from *int64 to *metav1.Time
2 parents bcb30a7 + cb86a44 commit c0cb7b7

File tree

8 files changed

+12
-15
lines changed

8 files changed

+12
-15
lines changed

client/apis/volumegroupsnapshot/v1beta1/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ type VolumeGroupSnapshotContentStatus struct {
327327
// since 1970-01-01 00:00:00 UTC.
328328
// This field is the source for the CreationTime field in VolumeGroupSnapshotStatus
329329
// +optional
330-
CreationTime *int64 `json:"creationTime,omitempty" protobuf:"varint,2,opt,name=creationTime"`
330+
CreationTime *metav1.Time `json:"creationTime,omitempty" protobuf:"bytes,2,opt,name=creationTime"`
331331

332332
// ReadyToUse indicates if all the individual snapshots in the group are ready to be
333333
// used to restore a group of volumes.

client/apis/volumegroupsnapshot/v1beta1/zz_generated.deepcopy.go

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/config/crd/groupsnapshot.storage.k8s.io_volumegroupsnapshotcontents.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ spec:
256256
On Unix, the command date +%s%N returns the current time in nanoseconds
257257
since 1970-01-01 00:00:00 UTC.
258258
This field is the source for the CreationTime field in VolumeGroupSnapshotStatus
259-
format: int64
260-
type: integer
259+
format: date-time
260+
type: string
261261
error:
262262
description: |-
263263
Error is the last observed error during group snapshot creation, if any.

pkg/common-controller/framework_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@ func newContent(contentName, boundToSnapshotUID, boundToSnapshotName, snapshotHa
12801280
}
12811281

12821282
func newGroupSnapshotContent(groupSnapshotContentName, boundToGroupSnapshotUID, boundToGroupSnapshotName, groupSnapshotHandle, groupSnapshotClassName string, desiredVolumeHandles []string, targetVolumeGroupSnapshotHandle string,
1283-
deletionPolicy crdv1.DeletionPolicy, creationTime *int64,
1283+
deletionPolicy crdv1.DeletionPolicy, creationTime *metav1.Time,
12841284
withFinalizer bool, withStatus bool) *crdv1beta1.VolumeGroupSnapshotContent {
12851285
ready := true
12861286
content := crdv1beta1.VolumeGroupSnapshotContent{
@@ -1337,7 +1337,7 @@ func newGroupSnapshotContent(groupSnapshotContentName, boundToGroupSnapshotUID,
13371337
}
13381338

13391339
func newGroupSnapshotContentArray(groupSnapshotContentName, boundToGroupSnapshotUID, boundToGroupSnapshotSnapshotName, groupSnapshotHandle, groupSnapshotClassName string, desiredVolumeHandles []string, volumeGroupHandle string,
1340-
deletionPolicy crdv1.DeletionPolicy, creationTime *int64,
1340+
deletionPolicy crdv1.DeletionPolicy, creationTime *metav1.Time,
13411341
withFinalizer bool, withStatus bool) []*crdv1beta1.VolumeGroupSnapshotContent {
13421342
return []*crdv1beta1.VolumeGroupSnapshotContent{
13431343
newGroupSnapshotContent(groupSnapshotContentName, boundToGroupSnapshotUID, boundToGroupSnapshotSnapshotName, groupSnapshotHandle, groupSnapshotClassName, desiredVolumeHandles, volumeGroupHandle,

pkg/common-controller/groupsnapshot_controller_helper.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,7 @@ func (ctrl *csiSnapshotCommonController) updateGroupSnapshotStatus(groupSnapshot
832832
boundContentName := groupSnapshotContent.Name
833833
var createdAt *time.Time
834834
if groupSnapshotContent.Status != nil && groupSnapshotContent.Status.CreationTime != nil {
835-
unixTime := time.Unix(0, *groupSnapshotContent.Status.CreationTime)
836-
createdAt = &unixTime
835+
createdAt = &groupSnapshotContent.Status.CreationTime.DeepCopy().Time
837836
}
838837
var readyToUse bool
839838
if groupSnapshotContent.Status != nil && groupSnapshotContent.Status.ReadyToUse != nil {

pkg/sidecar-controller/groupsnapshot_helper.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ func (ctrl *csiSnapshotSideCarController) createGroupSnapshotWrapper(groupSnapsh
443443
})
444444
}
445445

446-
newGroupSnapshotContent, err := ctrl.updateGroupSnapshotContentStatus(groupSnapshotContent, groupSnapshotID, readyToUse, creationTime.UnixNano(), snapshotContentLinks)
446+
newGroupSnapshotContent, err := ctrl.updateGroupSnapshotContentStatus(groupSnapshotContent, groupSnapshotID, readyToUse, metav1.NewTime(creationTime), snapshotContentLinks)
447447
if err != nil {
448448
klog.Errorf("error updating status for volume group snapshot content %s: %v.", groupSnapshotContent.Name, err)
449449
return groupSnapshotContent, fmt.Errorf("error updating status for volume group snapshot content %s: %v", groupSnapshotContent.Name, err)
@@ -578,7 +578,7 @@ func (ctrl *csiSnapshotSideCarController) updateGroupSnapshotContentStatus(
578578
groupSnapshotContent *crdv1beta1.VolumeGroupSnapshotContent,
579579
groupSnapshotHandle string,
580580
readyToUse bool,
581-
createdAt int64,
581+
createdAt metav1.Time,
582582
snapshotContentLinks []snapshotContentNameVolumeHandlePair,
583583
) (*crdv1beta1.VolumeGroupSnapshotContent, error) {
584584
klog.V(5).Infof("updateGroupSnapshotContentStatus: updating VolumeGroupSnapshotContent [%s], groupSnapshotHandle %s, readyToUse %v, createdAt %v", groupSnapshotContent.Name, groupSnapshotHandle, readyToUse, createdAt)
@@ -789,7 +789,7 @@ func (ctrl *csiSnapshotSideCarController) checkandUpdateGroupSnapshotContentStat
789789
}
790790

791791
// TODO: Get a reference to snapshot contents for this volume group snapshot
792-
updatedContent, err := ctrl.updateGroupSnapshotContentStatus(groupSnapshotContent, groupSnapshotID, readyToUse, creationTime.UnixNano(), []snapshotContentNameVolumeHandlePair{})
792+
updatedContent, err := ctrl.updateGroupSnapshotContentStatus(groupSnapshotContent, groupSnapshotID, readyToUse, metav1.NewTime(creationTime), []snapshotContentNameVolumeHandlePair{})
793793
if err != nil {
794794
return groupSnapshotContent, err
795795
}

vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1/types.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta1/zz_generated.deepcopy.go

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)