Skip to content

Commit 61c0ddd

Browse files
authored
minor logging improvements (#148)
1 parent 5bee10e commit 61c0ddd

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

internal/controller/appwrapper/appwrapper_controller.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func (r *AppWrapperReconciler) Reconcile(ctx context.Context, req ctrl.Request)
137137
if err := r.Update(ctx, aw); err != nil {
138138
return ctrl.Result{}, err
139139
}
140-
log.FromContext(ctx).Info("Deleted")
140+
log.FromContext(ctx).Info("Finalizer Deleted")
141141
}
142142
}
143143
return ctrl.Result{}, nil
@@ -526,7 +526,7 @@ func (r *AppWrapperReconciler) admissionGraceDuration(ctx context.Context, aw *w
526526
if duration, err := time.ParseDuration(userPeriod); err == nil {
527527
return r.limitDuration(duration)
528528
} else {
529-
log.FromContext(ctx).Info("Malformed admission grace period annotation", "annotation", userPeriod, "error", err)
529+
log.FromContext(ctx).Error(err, "Malformed admission grace period annotation; using default", "annotation", userPeriod)
530530
}
531531
}
532532
return r.limitDuration(r.Config.FaultTolerance.AdmissionGracePeriod)
@@ -537,7 +537,7 @@ func (r *AppWrapperReconciler) warmupGraceDuration(ctx context.Context, aw *work
537537
if duration, err := time.ParseDuration(userPeriod); err == nil {
538538
return r.limitDuration(duration)
539539
} else {
540-
log.FromContext(ctx).Info("Malformed warmup grace period annotation", "annotation", userPeriod, "error", err)
540+
log.FromContext(ctx).Error(err, "Malformed warmup grace period annotation; using default", "annotation", userPeriod)
541541
}
542542
}
543543
return r.limitDuration(r.Config.FaultTolerance.WarmupGracePeriod)
@@ -548,7 +548,7 @@ func (r *AppWrapperReconciler) failureGraceDuration(ctx context.Context, aw *wor
548548
if duration, err := time.ParseDuration(userPeriod); err == nil {
549549
return r.limitDuration(duration)
550550
} else {
551-
log.FromContext(ctx).Info("Malformed grace period annotation", "annotation", userPeriod, "error", err)
551+
log.FromContext(ctx).Error(err, "Malformed failure grace period annotation; using default", "annotation", userPeriod)
552552
}
553553
}
554554
return r.limitDuration(r.Config.FaultTolerance.FailureGracePeriod)
@@ -559,7 +559,7 @@ func (r *AppWrapperReconciler) retryLimit(ctx context.Context, aw *workloadv1bet
559559
if limit, err := strconv.Atoi(userLimit); err == nil {
560560
return int32(limit)
561561
} else {
562-
log.FromContext(ctx).Info("Malformed retry limit annotation", "annotation", userLimit, "error", err)
562+
log.FromContext(ctx).Error(err, "Malformed retry limit annotation; using default", "annotation", userLimit)
563563
}
564564
}
565565
return r.Config.FaultTolerance.RetryLimit
@@ -570,7 +570,7 @@ func (r *AppWrapperReconciler) retryPauseDuration(ctx context.Context, aw *workl
570570
if duration, err := time.ParseDuration(userPeriod); err == nil {
571571
return r.limitDuration(duration)
572572
} else {
573-
log.FromContext(ctx).Info("Malformed retry pause annotation", "annotation", userPeriod, "error", err)
573+
log.FromContext(ctx).Error(err, "Malformed retry pause annotation; using default", "annotation", userPeriod)
574574
}
575575
}
576576
return r.limitDuration(r.Config.FaultTolerance.RetryPausePeriod)
@@ -581,7 +581,7 @@ func (r *AppWrapperReconciler) forcefulDeletionGraceDuration(ctx context.Context
581581
if duration, err := time.ParseDuration(userPeriod); err == nil {
582582
return r.limitDuration(duration)
583583
} else {
584-
log.FromContext(ctx).Info("Malformed forceful deletion period annotation", "annotation", userPeriod, "error", err)
584+
log.FromContext(ctx).Error(err, "Malformed forceful deletion period annotation; using default", "annotation", userPeriod)
585585
}
586586
}
587587
return r.limitDuration(r.Config.FaultTolerance.ForcefulDeletionGracePeriod)
@@ -592,7 +592,7 @@ func (r *AppWrapperReconciler) deletionOnFailureGraceDuration(ctx context.Contex
592592
if duration, err := time.ParseDuration(userPeriod); err == nil {
593593
return r.limitDuration(duration)
594594
} else {
595-
log.FromContext(ctx).Info("Malformed delection on failue delay annotation", "annotation", userPeriod, "error", err)
595+
log.FromContext(ctx).Error(err, "Malformed deletion on failure grace period annotation; using default of 0", "annotation", userPeriod)
596596
}
597597
}
598598
return 0 * time.Second
@@ -605,7 +605,7 @@ func (r *AppWrapperReconciler) timeToLiveAfterSucceededDuration(ctx context.Cont
605605
return duration
606606
}
607607
} else {
608-
log.FromContext(ctx).Info("Malformed successTTL annotation", "annotation", userPeriod, "error", err)
608+
log.FromContext(ctx).Error(err, "Malformed successTTL annotation; using default", "annotation", userPeriod)
609609
}
610610
}
611611
return r.Config.FaultTolerance.SuccessTTL

internal/webhook/appwrapper_webhook.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ var _ webhook.CustomDefaulter = &AppWrapperWebhook{}
6868
// 3. Add labels with the user name and id
6969
func (w *AppWrapperWebhook) Default(ctx context.Context, obj runtime.Object) error {
7070
aw := obj.(*workloadv1beta2.AppWrapper)
71-
log.FromContext(ctx).Info("Applying defaults", "job", aw)
71+
log.FromContext(ctx).V(2).Info("Applying defaults", "job", aw)
7272

7373
// Queue name and Suspend
7474
if w.Config.EnableKueueIntegrations {
@@ -97,7 +97,7 @@ var _ webhook.CustomValidator = &AppWrapperWebhook{}
9797
// ValidateCreate validates invariants when an AppWrapper is created
9898
func (w *AppWrapperWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
9999
aw := obj.(*workloadv1beta2.AppWrapper)
100-
log.FromContext(ctx).Info("Validating create", "job", aw)
100+
log.FromContext(ctx).V(2).Info("Validating create", "job", aw)
101101
allErrors := w.validateAppWrapperCreate(ctx, aw)
102102
if w.Config.EnableKueueIntegrations {
103103
allErrors = append(allErrors, jobframework.ValidateCreateForQueueName((*wlc.AppWrapper)(aw))...)
@@ -109,7 +109,7 @@ func (w *AppWrapperWebhook) ValidateCreate(ctx context.Context, obj runtime.Obje
109109
func (w *AppWrapperWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) (admission.Warnings, error) {
110110
oldAW := oldObj.(*workloadv1beta2.AppWrapper)
111111
newAW := newObj.(*workloadv1beta2.AppWrapper)
112-
log.FromContext(ctx).Info("Validating update", "job", newAW)
112+
log.FromContext(ctx).V(2).Info("Validating update", "job", newAW)
113113
allErrors := w.validateAppWrapperUpdate(oldAW, newAW)
114114
if w.Config.EnableKueueIntegrations {
115115
allErrors = append(allErrors, jobframework.ValidateUpdateForQueueName((*wlc.AppWrapper)(oldAW), (*wlc.AppWrapper)(newAW))...)

0 commit comments

Comments
 (0)