Skip to content

Commit 0f9475c

Browse files
committed
Create a request with a context timeout
Signed-off-by: Manuel de Brito Fontes <[email protected]>
1 parent 63c8081 commit 0f9475c

File tree

1 file changed

+4
-1
lines changed
  • components/node-labeler/cmd

1 file changed

+4
-1
lines changed

components/node-labeler/cmd/run.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,11 @@ func checkRegistryFacade(host, port string) error {
292292
Transport: transport,
293293
}
294294

295+
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
296+
defer cancel()
297+
295298
dummyURL := fmt.Sprintf("https://%v:%v/v2/remote/not-a-valid-image/manifests/latest", host, port)
296-
req, err := http.NewRequest(http.MethodGet, dummyURL, nil)
299+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, dummyURL, nil)
297300
if err != nil {
298301
return fmt.Errorf("building HTTP request: %v", err)
299302
}

0 commit comments

Comments
 (0)