Skip to content

Commit

Permalink
[multikueue] Decrease the number logged errors (kubernetes-sigs#1823)
Browse files Browse the repository at this point in the history
* [multikueue] Decrease the number logged errors

Limit the number and severity of logged errors during
normal operations.

* Review Remarks
  • Loading branch information
trasc authored and vsoch committed Apr 18, 2024
1 parent e525925 commit fc2746e
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions pkg/controller/admissionchecks/multikueue/multikueuecluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"
Expand Down Expand Up @@ -196,11 +197,21 @@ func (rc *remoteClient) startWatcher(ctx context.Context, kind string, w multiKu
go func() {
log.V(2).Info("Starting watch")
for r := range newWatcher.ResultChan() {
wlKey, err := w.GetWorkloadKey(r.Object)
if err != nil {
log.V(2).Error(err, "Cannot get workload key", "jobKind", r.Object.GetObjectKind().GroupVersionKind())
} else {
rc.queueWorkloadEvent(ctx, wlKey)
switch r.Type {
case watch.Error:
switch s := r.Object.(type) {
case *metav1.Status:
log.V(3).Info("Watch error", "status", s.Status, "message", s.Message, "reason", s.Reason)
default:
log.V(3).Info("Watch error with unexpected type", "type", fmt.Sprintf("%T", s))
}
default:
wlKey, err := w.GetWorkloadKey(r.Object)
if err != nil {
log.V(2).Error(err, "Cannot get workload key", "jobKind", r.Object.GetObjectKind().GroupVersionKind())
} else {
rc.queueWorkloadEvent(ctx, wlKey)
}
}
}
log.V(2).Info("Watch ended", "ctxErr", ctx.Err())
Expand Down

0 comments on commit fc2746e

Please sign in to comment.