From d757a39933091a0ff14a546a3eaa3dbfaabd6292 Mon Sep 17 00:00:00 2001 From: acekingke Date: Wed, 24 Aug 2022 14:45:44 +0800 Subject: [PATCH] api,backup: add printcolumn for Success #668 --- api/v1alpha1/backup_types.go | 1 + backup/syncer/job.go | 1 + charts/mysql-operator/crds/mysql.radondb.com_backups.yaml | 4 ++++ config/crd/bases/mysql.radondb.com_backups.yaml | 4 ++++ 4 files changed, 10 insertions(+) diff --git a/api/v1alpha1/backup_types.go b/api/v1alpha1/backup_types.go index 0e51bb12..071a31bb 100644 --- a/api/v1alpha1/backup_types.go +++ b/api/v1alpha1/backup_types.go @@ -72,6 +72,7 @@ type BackupStatus struct { // +kubebuilder:printcolumn:name="BackupName",type="string",JSONPath=".status.backupName",description="The Backup name" // +kubebuilder:printcolumn:name="BackupDate",type="string",JSONPath=".status.backupDate",description="The Backup Date time" // +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".status.backupType",description="The Backup Type" +// +kubebuilder:printcolumn:name="Success",type="string",JSONPath=".status.conditions[?(@.type==\"Complete\")].status",description="Whether the backup Success?" // Backup is the Schema for the backups API type Backup struct { metav1.TypeMeta `json:",inline"` diff --git a/backup/syncer/job.go b/backup/syncer/job.go index cd2e904f..b6947b39 100644 --- a/backup/syncer/job.go +++ b/backup/syncer/job.go @@ -104,6 +104,7 @@ func (s *jobSyncer) updateStatus(job *batchv1.Job) { // check for failed condition if cond := jobCondition(batchv1.JobFailed, job); cond != nil { s.backup.UpdateStatusCondition(v1alpha1.BackupFailed, cond.Status, cond.Reason, cond.Message) + s.backup.UpdateStatusCondition(v1alpha1.BackupComplete, corev1.ConditionFalse, cond.Reason, cond.Message) if cond.Status == corev1.ConditionTrue { s.backup.Status.Completed = true } diff --git a/charts/mysql-operator/crds/mysql.radondb.com_backups.yaml b/charts/mysql-operator/crds/mysql.radondb.com_backups.yaml index da241801..06a454d7 100644 --- a/charts/mysql-operator/crds/mysql.radondb.com_backups.yaml +++ b/charts/mysql-operator/crds/mysql.radondb.com_backups.yaml @@ -29,6 +29,10 @@ spec: jsonPath: .status.backupType name: Type type: string + - description: Whether the backup Success? + jsonPath: .status.conditions[?(@.type=="Complete")].status + name: Success + type: string name: v1alpha1 schema: openAPIV3Schema: diff --git a/config/crd/bases/mysql.radondb.com_backups.yaml b/config/crd/bases/mysql.radondb.com_backups.yaml index da241801..06a454d7 100644 --- a/config/crd/bases/mysql.radondb.com_backups.yaml +++ b/config/crd/bases/mysql.radondb.com_backups.yaml @@ -29,6 +29,10 @@ spec: jsonPath: .status.backupType name: Type type: string + - description: Whether the backup Success? + jsonPath: .status.conditions[?(@.type=="Complete")].status + name: Success + type: string name: v1alpha1 schema: openAPIV3Schema: