Skip to content

Commit 1a3c4b0

Browse files
authored
Improve node-labeler logs (#17087)
Signed-off-by: Manuel de Brito Fontes <[email protected]>
1 parent 4a44f13 commit 1a3c4b0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

components/node-labeler/cmd/podutils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package cmd
77
import corev1 "k8s.io/api/core/v1"
88

99
// IsPodReady returns true if a pod is ready; false otherwise.
10-
func IsPodReady(pod *corev1.Pod) bool {
10+
func IsPodReady(pod corev1.Pod) bool {
1111
return IsPodReadyConditionTrue(pod.Status)
1212
}
1313

components/node-labeler/cmd/run.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (r *PodReconciler) Reconcile(ctx context.Context, req reconcile.Request) (r
194194
return reconcile.Result{}, err
195195
}
196196

197-
if !IsPodReady(&pod) {
197+
if !IsPodReady(pod) {
198198
// not ready. Wait until the next update.
199199
return reconcile.Result{}, nil
200200
}
@@ -285,8 +285,11 @@ func checkRegistryFacade(host, port string) error {
285285
Transport: transport,
286286
}
287287

288+
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
289+
defer cancel()
290+
288291
dummyURL := fmt.Sprintf("https://%v:%v/v2/remote/not-a-valid-image/manifests/latest", host, port)
289-
req, err := http.NewRequest(http.MethodGet, dummyURL, nil)
292+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, dummyURL, nil)
290293
if err != nil {
291294
return fmt.Errorf("building HTTP request: %v", err)
292295
}
@@ -309,7 +312,6 @@ func newDefaultTransport() *http.Transport {
309312
return &http.Transport{
310313
DialContext: (&net.Dialer{
311314
Timeout: 1 * time.Second,
312-
KeepAlive: 1 * time.Second,
313315
DualStack: false,
314316
}).DialContext,
315317
MaxIdleConns: 0,

0 commit comments

Comments
 (0)