diff --git a/api/v1beta1/aerospikebackup_webhook.go b/api/v1beta1/aerospikebackup_webhook.go index 8d114b62..c5334ddb 100644 --- a/api/v1beta1/aerospikebackup_webhook.go +++ b/api/v1beta1/aerospikebackup_webhook.go @@ -38,20 +38,20 @@ import ( "github.com/aerospike/aerospike-kubernetes-operator/controllers/common" ) -// log is for logging in this package. -var aerospikeBackupLog = logf.Log.WithName("aerospikebackup-resource") - func (r *AerospikeBackup) SetupWebhookWithManager(mgr ctrl.Manager) error { return ctrl.NewWebhookManagedBy(mgr). For(r). Complete() } +// Implemented Defaulter interface for future reference var _ webhook.Defaulter = &AerospikeBackup{} // Default implements webhook.Defaulter so a webhook will be registered for the type func (r *AerospikeBackup) Default() { - aerospikeBackupLog.Info("default", "name", r.Name) + abLog := logf.Log.WithName(namespacedName(r)) + + abLog.Info("Setting defaults for aerospikeBackup") } //nolint:lll // for readability @@ -61,9 +61,11 @@ var _ webhook.Validator = &AerospikeBackup{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type func (r *AerospikeBackup) ValidateCreate() (admission.Warnings, error) { - aerospikeBackupLog.Info("validate create", "name", r.Name) + abLog := logf.Log.WithName(namespacedName(r)) - if len(r.Spec.OnDemandBackups) != 0 && r.Spec.Config.Raw != nil { + abLog.Info("Validate create") + + if len(r.Spec.OnDemandBackups) != 0 { return nil, fmt.Errorf("onDemand backups config cannot be specified while creating backup") } @@ -76,7 +78,9 @@ func (r *AerospikeBackup) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *AerospikeBackup) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - aerospikeBackupLog.Info("validate update", "name", r.Name) + abLog := logf.Log.WithName(namespacedName(r)) + + abLog.Info("Validate update") oldObj := old.(*AerospikeBackup) @@ -101,32 +105,34 @@ func (r *AerospikeBackup) ValidateUpdate(old runtime.Object) (admission.Warnings // ValidateDelete implements webhook.Validator so a webhook will be registered for the type func (r *AerospikeBackup) ValidateDelete() (admission.Warnings, error) { - aerospikeBackupLog.Info("validate delete", "name", r.Name) + abLog := logf.Log.WithName(namespacedName(r)) + + abLog.Info("Validate delete") // TODO(user): fill in your validation logic upon object deletion. return nil, nil } func (r *AerospikeBackup) validateBackupConfig() error { - backupConfigMap := make(map[string]interface{}) + backupConfig := make(map[string]interface{}) - if err := yaml.Unmarshal(r.Spec.Config.Raw, &backupConfigMap); err != nil { + if err := yaml.Unmarshal(r.Spec.Config.Raw, &backupConfig); err != nil { return err } - if _, ok := backupConfigMap[common.ServiceKey]; ok { + if _, ok := backupConfig[common.ServiceKey]; ok { return fmt.Errorf("service field cannot be specified in backup config") } - if _, ok := backupConfigMap[common.BackupPoliciesKey]; ok { + if _, ok := backupConfig[common.BackupPoliciesKey]; ok { return fmt.Errorf("backup-policies field cannot be specified in backup config") } - if _, ok := backupConfigMap[common.StorageKey]; ok { + if _, ok := backupConfig[common.StorageKey]; ok { return fmt.Errorf("storage field cannot be specified in backup config") } - if _, ok := backupConfigMap[common.SecretAgentsKey]; ok { + if _, ok := backupConfig[common.SecretAgentsKey]; ok { return fmt.Errorf("secret-agent field cannot be specified in backup config") } @@ -149,30 +155,18 @@ func (r *AerospikeBackup) validateBackupConfig() error { return err } - aeroClusters, err := r.validateAerospikeCluster(&backupSvcConfig, backupConfigMap) + aeroClusters, err := r.getValidatedAerospikeClusters(backupConfig) if err != nil { return err } - err = r.validateBackupRoutines(&backupSvcConfig, backupConfigMap, aeroClusters) + backupRoutines, err := r.getValidatedBackupRoutines(backupConfig, aeroClusters) if err != nil { return err } - // Add empty placeholders for missing backupSvcConfig sections. This is required for validation to work. - if backupSvcConfig.ServiceConfig == nil { - backupSvcConfig.ServiceConfig = &model.BackupServiceConfig{} - } - - if backupSvcConfig.ServiceConfig.HTTPServer == nil { - backupSvcConfig.ServiceConfig.HTTPServer = &model.HTTPServerConfig{} - } - - if backupSvcConfig.ServiceConfig.Logger == nil { - backupSvcConfig.ServiceConfig.Logger = &model.LoggerConfig{} - } - - if err := backupSvcConfig.Validate(); err != nil { + err = updateValidateBackupSvcConfig(aeroClusters, backupRoutines, &backupSvcConfig) + if err != nil { return err } @@ -206,14 +200,13 @@ func getK8sClient() (client.Client, error) { return cl, nil } -func (r *AerospikeBackup) validateAerospikeCluster(backupSvcConfig *model.Config, - backupConfigMap map[string]interface{}, +func (r *AerospikeBackup) getValidatedAerospikeClusters(backupConfig map[string]interface{}, ) (map[string]*model.AerospikeCluster, error) { - if _, ok := backupConfigMap[common.AerospikeClusterKey]; !ok { + if _, ok := backupConfig[common.AerospikeClusterKey]; !ok { return nil, fmt.Errorf("aerospike-cluster field is required field in backup config") } - cluster, ok := backupConfigMap[common.AerospikeClusterKey].(map[string]interface{}) + cluster, ok := backupConfig[common.AerospikeClusterKey].(map[string]interface{}) if !ok { return nil, fmt.Errorf("aerospike-cluster field is not in the right format") } @@ -230,19 +223,13 @@ func (r *AerospikeBackup) validateAerospikeCluster(backupSvcConfig *model.Config } if len(aeroClusters) != 1 { - return aeroClusters, fmt.Errorf("only one aerospike cluster is allowed in backup backupSvcConfig") + return aeroClusters, fmt.Errorf("only one aerospike cluster is allowed in backup config") } - if len(backupSvcConfig.AerospikeClusters) == 0 { - backupSvcConfig.AerospikeClusters = make(map[string]*model.AerospikeCluster) - } - - for clusterName, aeroCluster := range aeroClusters { + for clusterName := range aeroClusters { if err := validateName(r.NamePrefix(), clusterName); err != nil { return nil, fmt.Errorf("invalid cluster name %s, %s", clusterName, err.Error()) } - - backupSvcConfig.AerospikeClusters[clusterName] = aeroCluster } return aeroClusters, nil @@ -259,7 +246,8 @@ func (r *AerospikeBackup) validateOnDemandBackupsUpdate(oldObj *AerospikeBackup) // Check if onDemand backup spec is updated if r.Spec.OnDemandBackups[0].ID == oldObj.Spec.OnDemandBackups[0].ID && !reflect.DeepEqual(r.Spec.OnDemandBackups[0], oldObj.Spec.OnDemandBackups[0]) { - return fmt.Errorf("onDemand backup cannot be updated") + return fmt.Errorf("existing onDemand backup cannot be updated. " + + "However, It can be removed and a new onDemand backup can be added") } // Check if previous onDemand backup is completed before allowing new onDemand backup @@ -289,39 +277,39 @@ func (r *AerospikeBackup) validateAerospikeClusterUpdate(oldObj *AerospikeBackup for clusterName := range newCluster { if _, ok := oldCluster[clusterName]; !ok { - return fmt.Errorf("aerospike-cluster name update is not allowed") + return fmt.Errorf("aerospike-cluster name cannot be updated") } } return nil } -func (r *AerospikeBackup) validateBackupRoutines(backupSvcConfig *model.Config, - backupSvcConfigMap map[string]interface{}, +func (r *AerospikeBackup) getValidatedBackupRoutines( + backupConfig map[string]interface{}, aeroClusters map[string]*model.AerospikeCluster, -) error { - if _, ok := backupSvcConfigMap[common.BackupRoutinesKey]; !ok { - return fmt.Errorf("backup-routines field is required in backup config") +) (map[string]*model.BackupRoutine, error) { + if _, ok := backupConfig[common.BackupRoutinesKey]; !ok { + return nil, fmt.Errorf("backup-routines field is required in backup config") } - routines, ok := backupSvcConfigMap[common.BackupRoutinesKey].(map[string]interface{}) + routines, ok := backupConfig[common.BackupRoutinesKey].(map[string]interface{}) if !ok { - return fmt.Errorf("backup-routines field is not in the right format") + return nil, fmt.Errorf("backup-routines field is not in the right format") } routineBytes, rErr := yaml.Marshal(routines) if rErr != nil { - return rErr + return nil, rErr } backupRoutines := make(map[string]*model.BackupRoutine) if err := yaml.Unmarshal(routineBytes, &backupRoutines); err != nil { - return err + return nil, err } if len(backupRoutines) == 0 { - return fmt.Errorf("backup-routines field is empty") + return nil, fmt.Errorf("backup-routines field cannot be empty") } // validate: @@ -329,23 +317,52 @@ func (r *AerospikeBackup) validateBackupRoutines(backupSvcConfig *model.Config, // 2. if only correct aerospike cluster (the one referred in Backup CR) is used in backup routines for routineName, routine := range backupRoutines { if err := validateName(r.NamePrefix(), routineName); err != nil { - return fmt.Errorf("invalid backup routine name %s, %s", routineName, err.Error()) + return nil, fmt.Errorf("invalid backup routine name %s, %s", routineName, err.Error()) } if _, ok := aeroClusters[routine.SourceCluster]; !ok { - return fmt.Errorf("cluster %s not found in backup aerospike-cluster config", routine.SourceCluster) + return nil, fmt.Errorf("cluster %s not found in backup aerospike-cluster config", routine.SourceCluster) } } + return backupRoutines, nil +} + +func updateValidateBackupSvcConfig( + clusters map[string]*model.AerospikeCluster, + routines map[string]*model.BackupRoutine, + backupSvcConfig *model.Config, +) error { + if len(backupSvcConfig.AerospikeClusters) == 0 { + backupSvcConfig.AerospikeClusters = make(map[string]*model.AerospikeCluster) + } + + for name, cluster := range clusters { + backupSvcConfig.AerospikeClusters[name] = cluster + } + if len(backupSvcConfig.BackupRoutines) == 0 { backupSvcConfig.BackupRoutines = make(map[string]*model.BackupRoutine) } - for name, routine := range backupRoutines { + for name, routine := range routines { backupSvcConfig.BackupRoutines[name] = routine } - return nil + // Add empty placeholders for missing backupSvcConfig sections. This is required for validation to work. + if backupSvcConfig.ServiceConfig == nil { + backupSvcConfig.ServiceConfig = &model.BackupServiceConfig{} + } + + if backupSvcConfig.ServiceConfig.HTTPServer == nil { + backupSvcConfig.ServiceConfig.HTTPServer = &model.HTTPServerConfig{} + } + + if backupSvcConfig.ServiceConfig.Logger == nil { + backupSvcConfig.ServiceConfig.Logger = &model.LoggerConfig{} + } + + return backupSvcConfig.Validate() } func (r *AerospikeBackup) NamePrefix() string { diff --git a/api/v1beta1/aerospikebackupservice_types.go b/api/v1beta1/aerospikebackupservice_types.go index 8a7b6344..bec63bee 100644 --- a/api/v1beta1/aerospikebackupservice_types.go +++ b/api/v1beta1/aerospikebackupservice_types.go @@ -60,12 +60,12 @@ type AerospikeBackupServiceSpec struct { Resources *corev1.ResourceRequirements `json:"resources,omitempty"` // SecretMounts is the list of secret to be mounted in the backup service. - // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Backup Service Volume" + // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Backup Service SecretMounts" SecretMounts []SecretMount `json:"secrets,omitempty"` // Service defines the Kubernetes service configuration for the backup service. // It is used to expose the backup service deployment. By default, the service type is ClusterIP. - // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Backup Service" + // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="K8s Service" Service *Service `json:"service,omitempty"` } @@ -106,7 +106,7 @@ type AerospikeBackupServiceStatus struct { // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="Image",type=string,JSONPath=`.spec.image` // +kubebuilder:printcolumn:name="Service Type",type=string,JSONPath=`.spec.service.type` -// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.phase` +// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phase` // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" // AerospikeBackupService is the Schema for the aerospikebackupservices API diff --git a/api/v1beta1/aerospikebackupservice_webhook.go b/api/v1beta1/aerospikebackupservice_webhook.go index 34f13d8e..a751c381 100644 --- a/api/v1beta1/aerospikebackupservice_webhook.go +++ b/api/v1beta1/aerospikebackupservice_webhook.go @@ -29,20 +29,20 @@ import ( "github.com/abhishekdwivedi3060/aerospike-backup-service/pkg/model" ) -// log is for logging in this package. -var aerospikeBackupServiceLog = logf.Log.WithName("aerospikebackupservice-resource") - func (r *AerospikeBackupService) SetupWebhookWithManager(mgr ctrl.Manager) error { return ctrl.NewWebhookManagedBy(mgr). For(r). Complete() } +// Implemented Defaulter interface for future reference var _ webhook.Defaulter = &AerospikeBackupService{} // Default implements webhook.Defaulter so a webhook will be registered for the type func (r *AerospikeBackupService) Default() { - aerospikeBackupServiceLog.Info("default", "name", r.Name) + absLog := logf.Log.WithName(namespacedName(r)) + + absLog.Info("Setting defaults for aerospikeBackupService") } //nolint:lll // for readability @@ -52,7 +52,9 @@ var _ webhook.Validator = &AerospikeBackupService{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type func (r *AerospikeBackupService) ValidateCreate() (admission.Warnings, error) { - aerospikeBackupServiceLog.Info("validate create", "name", r.Name) + absLog := logf.Log.WithName(namespacedName(r)) + + absLog.Info("Validate create") if err := r.validateBackupServiceConfig(); err != nil { return nil, err @@ -63,7 +65,9 @@ func (r *AerospikeBackupService) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *AerospikeBackupService) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) { - aerospikeBackupServiceLog.Info("validate update", "name", r.Name) + absLog := logf.Log.WithName(namespacedName(r)) + + absLog.Info("Validate update") if err := r.validateBackupServiceConfig(); err != nil { return nil, err @@ -74,7 +78,9 @@ func (r *AerospikeBackupService) ValidateUpdate(_ runtime.Object) (admission.War // ValidateDelete implements webhook.Validator so a webhook will be registered for the type func (r *AerospikeBackupService) ValidateDelete() (admission.Warnings, error) { - aerospikeBackupServiceLog.Info("validate delete", "name", r.Name) + absLog := logf.Log.WithName(namespacedName(r)) + + absLog.Info("Validate delete") // TODO(user): fill in your validation logic upon object deletion. return nil, nil diff --git a/api/v1beta1/aerospikerestore_types.go b/api/v1beta1/aerospikerestore_types.go index a9df1ae4..fe64b840 100644 --- a/api/v1beta1/aerospikerestore_types.go +++ b/api/v1beta1/aerospikerestore_types.go @@ -39,7 +39,7 @@ type RestoreType string const ( Full RestoreType = "Full" Incremental RestoreType = "Incremental" - TimeStamp RestoreType = "TimeStamp" + Timestamp RestoreType = "Timestamp" ) // AerospikeRestoreSpec defines the desired state of AerospikeRestore @@ -53,9 +53,9 @@ type AerospikeRestoreSpec struct { BackupService BackupService `json:"backupService"` // Type is the type of restore. It can of type Full, Incremental, and Timestamp. - // Based on the restore type, relevant restore config is given. + // Based on the restore type, the relevant restore config should be given. // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Restore Type" - // +kubebuilder:validation:Enum=Full;Incremental;TimeStamp + // +kubebuilder:validation:Enum=Full;Incremental;Timestamp Type RestoreType `json:"type"` // Config is the free form configuration for the restore in YAML format. @@ -86,7 +86,7 @@ type AerospikeRestoreStatus struct { // +kubebuilder:subresource:status // +kubebuilder:printcolumn:name="Backup Service Name",type=string,JSONPath=`.spec.backupService.name` // +kubebuilder:printcolumn:name="Backup Service Namespace",type=string,JSONPath=`.spec.backupService.namespace` -// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.phase` +// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phase` // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" // AerospikeRestore is the Schema for the aerospikerestores API diff --git a/api/v1beta1/aerospikerestore_webhook.go b/api/v1beta1/aerospikerestore_webhook.go index cbafa642..da5496b3 100644 --- a/api/v1beta1/aerospikerestore_webhook.go +++ b/api/v1beta1/aerospikerestore_webhook.go @@ -32,9 +32,6 @@ import ( "github.com/aerospike/aerospike-kubernetes-operator/controllers/common" ) -// log is for logging in this package. -var aerospikeRestoreLog = logf.Log.WithName("aerospikerestore-resource") - const defaultPollingPeriod time.Duration = 60 * time.Second func (r *AerospikeRestore) SetupWebhookWithManager(mgr ctrl.Manager) error { @@ -50,7 +47,9 @@ var _ webhook.Defaulter = &AerospikeRestore{} // Default implements webhook.Defaulter so a webhook will be registered for the type func (r *AerospikeRestore) Default() { - aerospikeRestoreLog.Info("default", "name", r.Name) + arLog := logf.Log.WithName(namespacedName(r)) + + arLog.Info("Setting defaults for aerospikeRestore") if r.Spec.PollingPeriod.Duration.Seconds() == 0 { r.Spec.PollingPeriod.Duration = defaultPollingPeriod @@ -64,7 +63,9 @@ var _ webhook.Validator = &AerospikeRestore{} // ValidateCreate implements webhook.Validator so a webhook will be registered for the type func (r *AerospikeRestore) ValidateCreate() (admission.Warnings, error) { - aerospikeRestoreLog.Info("validate create", "name", r.Name) + arLog := logf.Log.WithName(namespacedName(r)) + + arLog.Info("Validate create") if err := r.validateRestoreConfig(); err != nil { return nil, err @@ -75,12 +76,14 @@ func (r *AerospikeRestore) ValidateCreate() (admission.Warnings, error) { // ValidateUpdate implements webhook.Validator so a webhook will be registered for the type func (r *AerospikeRestore) ValidateUpdate(old runtime.Object) (admission.Warnings, error) { - aerospikeRestoreLog.Info("validate update", "name", r.Name) + arLog := logf.Log.WithName(namespacedName(r)) + + arLog.Info("Validate update") oldRestore := old.(*AerospikeRestore) if !reflect.DeepEqual(oldRestore.Spec, r.Spec) { - return nil, fmt.Errorf("AerospikeRestore Spec is immutable") + return nil, fmt.Errorf("aerospikeRestore Spec is immutable") } return nil, nil @@ -88,7 +91,9 @@ func (r *AerospikeRestore) ValidateUpdate(old runtime.Object) (admission.Warning // ValidateDelete implements webhook.Validator so a webhook will be registered for the type func (r *AerospikeRestore) ValidateDelete() (admission.Warnings, error) { - aerospikeRestoreLog.Info("validate delete", "name", r.Name) + arLog := logf.Log.WithName(namespacedName(r)) + + arLog.Info("Validate delete") // TODO(user): fill in your validation logic upon object deletion. return nil, nil @@ -119,7 +124,7 @@ func (r *AerospikeRestore) validateRestoreConfig() error { return restoreRequest.Validate() - case TimeStamp: + case Timestamp: var restoreRequest model.RestoreTimestampRequest if _, ok := restoreConfigInMap[common.SourceKey]; ok { diff --git a/api/v1beta1/utils.go b/api/v1beta1/utils.go new file mode 100644 index 00000000..2219c1e4 --- /dev/null +++ b/api/v1beta1/utils.go @@ -0,0 +1,13 @@ +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +func namespacedName(obj client.Object) string { + return types.NamespacedName{ + Namespace: obj.GetNamespace(), + Name: obj.GetName(), + }.String() +} diff --git a/config/crd/bases/asdb.aerospike.com_aerospikebackupservices.yaml b/config/crd/bases/asdb.aerospike.com_aerospikebackupservices.yaml index d823be87..75dc3df7 100644 --- a/config/crd/bases/asdb.aerospike.com_aerospikebackupservices.yaml +++ b/config/crd/bases/asdb.aerospike.com_aerospikebackupservices.yaml @@ -22,7 +22,7 @@ spec: name: Service Type type: string - jsonPath: .status.phase - name: Status + name: Phase type: string - jsonPath: .metadata.creationTimestamp name: Age diff --git a/config/crd/bases/asdb.aerospike.com_aerospikerestores.yaml b/config/crd/bases/asdb.aerospike.com_aerospikerestores.yaml index accd2891..759a1193 100644 --- a/config/crd/bases/asdb.aerospike.com_aerospikerestores.yaml +++ b/config/crd/bases/asdb.aerospike.com_aerospikerestores.yaml @@ -22,7 +22,7 @@ spec: name: Backup Service Namespace type: string - jsonPath: .status.phase - name: Status + name: Phase type: string - jsonPath: .metadata.creationTimestamp name: Age @@ -75,12 +75,12 @@ spec: type: string type: description: Type is the type of restore. It can of type Full, Incremental, - and Timestamp. Based on the restore type, relevant restore config - is given. + and Timestamp. Based on the restore type, the relevant restore config + should be given. enum: - Full - Incremental - - TimeStamp + - Timestamp type: string required: - backupService diff --git a/config/samples/aerospikebackup.yaml b/config/samples/aerospikebackup.yaml index c0a743fa..2fa06913 100644 --- a/config/samples/aerospikebackup.yaml +++ b/config/samples/aerospikebackup.yaml @@ -1,12 +1,6 @@ apiVersion: asdb.aerospike.com/v1beta1 kind: AerospikeBackup metadata: - labels: - app.kubernetes.io/name: aerospikebackup - app.kubernetes.io/instance: aerospikebackup-sample - app.kubernetes.io/part-of: aerospike-kubernetes-operator - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/created-by: aerospike-kubernetes-operator name: aerospikebackup namespace: aerospike spec: @@ -18,7 +12,7 @@ spec: # routineName: aerospike-aerospikebackup-test-routine config: aerospike-cluster: - aerospike-aerospikebackup-test-cluster: + aerospike-aerospikebackup-test-cluster: # Name format: -- credentials: password: admin123 user: admin @@ -26,7 +20,7 @@ spec: - host-name: aerocluster.aerospike.svc.cluster.local port: 3000 backup-routines: - aerospike-aerospikebackup-test-routine: + aerospike-aerospikebackup-test-routine: # Name format: -- backup-policy: test-policy interval-cron: "@daily" incr-interval-cron: "@hourly" diff --git a/config/samples/aerospikebackupservice.yaml b/config/samples/aerospikebackupservice.yaml index 7081a239..e34f1d39 100644 --- a/config/samples/aerospikebackupservice.yaml +++ b/config/samples/aerospikebackupservice.yaml @@ -1,16 +1,10 @@ apiVersion: asdb.aerospike.com/v1beta1 kind: AerospikeBackupService metadata: - labels: - app.kubernetes.io/name: aerospikebackupservice - app.kubernetes.io/instance: aerospikebackupservice-sample - app.kubernetes.io/part-of: aerospike-kubernetes-operator - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/created-by: aerospike-kubernetes-operator name: aerospikebackupservice-sample namespace: aerospike spec: - image: aerospike.jfrog.io/ecosystem-container-prod-local/aerospike-backup-service:1.0.0 + image: aerospike/aerospike-backup-service:1.0.0 config: service: http: diff --git a/config/samples/aerospikerestore.yaml b/config/samples/aerospikerestore.yaml index 209b2acd..c25daded 100644 --- a/config/samples/aerospikerestore.yaml +++ b/config/samples/aerospikerestore.yaml @@ -1,12 +1,6 @@ apiVersion: asdb.aerospike.com/v1beta1 kind: AerospikeRestore metadata: - labels: - app.kubernetes.io/name: aerospikerestore - app.kubernetes.io/instance: aerospikerestore-sample - app.kubernetes.io/part-of: aerospike-kubernetes-operator - app.kubernetes.io/managed-by: kustomize - app.kubernetes.io/created-by: aerospike-kubernetes-operator name: aerospikerestore-sample namespace: aerospike spec: diff --git a/controllers/aerospikecluster_controller.go b/controllers/aerospikecluster_controller.go index 025af166..8f961c35 100644 --- a/controllers/aerospikecluster_controller.go +++ b/controllers/aerospikecluster_controller.go @@ -96,7 +96,7 @@ func (r *AerospikeClusterReconciler) Reconcile( return reconcile.Result{}, nil } // Error reading the object - requeue the request. - return reconcile.Result{Requeue: true}, err + return reconcile.Result{}, err } cr := SingleClusterReconciler{ diff --git a/controllers/backup-service/aerospikebackupservice_controller.go b/controllers/backup-service/aerospikebackupservice_controller.go index c4bfd020..966d1517 100644 --- a/controllers/backup-service/aerospikebackupservice_controller.go +++ b/controllers/backup-service/aerospikebackupservice_controller.go @@ -60,7 +60,7 @@ func (r *AerospikeBackupServiceReconciler) Reconcile(_ context.Context, request return reconcile.Result{}, nil } // Error reading the object - requeue the request. - return reconcile.Result{Requeue: true}, err + return reconcile.Result{}, err } cr := SingleBackupServiceReconciler{ diff --git a/controllers/backup-service/reconciler.go b/controllers/backup-service/reconciler.go index 759f6f11..714c664b 100644 --- a/controllers/backup-service/reconciler.go +++ b/controllers/backup-service/reconciler.go @@ -667,8 +667,6 @@ func (r *SingleBackupServiceReconciler) updateStatus() error { r.aeroBackupService.Status = *status - r.Log.Info(fmt.Sprintf("Updating status: %+v", r.aeroBackupService.Status)) - return r.Client.Status().Update(context.Background(), r.aeroBackupService) } diff --git a/controllers/backup/aerospikebackup_controller.go b/controllers/backup/aerospikebackup_controller.go index cdec3598..e3cb49c9 100644 --- a/controllers/backup/aerospikebackup_controller.go +++ b/controllers/backup/aerospikebackup_controller.go @@ -60,7 +60,7 @@ func (r *AerospikeBackupReconciler) Reconcile(_ context.Context, request ctrl.Re return reconcile.Result{}, nil } // Error reading the object - requeue the request. - return reconcile.Result{Requeue: true}, err + return reconcile.Result{}, err } cr := SingleBackupReconciler{ diff --git a/controllers/backup/reconciler.go b/controllers/backup/reconciler.go index 492da642..ac4c3bb3 100644 --- a/controllers/backup/reconciler.go +++ b/controllers/backup/reconciler.go @@ -116,59 +116,54 @@ func (r *SingleBackupReconciler) removeFinalizer(finalizerName string) error { func (r *SingleBackupReconciler) reconcileConfigMap() error { cm, err := r.getBackupSvcConfigMap() if err != nil { - return fmt.Errorf("backup Service configMap not found, name: %s", - r.aeroBackup.Spec.BackupService.String()) + return fmt.Errorf("failed to fetch Backup Service configMap, name: %s, error %v", + r.aeroBackup.Spec.BackupService.String(), err.Error()) } r.Log.Info("Updating existing ConfigMap for Backup", "name", r.aeroBackup.Spec.BackupService.String(), ) - specBackupConfigMap, err := r.getBackupConfigInMap() + specBackupConfig, err := r.getBackupConfigInMap() if err != nil { return err } - backupSvcConfigMap := make(map[string]interface{}) + backupSvcConfig := make(map[string]interface{}) data := cm.Data[common.BackupServiceConfigYAML] - err = yaml.Unmarshal([]byte(data), &backupSvcConfigMap) + err = yaml.Unmarshal([]byte(data), &backupSvcConfig) if err != nil { return err } - if _, ok := backupSvcConfigMap[common.AerospikeClustersKey]; !ok { - backupSvcConfigMap[common.AerospikeClustersKey] = make(map[string]interface{}) - } - - clusterMap, ok := backupSvcConfigMap[common.AerospikeClustersKey].(map[string]interface{}) - if !ok { - return fmt.Errorf("aerospike-clusters is not a map") + clusterMap, err := common.GetConfigSection(backupSvcConfig, common.AerospikeClustersKey) + if err != nil { + return err } - cluster := specBackupConfigMap[common.AerospikeClusterKey].(map[string]interface{}) + cluster := specBackupConfig[common.AerospikeClusterKey].(map[string]interface{}) var clusterName string - // There will always be only one cluster in the backup config + // There will always be only one cluster in the backup config. + // Cluster name in the CR will always be unique. + // Uniqueness is maintained by having a prefix with format --. + // It is enforced by the webhook. for name, clusterInfo := range cluster { clusterName = name clusterMap[name] = clusterInfo } - backupSvcConfigMap[common.AerospikeClustersKey] = clusterMap + backupSvcConfig[common.AerospikeClustersKey] = clusterMap - if _, ok = backupSvcConfigMap[common.BackupRoutinesKey]; !ok { - backupSvcConfigMap[common.BackupRoutinesKey] = make(map[string]interface{}) - } - - routineMap, ok := backupSvcConfigMap[common.BackupRoutinesKey].(map[string]interface{}) - if !ok { - return fmt.Errorf("backup-routines is not a map") + routineMap, err := common.GetConfigSection(backupSvcConfig, common.BackupRoutinesKey) + if err != nil { + return err } - routines := specBackupConfigMap[common.BackupRoutinesKey].(map[string]interface{}) + routines := specBackupConfig[common.BackupRoutinesKey].(map[string]interface{}) // Remove the routines which are not in spec routinesToBeDeleted := r.routinesToDelete(routines, routineMap, clusterName) @@ -182,9 +177,9 @@ func (r *SingleBackupReconciler) reconcileConfigMap() error { routineMap[name] = routine } - backupSvcConfigMap[common.BackupRoutinesKey] = routineMap + backupSvcConfig[common.BackupRoutinesKey] = routineMap - updatedConfig, err := yaml.Marshal(backupSvcConfigMap) + updatedConfig, err := yaml.Marshal(backupSvcConfig) if err != nil { return err } @@ -223,35 +218,35 @@ func (r *SingleBackupReconciler) removeBackupInfoFromConfigMap() error { "name", r.aeroBackup.Spec.BackupService.String(), ) - specBackupConfigMap, err := r.getBackupConfigInMap() + specBackupConfig, err := r.getBackupConfigInMap() if err != nil { return err } - backupSvcConfigMap := make(map[string]interface{}) + backupSvcConfig := make(map[string]interface{}) data := cm.Data[common.BackupServiceConfigYAML] - err = yaml.Unmarshal([]byte(data), &backupSvcConfigMap) + err = yaml.Unmarshal([]byte(data), &backupSvcConfig) if err != nil { return err } var clusterName string - if clusterIface, ok := backupSvcConfigMap[common.AerospikeClustersKey]; ok { + if clusterIface, ok := backupSvcConfig[common.AerospikeClustersKey]; ok { if clusterMap, ok := clusterIface.(map[string]interface{}); ok { - currentCluster := specBackupConfigMap[common.AerospikeClusterKey].(map[string]interface{}) + currentCluster := specBackupConfig[common.AerospikeClusterKey].(map[string]interface{}) for name := range currentCluster { clusterName = name delete(clusterMap, name) } - backupSvcConfigMap[common.AerospikeClustersKey] = clusterMap + backupSvcConfig[common.AerospikeClustersKey] = clusterMap } } - if routineIface, ok := backupSvcConfigMap[common.BackupRoutinesKey]; ok { + if routineIface, ok := backupSvcConfig[common.BackupRoutinesKey]; ok { if routineMap, ok := routineIface.(map[string]interface{}); ok { routinesToBeDelete := r.routinesToDelete(nil, routineMap, clusterName) @@ -259,11 +254,11 @@ func (r *SingleBackupReconciler) removeBackupInfoFromConfigMap() error { delete(routineMap, routinesToBeDelete[idx]) } - backupSvcConfigMap[common.BackupRoutinesKey] = routineMap + backupSvcConfig[common.BackupRoutinesKey] = routineMap } } - updatedConfig, err := yaml.Marshal(backupSvcConfigMap) + updatedConfig, err := yaml.Marshal(backupSvcConfig) if err != nil { return err } @@ -335,22 +330,22 @@ func (r *SingleBackupReconciler) reconcileScheduledBackup() error { return err } - backupSvcConfigMap, err := serviceClient.GetBackupServiceConfig() + backupSvcConfig, err := serviceClient.GetBackupServiceConfig() if err != nil { return err } - r.Log.Info("Fetched backup service config", "config", backupSvcConfigMap) + r.Log.Info("Fetched backup service config", "config", backupSvcConfig) - specBackupConfigMap, err := r.getBackupConfigInMap() + specBackupConfig, err := r.getBackupConfigInMap() if err != nil { return err } - if specBackupConfigMap[common.AerospikeClusterKey] != nil { - cluster := specBackupConfigMap[common.AerospikeClusterKey].(map[string]interface{}) + if specBackupConfig[common.AerospikeClusterKey] != nil { + cluster := specBackupConfig[common.AerospikeClusterKey].(map[string]interface{}) - currentClusters, gErr := common.GetConfigSection(backupSvcConfigMap, common.AerospikeClustersKey) + currentClusters, gErr := common.GetConfigSection(backupSvcConfig, common.AerospikeClustersKey) if gErr != nil { return gErr } @@ -380,10 +375,10 @@ func (r *SingleBackupReconciler) reconcileScheduledBackup() error { } } - if specBackupConfigMap[common.BackupRoutinesKey] != nil { - routines := specBackupConfigMap[common.BackupRoutinesKey].(map[string]interface{}) + if specBackupConfig[common.BackupRoutinesKey] != nil { + routines := specBackupConfig[common.BackupRoutinesKey].(map[string]interface{}) - currentRoutines, gErr := common.GetConfigSection(backupSvcConfigMap, common.BackupRoutinesKey) + currentRoutines, gErr := common.GetConfigSection(backupSvcConfig, common.BackupRoutinesKey) if gErr != nil { return gErr } @@ -414,7 +409,7 @@ func (r *SingleBackupReconciler) reconcileScheduledBackup() error { } // If there are routines that are removed, unregister them - err = r.unregisterBackupRoutines(serviceClient, backupSvcConfigMap, specBackupConfigMap) + err = r.deregisterBackupRoutines(serviceClient, backupSvcConfig, specBackupConfig) if err != nil { return err } @@ -453,18 +448,18 @@ func (r *SingleBackupReconciler) unregisterBackup() error { return err } - specBackupConfigMap, err := r.getBackupConfigInMap() + specBackupConfig, err := r.getBackupConfigInMap() if err != nil { return err } - err = r.unregisterBackupRoutines(serviceClient, backupSvcConfig, specBackupConfigMap) + err = r.deregisterBackupRoutines(serviceClient, backupSvcConfig, specBackupConfig) if err != nil { return err } - if specBackupConfigMap[common.AerospikeClusterKey] != nil { - cluster := specBackupConfigMap[common.AerospikeClusterKey].(map[string]interface{}) + if specBackupConfig[common.AerospikeClusterKey] != nil { + cluster := specBackupConfig[common.AerospikeClusterKey].(map[string]interface{}) currentClusters, gErr := common.GetConfigSection(backupSvcConfig, common.AerospikeClustersKey) if gErr != nil { @@ -490,17 +485,17 @@ func (r *SingleBackupReconciler) unregisterBackup() error { return nil } -func (r *SingleBackupReconciler) unregisterBackupRoutines( +func (r *SingleBackupReconciler) deregisterBackupRoutines( serviceClient *backup_service.Client, - backupSvcConfigMap, - specBackupConfigMap map[string]interface{}, + backupSvcConfig, + specBackupConfig map[string]interface{}, ) error { - allRoutines, err := common.GetConfigSection(backupSvcConfigMap, common.BackupRoutinesKey) + allRoutines, err := common.GetConfigSection(backupSvcConfig, common.BackupRoutinesKey) if err != nil { return err } - cluster := specBackupConfigMap[common.AerospikeClusterKey].(map[string]interface{}) + cluster := specBackupConfig[common.AerospikeClusterKey].(map[string]interface{}) var clusterName string @@ -513,7 +508,7 @@ func (r *SingleBackupReconciler) unregisterBackupRoutines( // Ignore routines from the spec if the backup is being deleted if r.aeroBackup.DeletionTimestamp.IsZero() { - specRoutines = specBackupConfigMap[common.BackupRoutinesKey].(map[string]interface{}) + specRoutines = specBackupConfig[common.BackupRoutinesKey].(map[string]interface{}) } routinesToBeDelete := r.routinesToDelete(specRoutines, allRoutines, clusterName) @@ -576,11 +571,11 @@ func (r *SingleBackupReconciler) routinesToDelete( } func (r *SingleBackupReconciler) getBackupConfigInMap() (map[string]interface{}, error) { - backupConfigMap := make(map[string]interface{}) + backupConfig := make(map[string]interface{}) - if err := yaml.Unmarshal(r.aeroBackup.Spec.Config.Raw, &backupConfigMap); err != nil { - return backupConfigMap, err + if err := yaml.Unmarshal(r.aeroBackup.Spec.Config.Raw, &backupConfig); err != nil { + return backupConfig, err } - return backupConfigMap, nil + return backupConfig, nil } diff --git a/controllers/restore/aerospikerestore_controller.go b/controllers/restore/aerospikerestore_controller.go index f9d36126..6270b377 100644 --- a/controllers/restore/aerospikerestore_controller.go +++ b/controllers/restore/aerospikerestore_controller.go @@ -59,7 +59,7 @@ func (r *AerospikeRestoreReconciler) Reconcile(_ context.Context, request ctrl.R return reconcile.Result{}, nil } // Error reading the object - requeue the request. - return reconcile.Result{Requeue: true}, err + return reconcile.Result{}, err } cr := SingleRestoreReconciler{ diff --git a/controllers/restore/reconciler.go b/controllers/restore/reconciler.go index 455f3335..597a8f1a 100644 --- a/controllers/restore/reconciler.go +++ b/controllers/restore/reconciler.go @@ -19,7 +19,7 @@ import ( backup_service "github.com/aerospike/aerospike-kubernetes-operator/pkg/backup-service" ) -// SingleClusterReconciler reconciles a single AerospikeRestore +// SingleRestoreReconciler reconciles a single AerospikeRestore type SingleRestoreReconciler struct { client.Client Recorder record.EventRecorder @@ -83,8 +83,8 @@ func (r *SingleRestoreReconciler) reconcileRestore() common.ReconcileResult { jobID, statusCode, err = serviceClient.TriggerRestoreWithType(r.Log, string(asdbv1beta1.Incremental), r.aeroRestore.Spec.Config.Raw) - case asdbv1beta1.TimeStamp: - jobID, statusCode, err = serviceClient.TriggerRestoreWithType(r.Log, string(asdbv1beta1.TimeStamp), + case asdbv1beta1.Timestamp: + jobID, statusCode, err = serviceClient.TriggerRestoreWithType(r.Log, string(asdbv1beta1.Timestamp), r.aeroRestore.Spec.Config.Raw) default: diff --git a/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikebackupservices.asdb.aerospike.com.yaml b/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikebackupservices.asdb.aerospike.com.yaml index d823be87..75dc3df7 100644 --- a/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikebackupservices.asdb.aerospike.com.yaml +++ b/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikebackupservices.asdb.aerospike.com.yaml @@ -22,7 +22,7 @@ spec: name: Service Type type: string - jsonPath: .status.phase - name: Status + name: Phase type: string - jsonPath: .metadata.creationTimestamp name: Age diff --git a/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikerestores.asdb.aerospike.com.yaml b/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikerestores.asdb.aerospike.com.yaml index accd2891..759a1193 100644 --- a/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikerestores.asdb.aerospike.com.yaml +++ b/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikerestores.asdb.aerospike.com.yaml @@ -22,7 +22,7 @@ spec: name: Backup Service Namespace type: string - jsonPath: .status.phase - name: Status + name: Phase type: string - jsonPath: .metadata.creationTimestamp name: Age @@ -75,12 +75,12 @@ spec: type: string type: description: Type is the type of restore. It can of type Full, Incremental, - and Timestamp. Based on the restore type, relevant restore config - is given. + and Timestamp. Based on the restore type, the relevant restore config + should be given. enum: - Full - Incremental - - TimeStamp + - Timestamp type: string required: - backupService diff --git a/pkg/backup-service/client.go b/pkg/backup-service/client.go index 70992b55..d8373ede 100644 --- a/pkg/backup-service/client.go +++ b/pkg/backup-service/client.go @@ -635,7 +635,7 @@ func (c *Client) TriggerRestoreWithType(log logr.Logger, restoreType string, case "Incremental": url = c.API("/restore/incremental") - case "TimeStamp": + case "Timestamp": url = c.API("/restore/timestamp") default: diff --git a/test/backup/backup_test.go b/test/backup/backup_test.go index 839d4156..2852a727 100644 --- a/test/backup/backup_test.go +++ b/test/backup/backup_test.go @@ -52,7 +52,8 @@ var _ = Describe( backup = newBackupWithConfig(backupNsNm, configBytes) err = CreateBackup(k8sClient, backup) Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("name should start with %s", namePrefix(backupNsNm))) + Expect(err.Error()).To( + ContainSubstring("name should start with %s", namePrefix(backupNsNm))) }) It("Should fail when more than 1 cluster is given in backup config", func() { @@ -67,6 +68,8 @@ var _ = Describe( backup = newBackupWithConfig(backupNsNm, configBytes) err = CreateBackup(k8sClient, backup) Expect(err).To(HaveOccurred()) + Expect(err.Error()).To( + ContainSubstring("only one aerospike cluster is allowed in backup config")) }) It("Should fail when on-demand backup is given at the time of creation", func() { @@ -82,6 +85,8 @@ var _ = Describe( err = CreateBackup(k8sClient, backup) Expect(err).To(HaveOccurred()) + Expect(err.Error()).To( + ContainSubstring("onDemand backups config cannot be specified while creating backup")) }) It("Should fail when non-existing routine is given in on-demand backup", func() { @@ -103,6 +108,8 @@ var _ = Describe( err = updateBackup(k8sClient, backup) Expect(err).To(HaveOccurred()) + Expect(err.Error()).To( + ContainSubstring("invalid onDemand config, backup routine non-existing-routine not found")) }) It("Should fail when backup service is not present", func() { @@ -113,6 +120,8 @@ var _ = Describe( err = CreateBackup(k8sClient, backup) Expect(err).To(HaveOccurred()) + Expect(err.Error()).To( + ContainSubstring("not found")) }) It("Should fail when backup service reference is updated", func() { @@ -129,6 +138,8 @@ var _ = Describe( err = updateBackup(k8sClient, backup) Expect(err).To(HaveOccurred()) + Expect(err.Error()).To( + ContainSubstring("backup service cannot be updated")) }) It("Should fail when non-existing policy is referred in Backup routine", func() { @@ -283,7 +294,8 @@ var _ = Describe( err = updateBackup(k8sClient, backup) Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("aerospike-cluster name update is not allowed")) + Expect(err.Error()).To( + ContainSubstring("aerospike-cluster name cannot be updated")) }) It("Should fail when on-demand backup is added along with backup-config update", func() { @@ -379,20 +391,20 @@ var _ = Describe( // Add a routine to the configMap data := cm.Data[common.BackupServiceConfigYAML] - backupSvcConfigMap := make(map[string]interface{}) + backupSvcConfig := make(map[string]interface{}) - err = yaml.Unmarshal([]byte(data), &backupSvcConfigMap) + err = yaml.Unmarshal([]byte(data), &backupSvcConfig) Expect(err).ToNot(HaveOccurred()) - backupRoutines := backupSvcConfigMap[common.BackupRoutinesKey].(map[string]interface{}) + backupRoutines := backupSvcConfig[common.BackupRoutinesKey].(map[string]interface{}) // Add a new routine with a different name newRoutineName := namePrefix(backupNsNm) + "-" + "test-routine1" backupRoutines[newRoutineName] = backupRoutines[namePrefix(backupNsNm)+"-"+"test-routine"] - backupSvcConfigMap[common.BackupRoutinesKey] = backupRoutines + backupSvcConfig[common.BackupRoutinesKey] = backupRoutines - newData, mErr := yaml.Marshal(backupSvcConfigMap) + newData, mErr := yaml.Marshal(backupSvcConfig) Expect(mErr).ToNot(HaveOccurred()) cm.Data[common.BackupServiceConfigYAML] = string(newData) @@ -421,12 +433,12 @@ var _ = Describe( Expect(err).ToNot(HaveOccurred()) data = cm.Data[common.BackupServiceConfigYAML] - backupSvcConfigMap = make(map[string]interface{}) + backupSvcConfig = make(map[string]interface{}) - err = yaml.Unmarshal([]byte(data), &backupSvcConfigMap) + err = yaml.Unmarshal([]byte(data), &backupSvcConfig) Expect(err).ToNot(HaveOccurred()) - backupRoutines = backupSvcConfigMap[common.BackupRoutinesKey].(map[string]interface{}) + backupRoutines = backupSvcConfig[common.BackupRoutinesKey].(map[string]interface{}) _, ok := backupRoutines[namePrefix(backupNsNm)+"-"+"test-routine1"] Expect(ok).To(BeFalse()) }) diff --git a/test/backup_service/test_utils.go b/test/backup_service/test_utils.go index 48265daf..49f199e9 100644 --- a/test/backup_service/test_utils.go +++ b/test/backup_service/test_utils.go @@ -23,7 +23,7 @@ import ( "github.com/aerospike/aerospike-kubernetes-operator/test" ) -const BackupServiceImage = "aerospike.jfrog.io/ecosystem-container-prod-local/aerospike-backup-service:1.0.0" +const BackupServiceImage = "aerospike/aerospike-backup-service:1.0.0" const ( timeout = 2 * time.Minute diff --git a/test/restore/restore_test.go b/test/restore/restore_test.go index 45ee7e02..4f7b7fcc 100644 --- a/test/restore/restore_test.go +++ b/test/restore/restore_test.go @@ -60,7 +60,7 @@ var _ = Describe( err = k8sClient.Update(testCtx, restore) Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("AerospikeRestore Spec is immutable")) + Expect(err.Error()).To(ContainSubstring("aerospikeRestore Spec is immutable")) }) It("Should fail restore when wrong backup path is given", func() { @@ -75,7 +75,7 @@ var _ = Describe( Expect(err).To(HaveOccurred()) }) - It("Should fail when routine/time is not given for TimeStamp restore type", func() { + It("Should fail when routine/time is not given for Timestamp restore type", func() { // getRestoreConfigInMap returns restore config without a routine, time and with source type restoreConfig := getRestoreConfigInMap(backupDataPath) delete(restoreConfig, common.SourceKey) @@ -83,15 +83,15 @@ var _ = Describe( configBytes, mErr := json.Marshal(restoreConfig) Expect(mErr).ToNot(HaveOccurred()) - restore = newRestoreWithConfig(restoreNsNm, asdbv1beta1.TimeStamp, configBytes) + restore = newRestoreWithConfig(restoreNsNm, asdbv1beta1.Timestamp, configBytes) err = createRestore(k8sClient, restore) Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("restore point in time should be positive")) }) - It("Should fail when source field is given for TimeStamp restore type", func() { - restore, err = newRestore(restoreNsNm, asdbv1beta1.TimeStamp) + It("Should fail when source field is given for Timestamp restore type", func() { + restore, err = newRestore(restoreNsNm, asdbv1beta1.Timestamp) Expect(err).ToNot(HaveOccurred()) err = createRestore(k8sClient, restore) @@ -151,7 +151,7 @@ var _ = Describe( ) It( - "Should complete restore for TimeStamp restore type", func() { + "Should complete restore for Timestamp restore type", func() { restoreConfig := getRestoreConfigInMap(backupDataPath) delete(restoreConfig, common.SourceKey) @@ -168,7 +168,7 @@ var _ = Describe( configBytes, err := json.Marshal(restoreConfig) Expect(err).ToNot(HaveOccurred()) - restore = newRestoreWithConfig(restoreNsNm, asdbv1beta1.TimeStamp, configBytes) + restore = newRestoreWithConfig(restoreNsNm, asdbv1beta1.Timestamp, configBytes) err = createRestore(k8sClient, restore) Expect(err).ToNot(HaveOccurred())