From 2e6e29b4096a0708d820c17d136cc7bc552a48a7 Mon Sep 17 00:00:00 2001 From: Michael Burman Date: Tue, 19 Sep 2023 16:44:32 +0300 Subject: [PATCH] Add bypass for validation for older backups, add printcolumns for prettier output of MedusaRestoreJob --- apis/medusa/v1alpha1/medusarestorejob_types.go | 3 +++ .../medusa.k8ssandra.io_medusarestorejobs.yaml | 15 ++++++++++++++- controllers/medusa/medusarestorejob_controller.go | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/apis/medusa/v1alpha1/medusarestorejob_types.go b/apis/medusa/v1alpha1/medusarestorejob_types.go index e422f45a6..a96933882 100644 --- a/apis/medusa/v1alpha1/medusarestorejob_types.go +++ b/apis/medusa/v1alpha1/medusarestorejob_types.go @@ -61,6 +61,9 @@ type MedusaRestoreJobStatus struct { //+kubebuilder:object:root=true //+kubebuilder:subresource:status +//+kubebuilder:printcolumn:name="Started",type=date,JSONPath=".status.startTime",description="Restore start time" +//+kubebuilder:printcolumn:name="Finished",type=date,JSONPath=".status.finishTime",description="Restore finish time" +//+kubebuilder:printcolumn:name="Error",type=string,JSONPath=".status.message",description="Error message" // MedusaRestoreJob is the Schema for the medusarestorejobs API type MedusaRestoreJob struct { diff --git a/config/crd/bases/medusa.k8ssandra.io_medusarestorejobs.yaml b/config/crd/bases/medusa.k8ssandra.io_medusarestorejobs.yaml index 68ae3779e..dfb48f722 100644 --- a/config/crd/bases/medusa.k8ssandra.io_medusarestorejobs.yaml +++ b/config/crd/bases/medusa.k8ssandra.io_medusarestorejobs.yaml @@ -14,7 +14,20 @@ spec: singular: medusarestorejob scope: Namespaced versions: - - name: v1alpha1 + - additionalPrinterColumns: + - description: Restore start time + jsonPath: .status.startTime + name: Started + type: date + - description: Restore finish time + jsonPath: .status.finishTime + name: Finished + type: date + - description: Error message + jsonPath: .status.message + name: Error + type: string + name: v1alpha1 schema: openAPIV3Schema: description: MedusaRestoreJob is the Schema for the medusarestorejobs API diff --git a/controllers/medusa/medusarestorejob_controller.go b/controllers/medusa/medusarestorejob_controller.go index 46c5b07ec..c110a576e 100644 --- a/controllers/medusa/medusarestorejob_controller.go +++ b/controllers/medusa/medusarestorejob_controller.go @@ -275,6 +275,11 @@ func (r *MedusaRestoreJobReconciler) prepareRestore(ctx context.Context, request } func validateBackupForRestore(backup *medusav1alpha1.MedusaBackup, cassdc *cassdcapi.CassandraDatacenter) error { + if backup.Status.TotalNodes == 0 && backup.Status.FinishedNodes == 0 { + // This is an old backup without enough data, need to skip for backwards compatibility + return nil + } + if backup.Status.FinishTime.IsZero() { return fmt.Errorf("target backup has not finished") }