Skip to content

Commit 52c042c

Browse files
author
eliranb
committed
Improve error messages in reconcileDeployment and reconcileStatefulSet functions by including workload names for better debugging clarity.
1 parent b948101 commit 52c042c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/controller/lightrunjavaagent_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (r *LightrunJavaAgentReconciler) reconcileDeployment(ctx context.Context, l
146146
if err != nil {
147147
return r.errorStatus(ctx, lightrunJavaAgent, err)
148148
}
149-
return r.errorStatus(ctx, lightrunJavaAgent, errors.New("deployment not found"))
149+
return r.errorStatus(ctx, lightrunJavaAgent, errors.New("deployment not found: "+deploymentName))
150150
} else {
151151
log.Error(err, "unable to fetch deployment")
152152
return r.errorStatus(ctx, lightrunJavaAgent, err)
@@ -155,7 +155,7 @@ func (r *LightrunJavaAgentReconciler) reconcileDeployment(ctx context.Context, l
155155

156156
if oldLrjaName, ok := originalDeployment.Annotations[annotationAgentName]; ok && oldLrjaName != lightrunJavaAgent.Name {
157157
log.Error(err, "Deployment already patched by LightrunJavaAgent", "Existing LightrunJavaAgent", oldLrjaName)
158-
return r.errorStatus(ctx, lightrunJavaAgent, errors.New("deployment already patched"))
158+
return r.errorStatus(ctx, lightrunJavaAgent, errors.New("deployment already patched: "+deploymentName))
159159
}
160160

161161
deploymentApplyConfig, err := appsv1ac.ExtractDeployment(originalDeployment, fieldManager)
@@ -377,7 +377,7 @@ func (r *LightrunJavaAgentReconciler) reconcileStatefulSet(ctx context.Context,
377377
if err != nil {
378378
return r.errorStatus(ctx, lightrunJavaAgent, err)
379379
}
380-
return r.errorStatus(ctx, lightrunJavaAgent, errors.New("statefulset not found"))
380+
return r.errorStatus(ctx, lightrunJavaAgent, errors.New("statefulset not found: "+statefulSetName))
381381
} else {
382382
log.Error(err, "unable to fetch statefulset")
383383
return r.errorStatus(ctx, lightrunJavaAgent, err)
@@ -466,7 +466,7 @@ func (r *LightrunJavaAgentReconciler) reconcileStatefulSet(ctx context.Context,
466466
// Check if already patched by another LightrunJavaAgent
467467
if oldLrjaName, ok := originalStatefulSet.Annotations[annotationAgentName]; ok && oldLrjaName != lightrunJavaAgent.Name {
468468
log.Error(err, "StatefulSet already patched by LightrunJavaAgent", "Existing LightrunJavaAgent", oldLrjaName)
469-
return r.errorStatus(ctx, lightrunJavaAgent, errors.New("statefulset already patched"))
469+
return r.errorStatus(ctx, lightrunJavaAgent, errors.New("statefulset :"+statefulSetName+" already patched"))
470470
}
471471

472472
// Add finalizer if not already present

0 commit comments

Comments
 (0)