From 0e44aca68294ca854dda39d19b85d18024dfcfac Mon Sep 17 00:00:00 2001 From: Emruz Hossain Date: Tue, 19 Nov 2024 16:15:49 +0600 Subject: [PATCH 1/4] Add snapshot duration field in QdrantClusterSnapshot status Signed-off-by: Emruz Hossain --- api/v1/qdrantclustersnapshot_types.go | 4 ++++ api/v1/zz_generated.deepcopy.go | 5 +++++ .../region-crds/qdrant.io_qdrantclustersnapshots.yaml | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/api/v1/qdrantclustersnapshot_types.go b/api/v1/qdrantclustersnapshot_types.go index 6fc9c95..b32e214 100644 --- a/api/v1/qdrantclustersnapshot_types.go +++ b/api/v1/qdrantclustersnapshot_types.go @@ -46,6 +46,9 @@ type QdrantClusterSnapshotStatus struct { // The calculated time (in UTC) this snapshot will be deleted, if so. // +optional RetainUntil *metav1.Time `json:"retainUntil,omitempty"` + // Duration specifies how long it took for the snapshot to complete + // +optional + Duration *metav1.Duration `json:"duration,omitempty"` } type VolumeSnapshotInfo struct { @@ -66,6 +69,7 @@ type VolumeSnapshotInfo struct { // +kubebuilder:printcolumn:name="clusterid",type=string,JSONPath=`.spec.cluster-id` // +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phase` // +kubebuilder:printcolumn:name="retainUntil",type=string,JSONPath=`.status.retainUntil` +// +kubebuilder:printcolumn:name="duration",type=string,JSONPath=`.status.duration` // +kubebuilder:printcolumn:name="age",type=date,JSONPath=`.metadata.creationTimestamp` // QdrantClusterSnapshot is the Schema for the qdrantclustersnapshots API diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 7d11b32..a70fec6 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -787,6 +787,11 @@ func (in *QdrantClusterSnapshotStatus) DeepCopyInto(out *QdrantClusterSnapshotSt in, out := &in.RetainUntil, &out.RetainUntil *out = (*in).DeepCopy() } + if in.Duration != nil { + in, out := &in.Duration, &out.Duration + *out = new(metav1.Duration) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new QdrantClusterSnapshotStatus. diff --git a/charts/qdrant-kubernetes-api/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml b/charts/qdrant-kubernetes-api/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml index 1efe08a..ce0a786 100644 --- a/charts/qdrant-kubernetes-api/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml +++ b/charts/qdrant-kubernetes-api/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml @@ -28,6 +28,9 @@ spec: - jsonPath: .status.retainUntil name: retainUntil type: string + - jsonPath: .status.duration + name: duration + type: string - jsonPath: .metadata.creationTimestamp name: age type: date @@ -83,6 +86,10 @@ spec: type: object status: properties: + duration: + description: Duration specifies how long it took for the snapshot + to complete + type: string phase: enum: - Running From 049ff229ec705dc2318f06325af9d1ef6d4b7dce Mon Sep 17 00:00:00 2001 From: Emruz Hossain Date: Tue, 19 Nov 2024 16:44:10 +0600 Subject: [PATCH 2/4] Add IsCompleted() heleper Signed-off-by: Emruz Hossain --- api/v1/qdrantclustersnapshot_types.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/v1/qdrantclustersnapshot_types.go b/api/v1/qdrantclustersnapshot_types.go index b32e214..930b3af 100644 --- a/api/v1/qdrantclustersnapshot_types.go +++ b/api/v1/qdrantclustersnapshot_types.go @@ -81,6 +81,10 @@ type QdrantClusterSnapshot struct { Status QdrantClusterSnapshotStatus `json:"status,omitempty"` } +func (qcs *QdrantClusterSnapshot) IsCompleted() bool { + return qcs.Status.Phase == SnapshotSucceeded || qcs.Status.Phase == SnapshotFailed || qcs.Status.Phase == SnapshotSkipped +} + //+kubebuilder:object:root=true // QdrantClusterSnapshotList contains a list of QdrantClusterSnapshot From 8a610ff26779270904851dbad319d6fe9fa811e9 Mon Sep 17 00:00:00 2001 From: Emruz Hossain Date: Tue, 19 Nov 2024 19:06:05 +0600 Subject: [PATCH 3/4] Rename Duration to CompletionTime Signed-off-by: Emruz Hossain --- api/v1/qdrantclustersnapshot_types.go | 6 +++--- api/v1/zz_generated.deepcopy.go | 4 ++-- .../region-crds/qdrant.io_qdrantclustersnapshots.yaml | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/v1/qdrantclustersnapshot_types.go b/api/v1/qdrantclustersnapshot_types.go index 930b3af..18334e2 100644 --- a/api/v1/qdrantclustersnapshot_types.go +++ b/api/v1/qdrantclustersnapshot_types.go @@ -46,9 +46,9 @@ type QdrantClusterSnapshotStatus struct { // The calculated time (in UTC) this snapshot will be deleted, if so. // +optional RetainUntil *metav1.Time `json:"retainUntil,omitempty"` - // Duration specifies how long it took for the snapshot to complete + // CompletionTime specifies how long it took for the snapshot to complete // +optional - Duration *metav1.Duration `json:"duration,omitempty"` + CompletionTime *metav1.Duration `json:"completionTime,omitempty"` } type VolumeSnapshotInfo struct { @@ -69,7 +69,7 @@ type VolumeSnapshotInfo struct { // +kubebuilder:printcolumn:name="clusterid",type=string,JSONPath=`.spec.cluster-id` // +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phase` // +kubebuilder:printcolumn:name="retainUntil",type=string,JSONPath=`.status.retainUntil` -// +kubebuilder:printcolumn:name="duration",type=string,JSONPath=`.status.duration` +// +kubebuilder:printcolumn:name="completion-time",type=string,JSONPath=`.status.completionTime` // +kubebuilder:printcolumn:name="age",type=date,JSONPath=`.metadata.creationTimestamp` // QdrantClusterSnapshot is the Schema for the qdrantclustersnapshots API diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index a70fec6..b6795bd 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -787,8 +787,8 @@ func (in *QdrantClusterSnapshotStatus) DeepCopyInto(out *QdrantClusterSnapshotSt in, out := &in.RetainUntil, &out.RetainUntil *out = (*in).DeepCopy() } - if in.Duration != nil { - in, out := &in.Duration, &out.Duration + if in.CompletionTime != nil { + in, out := &in.CompletionTime, &out.CompletionTime *out = new(metav1.Duration) **out = **in } diff --git a/charts/qdrant-kubernetes-api/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml b/charts/qdrant-kubernetes-api/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml index ce0a786..b5e9568 100644 --- a/charts/qdrant-kubernetes-api/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml +++ b/charts/qdrant-kubernetes-api/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml @@ -28,8 +28,8 @@ spec: - jsonPath: .status.retainUntil name: retainUntil type: string - - jsonPath: .status.duration - name: duration + - jsonPath: .status.completionTime + name: completion-time type: string - jsonPath: .metadata.creationTimestamp name: age @@ -86,8 +86,8 @@ spec: type: object status: properties: - duration: - description: Duration specifies how long it took for the snapshot + completionTime: + description: CompletionTime specifies how long it took for the snapshot to complete type: string phase: From f47d59cc47678ded0e6a010900b54fedd9d541bf Mon Sep 17 00:00:00 2001 From: Emruz Hossain Date: Tue, 19 Nov 2024 22:34:31 +0600 Subject: [PATCH 4/4] Added comment about duration format Signed-off-by: Emruz Hossain --- api/v1/qdrantclustersnapshot_types.go | 2 ++ .../region-crds/qdrant.io_qdrantclustersnapshots.yaml | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api/v1/qdrantclustersnapshot_types.go b/api/v1/qdrantclustersnapshot_types.go index 18334e2..f07aafe 100644 --- a/api/v1/qdrantclustersnapshot_types.go +++ b/api/v1/qdrantclustersnapshot_types.go @@ -47,6 +47,8 @@ type QdrantClusterSnapshotStatus struct { // +optional RetainUntil *metav1.Time `json:"retainUntil,omitempty"` // CompletionTime specifies how long it took for the snapshot to complete + // When serialized, it is a Duration in string format which follows "DDdHHhMMmSSs" format + // For example: "1d3h5m10s", "3h5m10s", "5m10s", "10s" etc. // +optional CompletionTime *metav1.Duration `json:"completionTime,omitempty"` } diff --git a/charts/qdrant-kubernetes-api/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml b/charts/qdrant-kubernetes-api/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml index b5e9568..f7f9588 100644 --- a/charts/qdrant-kubernetes-api/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml +++ b/charts/qdrant-kubernetes-api/templates/region-crds/qdrant.io_qdrantclustersnapshots.yaml @@ -87,8 +87,10 @@ spec: status: properties: completionTime: - description: CompletionTime specifies how long it took for the snapshot - to complete + description: |- + CompletionTime specifies how long it took for the snapshot to complete + When serialized, it is a Duration in string format which follows "DDdHHhMMmSSs" format + For example: "1d3h5m10s", "3h5m10s", "5m10s", "10s" etc. type: string phase: enum: