diff --git a/internal/controller/backup-service/reconciler.go b/internal/controller/backup-service/reconciler.go index 258ad2ec..c4e10cca 100644 --- a/internal/controller/backup-service/reconciler.go +++ b/internal/controller/backup-service/reconciler.go @@ -63,6 +63,12 @@ func (r *SingleBackupServiceReconciler) Reconcile() (result ctrl.Result, recErr }() if !r.aeroBackupService.ObjectMeta.DeletionTimestamp.IsZero() { + r.Log.Info("Deleted AerospikeBackupService") + r.Recorder.Eventf( + r.aeroBackupService, corev1.EventTypeNormal, "Deleted", + "Deleted AerospikeBackupService %s/%s", r.aeroBackupService.Namespace, + r.aeroBackupService.Name, + ) // Stop reconciliation as the Aerospike Backup service is being deleted return reconcile.Result{}, nil } @@ -73,21 +79,44 @@ func (r *SingleBackupServiceReconciler) Reconcile() (result ctrl.Result, recErr } if err := r.reconcileConfigMap(); err != nil { + r.Log.Error(err, "Failed to reconcile config map") + r.Recorder.Eventf(r.aeroBackupService, corev1.EventTypeWarning, + "ConfigMapReconcileFailed", "Failed to reconcile config map %s/%s", + r.aeroBackupService.Namespace, r.aeroBackupService.Name) + recErr = err + return ctrl.Result{}, err } if err := r.reconcileDeployment(); err != nil { + r.Log.Error(err, "Failed to reconcile deployment") + r.Recorder.Eventf(r.aeroBackupService, corev1.EventTypeWarning, + "DeploymentReconcileFailed", "Failed to reconcile deployment %s/%s", + r.aeroBackupService.Namespace, r.aeroBackupService.Name) + recErr = err + return ctrl.Result{}, err } if err := r.reconcileService(); err != nil { + r.Log.Error(err, "Failed to reconcile service") + r.Recorder.Eventf(r.aeroBackupService, corev1.EventTypeWarning, + "ServiceReconcileFailed", "Failed to reconcile service %s/%s", + r.aeroBackupService.Namespace, r.aeroBackupService.Name) + recErr = err + return ctrl.Result{}, err } if err := r.updateStatus(); err != nil { + r.Log.Error(err, "Failed to update status") + r.Recorder.Eventf(r.aeroBackupService, corev1.EventTypeWarning, + "StatusUpdateFailed", "Failed to update AerospikeBackupService status %s/%s", + r.aeroBackupService.Namespace, r.aeroBackupService.Name) + return ctrl.Result{}, err } diff --git a/internal/controller/backup/reconciler.go b/internal/controller/backup/reconciler.go index fbe48454..fec03c29 100644 --- a/internal/controller/backup/reconciler.go +++ b/internal/controller/backup/reconciler.go @@ -42,6 +42,12 @@ func (r *SingleBackupReconciler) Reconcile() (result ctrl.Result, recErr error) return reconcile.Result{}, err } + r.Log.Info("Deleted AerospikeBackup") + r.Recorder.Eventf( + r.aeroBackup, corev1.EventTypeNormal, "Deleted", + "Deleted AerospikeBackup %s/%s", r.aeroBackup.Namespace, + r.aeroBackup.Name, + ) // Stop reconciliation as the backup is being deleted return reconcile.Result{}, nil } @@ -54,16 +60,28 @@ func (r *SingleBackupReconciler) Reconcile() (result ctrl.Result, recErr error) if err := r.reconcileConfigMap(); err != nil { r.Log.Error(err, "Failed to reconcile config map") + r.Recorder.Eventf(r.aeroBackup, corev1.EventTypeWarning, + "ConfigMapReconcileFailed", "Failed to reconcile config map %s/%s", + r.aeroBackup.Namespace, r.aeroBackup.Name) + return reconcile.Result{}, err } if err := r.reconcileBackup(); err != nil { r.Log.Error(err, "Failed to reconcile backup") + r.Recorder.Eventf(r.aeroBackup, corev1.EventTypeWarning, + "BackupReconcileFailed", "Failed to reconcile backup %s/%s", + r.aeroBackup.Namespace, r.aeroBackup.Name) + return reconcile.Result{}, err } if err := r.updateStatus(); err != nil { r.Log.Error(err, "Failed to update status") + r.Recorder.Eventf(r.aeroBackup, corev1.EventTypeWarning, + "StatusUpdateFailed", "Failed to update AerospikeBackup status %s/%s", + r.aeroBackup.Namespace, r.aeroBackup.Name) + return reconcile.Result{}, err } @@ -309,7 +327,7 @@ func (r *SingleBackupReconciler) scheduleOnDemandBackup() error { r.Log.Info("Scheduled on-demand backup", "ID", r.aeroBackup.Spec.OnDemandBackups[0].ID, "routine", r.aeroBackup.Spec.OnDemandBackups[0].RoutineName) - r.Log.Info("Reconciled scheduled backup") + r.Log.Info("Reconciled on-demand backup") return nil } diff --git a/internal/controller/restore/reconciler.go b/internal/controller/restore/reconciler.go index 435cd994..b54ec130 100644 --- a/internal/controller/restore/reconciler.go +++ b/internal/controller/restore/reconciler.go @@ -7,6 +7,7 @@ import ( "net/http" "github.com/go-logr/logr" + corev1 "k8s.io/api/core/v1" k8sRuntime "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/rest" "k8s.io/client-go/tools/record" @@ -31,6 +32,12 @@ type SingleRestoreReconciler struct { func (r *SingleRestoreReconciler) Reconcile() (result ctrl.Result, recErr error) { if !r.aeroRestore.ObjectMeta.DeletionTimestamp.IsZero() { + r.Log.Info("Deleted AerospikeRestore") + r.Recorder.Eventf( + r.aeroRestore, corev1.EventTypeNormal, "Deleted", + "Deleted AerospikeRestore %s/%s", r.aeroRestore.Namespace, + r.aeroRestore.Name, + ) // Stop reconciliation as the Aerospike restore is being deleted return reconcile.Result{}, nil } @@ -41,6 +48,10 @@ func (r *SingleRestoreReconciler) Reconcile() (result ctrl.Result, recErr error) if res := r.reconcileRestore(); !res.IsSuccess { if res.Err != nil { + r.Log.Error(res.Err, "Failed to reconcile restore") + r.Recorder.Eventf(r.aeroRestore, corev1.EventTypeWarning, "RestoreReconcileFailed", + "Failed to reconcile restore %s/%s", r.aeroRestore.Namespace, r.aeroRestore.Name) + return res.Result, res.Err } @@ -48,6 +59,10 @@ func (r *SingleRestoreReconciler) Reconcile() (result ctrl.Result, recErr error) } if err := r.checkRestoreStatus(); err != nil { + r.Log.Error(err, "Failed to check restore status") + r.Recorder.Eventf(r.aeroRestore, corev1.EventTypeWarning, "CheckStatusFailed", + "Failed to check restore status %s/%s", r.aeroRestore.Namespace, r.aeroRestore.Name) + return ctrl.Result{}, err }