Skip to content

Commit

Permalink
Merge pull request #1235 from leonardoce/metatime
Browse files Browse the repository at this point in the history
Change CreationTime in VolumeGroupSnapshotContentStatus from *int64 to *metav1.Time
  • Loading branch information
k8s-ci-robot authored Dec 9, 2024
2 parents bcb30a7 + cb86a44 commit c0cb7b7
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion client/apis/volumegroupsnapshot/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ type VolumeGroupSnapshotContentStatus struct {
// since 1970-01-01 00:00:00 UTC.
// This field is the source for the CreationTime field in VolumeGroupSnapshotStatus
// +optional
CreationTime *int64 `json:"creationTime,omitempty" protobuf:"varint,2,opt,name=creationTime"`
CreationTime *metav1.Time `json:"creationTime,omitempty" protobuf:"bytes,2,opt,name=creationTime"`

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ spec:
On Unix, the command date +%s%N returns the current time in nanoseconds
since 1970-01-01 00:00:00 UTC.
This field is the source for the CreationTime field in VolumeGroupSnapshotStatus
format: int64
type: integer
format: date-time
type: string
error:
description: |-
Error is the last observed error during group snapshot creation, if any.
Expand Down
4 changes: 2 additions & 2 deletions pkg/common-controller/framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ func newContent(contentName, boundToSnapshotUID, boundToSnapshotName, snapshotHa
}

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

func newGroupSnapshotContentArray(groupSnapshotContentName, boundToGroupSnapshotUID, boundToGroupSnapshotSnapshotName, groupSnapshotHandle, groupSnapshotClassName string, desiredVolumeHandles []string, volumeGroupHandle string,
deletionPolicy crdv1.DeletionPolicy, creationTime *int64,
deletionPolicy crdv1.DeletionPolicy, creationTime *metav1.Time,
withFinalizer bool, withStatus bool) []*crdv1beta1.VolumeGroupSnapshotContent {
return []*crdv1beta1.VolumeGroupSnapshotContent{
newGroupSnapshotContent(groupSnapshotContentName, boundToGroupSnapshotUID, boundToGroupSnapshotSnapshotName, groupSnapshotHandle, groupSnapshotClassName, desiredVolumeHandles, volumeGroupHandle,
Expand Down
3 changes: 1 addition & 2 deletions pkg/common-controller/groupsnapshot_controller_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,7 @@ func (ctrl *csiSnapshotCommonController) updateGroupSnapshotStatus(groupSnapshot
boundContentName := groupSnapshotContent.Name
var createdAt *time.Time
if groupSnapshotContent.Status != nil && groupSnapshotContent.Status.CreationTime != nil {
unixTime := time.Unix(0, *groupSnapshotContent.Status.CreationTime)
createdAt = &unixTime
createdAt = &groupSnapshotContent.Status.CreationTime.DeepCopy().Time
}
var readyToUse bool
if groupSnapshotContent.Status != nil && groupSnapshotContent.Status.ReadyToUse != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/sidecar-controller/groupsnapshot_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func (ctrl *csiSnapshotSideCarController) createGroupSnapshotWrapper(groupSnapsh
})
}

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

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c0cb7b7

Please sign in to comment.