Skip to content

Commit

Permalink
fix some logs
Browse files Browse the repository at this point in the history
Signed-off-by: AiRanthem <[email protected]>
  • Loading branch information
AiRanthem committed Dec 25, 2024
1 parent 5faf642 commit cda1e9b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
11 changes: 5 additions & 6 deletions pkg/controller/workloadspread/workloadspread_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ func (r *ReconcileWorkloadSpread) getReplicasPathList(ws *appsv1alpha1.WorkloadS
return nil, nil
}

Check warning on line 282 in pkg/controller/workloadspread/workloadspread_controller.go

View check run for this annotation

Codecov / codecov/patch

pkg/controller/workloadspread/workloadspread_controller.go#L281-L282

Added lines #L281 - L282 were not covered by tests
if ws.Spec.TargetFilter != nil && len(ws.Spec.TargetFilter.ReplicasPathList) > 0 {
klog.V(5).InfoS("found replicas path list in target filter", "replicasPathList", ws.Spec.TargetFilter.ReplicasPathList, "workloadSpread", klog.KObj(ws))
return ws.Spec.TargetFilter.ReplicasPathList, nil
}
whiteList, err := configuration.GetWSWatchCustomWorkloadWhiteList(r.Client)
Expand Down Expand Up @@ -335,7 +334,7 @@ func (r *ReconcileWorkloadSpread) getPodsForWorkloadSpread(ws *appsv1alpha1.Work
}

func (r *ReconcileWorkloadSpread) filterWorkload(ws *appsv1alpha1.WorkloadSpread, pods []*corev1.Pod, replicas int32) (int32, []*corev1.Pod, error) {
klog.V(5).InfoS("before workload filtering", "pods", len(pods), "replicas", replicas)
klog.V(5).InfoS("before workload filtering", "pods", len(pods), "replicas", replicas, "workloadSpread", klog.KObj(ws))
replicasPathList, err := r.getReplicasPathList(ws)
if err != nil {
return replicas, pods, err
Expand All @@ -359,10 +358,11 @@ func (r *ReconcileWorkloadSpread) filterWorkload(ws *appsv1alpha1.WorkloadSpread
}

Check warning on line 358 in pkg/controller/workloadspread/workloadspread_controller.go

View check run for this annotation

Codecov / codecov/patch

pkg/controller/workloadspread/workloadspread_controller.go#L357-L358

Added lines #L357 - L358 were not covered by tests
filteredReplicas += n
}
klog.V(4).InfoS("replicas after filtering", "replicas", filteredReplicas, "replicasPathList", replicasPathList)
klog.V(4).InfoS("replicas after filtering", "replicas", filteredReplicas,
"replicasPathList", replicasPathList, "workloadSpread", klog.KObj(ws))
} else {
filteredReplicas = replicas
klog.V(4).InfoS("replicas not filtered")
klog.V(4).InfoS("replicas not filtered", "workloadSpread", klog.KObj(ws))
}
var filteredPods []*corev1.Pod
if ws.Spec.TargetFilter != nil && ws.Spec.TargetFilter.Selector != nil {
Expand All @@ -378,7 +378,6 @@ func (r *ReconcileWorkloadSpread) filterWorkload(ws *appsv1alpha1.WorkloadSpread
klog.V(4).InfoS("pods after filtering", "pods", len(filteredPods), "selector", ws.Spec.TargetFilter.Selector)
} else {
filteredPods = pods
klog.V(4).InfoS("pods not filtered")
}
return filteredReplicas, filteredPods, nil
}
Expand All @@ -391,7 +390,7 @@ func (r *ReconcileWorkloadSpread) filterWorkload(ws *appsv1alpha1.WorkloadSpread
// mainly counts missingReplicas and records the creation or deletion entry of Pod into map.
func (r *ReconcileWorkloadSpread) syncWorkloadSpread(ws *appsv1alpha1.WorkloadSpread) error {
if ws.Spec.TargetReference == nil {
klog.InfoS("WorkloadSpread has no target reference")
klog.InfoS("WorkloadSpread has no target reference", "workloadSpread", klog.KObj(ws))
return nil
}

Check warning on line 395 in pkg/controller/workloadspread/workloadspread_controller.go

View check run for this annotation

Codecov / codecov/patch

pkg/controller/workloadspread/workloadspread_controller.go#L393-L395

Added lines #L393 - L395 were not covered by tests
pods, workloadReplicas, err := r.getPodsForWorkloadSpread(ws)
Expand Down
2 changes: 0 additions & 2 deletions pkg/util/controllerfinder/controller_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
scaleclient "k8s.io/client-go/scale"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"
)
Expand Down Expand Up @@ -516,7 +515,6 @@ func (r *ControllerFinder) getRefUID(ref ControllerReference, namespace string)
if err != nil {
return nil, client.IgnoreNotFound(err)
}
klog.V(5).InfoS("get ref UID success", "uid", un.GetUID(), "ref", klog.KObj(un))
return &ScaleAndSelector{
Scale: ReplicasUnknown,
ControllerReference: ControllerReference{
Expand Down
7 changes: 5 additions & 2 deletions pkg/util/controllerfinder/pods_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllerfinder

import (
"context"
"fmt"

"github.com/openkruise/kruise/pkg/util"
utilclient "github.com/openkruise/kruise/pkg/util/client"
Expand Down Expand Up @@ -91,7 +92,8 @@ func (r *ControllerFinder) GetPodsForRef(apiVersion, kind, ns, name string, acti
labelSelector = obj.Selector
workloadUIDs = append(workloadUIDs, obj.UID)
}
klog.V(5).InfoS("find pods and replicas result", "workloadReplicas", workloadReplicas, "workloadUIDs", workloadUIDs, "labelSelector", labelSelector)
klog.V(5).InfoS("find pods and replicas result", "target", fmt.Sprintf("%s/%s", ns, name), "kind", kind,
"workloadReplicas", workloadReplicas, "workloadUIDs", workloadUIDs, "labelSelector", labelSelector)

Check warning on line 96 in pkg/util/controllerfinder/pods_finder.go

View check run for this annotation

Codecov / codecov/patch

pkg/util/controllerfinder/pods_finder.go#L95-L96

Added lines #L95 - L96 were not covered by tests
if workloadReplicas == 0 {
return nil, workloadReplicas, nil
}
Expand Down Expand Up @@ -121,7 +123,8 @@ func (r *ControllerFinder) GetPodsForRef(apiVersion, kind, ns, name string, acti
FieldSelector: fields.SelectorFromSet(fields.Set{fieldindex.IndexNameForOwnerRefUID: string(uid)}),
}
pods, err := listPods(&listOption)
klog.V(5).InfoS("result of list pods with owner ref uid", "pods", len(pods), "err", err, "refUid", uid)
klog.V(5).InfoS("result of list pods with owner ref uid",
"target", fmt.Sprintf("%s/%s", ns, name), "kind", kind, "pods", len(pods), "err", err, "refUid", uid)

Check warning on line 127 in pkg/util/controllerfinder/pods_finder.go

View check run for this annotation

Codecov / codecov/patch

pkg/util/controllerfinder/pods_finder.go#L126-L127

Added lines #L126 - L127 were not covered by tests
if err != nil {
return nil, -1, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/workloadspread/utils.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 The Kruise Authors.
Copyright 2024 The Kruise Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down

0 comments on commit cda1e9b

Please sign in to comment.