Skip to content

Commit

Permalink
Incorporate requested changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwalantmodi05 committed Dec 4, 2024
1 parent 694f467 commit a26e75e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
16 changes: 16 additions & 0 deletions internal/controller/backup-service/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ func (r *SingleBackupServiceReconciler) reconcileConfigMap() error {

r.Log.Info("Created new Backup Service ConfigMap",
"name", getBackupServiceName(r.aeroBackupService))
r.Recorder.Eventf(r.aeroBackupService, corev1.EventTypeNormal, "ConfigMapCreated",
"Created new Backup Service ConfigMap %s/%s", r.aeroBackupService.Namespace, r.aeroBackupService.Name)

return nil
}
Expand Down Expand Up @@ -213,6 +215,8 @@ func (r *SingleBackupServiceReconciler) reconcileConfigMap() error {

r.Log.Info("Updated Backup Service ConfigMap",
"name", getBackupServiceName(r.aeroBackupService))
r.Recorder.Eventf(r.aeroBackupService, corev1.EventTypeNormal, "ConfigMapUpdated",
"Updated Backup Service ConfigMap %s/%s", r.aeroBackupService.Namespace, r.aeroBackupService.Name)

return nil
}
Expand Down Expand Up @@ -258,6 +262,11 @@ func (r *SingleBackupServiceReconciler) reconcileDeployment() error {
return fmt.Errorf("failed to deploy Backup service deployment: %v", err)
}

r.Log.Info("Created Backup Service deployment",
"name", getBackupServiceName(r.aeroBackupService))
r.Recorder.Eventf(r.aeroBackupService, corev1.EventTypeNormal, "DeploymentCreated",
"Created Backup Service Deployment %s/%s", r.aeroBackupService.Namespace, r.aeroBackupService.Name)

return r.waitForDeploymentToBeReady()
}

Expand Down Expand Up @@ -508,6 +517,11 @@ func (r *SingleBackupServiceReconciler) reconcileService() error {
return fmt.Errorf("failed to create Backup Service: %v", err)
}

r.Log.Info("Created Backup Service",
"name", getBackupServiceName(r.aeroBackupService))
r.Recorder.Eventf(r.aeroBackupService, corev1.EventTypeNormal, "ServiceCreated",
"Created Backup Service %s/%s", r.aeroBackupService.Namespace, r.aeroBackupService.Name)

return nil
}

Expand All @@ -528,6 +542,8 @@ func (r *SingleBackupServiceReconciler) reconcileService() error {
}

r.Log.Info("Updated Backup Service", "name", getBackupServiceName(r.aeroBackupService))
r.Recorder.Eventf(r.aeroBackupService, corev1.EventTypeNormal, "ServiceUpdated",
"Updated Backup Service %s/%s", r.aeroBackupService.Namespace, r.aeroBackupService.Name)

return nil
}
Expand Down
11 changes: 9 additions & 2 deletions internal/controller/backup/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ 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)
"ConfigMapReconcileFailed", "Failed to reconcile config map %s",
r.aeroBackup.Spec.BackupService.String())

return reconcile.Result{}, err
}
Expand Down Expand Up @@ -216,6 +216,9 @@ func (r *SingleBackupReconciler) reconcileConfigMap() error {
r.Log.Info("Updated Backup Service ConfigMap for Backup",
"name", r.aeroBackup.Spec.BackupService.String(),
)
r.Recorder.Eventf(r.aeroBackup, corev1.EventTypeNormal, "ConfigMapUpdated",
"Updated Backup Service ConfigMap %s for Backup %s/%s", r.aeroBackup.Spec.BackupService.String(),
r.aeroBackup.Namespace, r.aeroBackup.Name)

return nil
}
Expand Down Expand Up @@ -326,6 +329,8 @@ 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.Recorder.Eventf(r.aeroBackup, corev1.EventTypeNormal, "BackupScheduled",
"Scheduled on-demand backup %s/%s", r.aeroBackup.Namespace, r.aeroBackup.Name)

r.Log.Info("Reconciled on-demand backup")

Expand Down Expand Up @@ -439,6 +444,8 @@ func (r *SingleBackupReconciler) reconcileScheduledBackup() error {
}

r.Log.Info("Reconciled scheduled backup")
r.Recorder.Eventf(r.aeroBackup, corev1.EventTypeNormal, "BackupReconciled",
"Reconciled scheduled backup %s/%s", r.aeroBackup.Namespace, r.aeroBackup.Name)

return nil
}
Expand Down
5 changes: 5 additions & 0 deletions internal/controller/restore/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ func (r *SingleRestoreReconciler) reconcileRestore() common.ReconcileResult {
return common.ReconcileError(err)
}

r.Recorder.Eventf(r.aeroRestore, corev1.EventTypeNormal, "RestoreTriggered",
"Triggered restore %s/%s", r.aeroRestore.Namespace, r.aeroRestore.Name)

r.aeroRestore.Status.JobID = jobID

if err = r.Client.Status().Update(context.Background(), r.aeroRestore); err != nil {
Expand All @@ -147,6 +150,8 @@ func (r *SingleRestoreReconciler) checkRestoreStatus() error {
}

r.Log.Info(fmt.Sprintf("Restore status: %+v", restoreStatus))
r.Recorder.Eventf(r.aeroRestore, corev1.EventTypeNormal, "RestoreStatus",
"Restore status: %+v", restoreStatus)

if status, ok := restoreStatus["status"]; ok {
r.aeroRestore.Status.Phase = statusToPhase(status.(string))
Expand Down

0 comments on commit a26e75e

Please sign in to comment.