From cb271afdc2dc2c34c35b71ed49d31623dab05f85 Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Tue, 6 Feb 2024 16:53:26 +0100 Subject: [PATCH] hack: fix janitor to properly set kubeconfig and log an error --- hack/clean-ci.sh | 3 +++ hack/tools/janitor/main.go | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hack/clean-ci.sh b/hack/clean-ci.sh index 69f0896f21..ad2cc62e6d 100755 --- a/hack/clean-ci.sh +++ b/hack/clean-ci.sh @@ -58,5 +58,8 @@ function wait_for_ipam_reachable() { } wait_for_ipam_reachable +# Set kubeconfig for IPAM cleanup +export KUBECONFIG="${E2E_IPAM_KUBECONFIG}" + # Run e2e tests make clean-ci diff --git a/hack/tools/janitor/main.go b/hack/tools/janitor/main.go index b982bfc833..c0a071ef3a 100644 --- a/hack/tools/janitor/main.go +++ b/hack/tools/janitor/main.go @@ -92,7 +92,10 @@ func run(ctx context.Context) error { defer vSphereClients.logout(ctx) // Create controller-runtime client for IPAM. - restConfig := ctrl.GetConfigOrDie() + restConfig, err := ctrl.GetConfig() + if err != nil { + return errors.Wrap(err, "unable to get kubeconfig") + } ipamClient, err := client.New(restConfig, client.Options{Scheme: ipamScheme}) if err != nil { return errors.Wrap(err, "creating IPAM client")