Skip to content

Commit

Permalink
Log exporter deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
mangelajo committed Aug 4, 2024
1 parent ca62ca5 commit ab1f1c8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/controller/exporter_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func (r *ExporterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
exporter := &jumpstarterdevv1alpha1.Exporter{}
err := r.Get(ctx, req.NamespacedName, exporter)
if apierrors.IsNotFound(err) {
logger.Info("reconcile: Exporter deleted", "exporter", req.NamespacedName)
// Request object not found, could have been deleted after reconcile request.
// Owned objects are automatically garbage collected. For additional cleanup logic use finalizers.
return reconcile.Result{}, nil
Expand All @@ -73,23 +74,23 @@ func (r *ExporterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
}

if exporter.Spec.Credentials == nil {
logger.Info("reconcile: Exporter has no credentials, creating credentials", "exporter", exporter.GetName())
logger.Info("reconcile: Exporter has no credentials, creating credentials", "exporter", req.NamespacedName)
secret, err := r.secretForExporter(exporter)
if err != nil {
logger.Error(err, "reconcile: unable to create secret for Exporter")
return ctrl.Result{}, err
}
err = r.Create(ctx, secret)
if err != nil {
logger.Error(err, "reconcile: unable to create secret for Exporter", "exporter", exporter.GetName(), "secret", secret.GetName())
logger.Error(err, "reconcile: unable to create secret for Exporter", "exporter", req.NamespacedName, "secret", secret.GetName())
return ctrl.Result{}, err
}
exporter.Spec.Credentials = []corev1.SecretReference{
{Name: secret.Name, Namespace: secret.Namespace},
}
err = r.Update(ctx, exporter)
if err != nil {
logger.Error(err, "reconcile: unable to update Exporter with secret reference", "exporter", exporter.GetName(), "secret", secret.GetName())
logger.Error(err, "reconcile: unable to update Exporter with secret reference", "exporter", req.NamespacedName, "secret", secret.GetName())
return ctrl.Result{}, err
}
}
Expand Down

0 comments on commit ab1f1c8

Please sign in to comment.