diff --git a/internal/controller/issuerconfig/publisher.go b/internal/controller/issuerconfig/publisher.go index 0098df02..7d1b862f 100644 --- a/internal/controller/issuerconfig/publisher.go +++ b/internal/controller/issuerconfig/publisher.go @@ -94,7 +94,11 @@ func (c *publisherController) Sync(ctx controller.Context) error { return nil } - config, _ := clientcmd.Load([]byte(kubeConfig)) + config, err := clientcmd.Load([]byte(kubeConfig)) + if err != nil { + klog.InfoS("could not load kubeconfig configmap key") + return nil + } var certificateAuthorityData, server string for _, v := range config.Clusters { diff --git a/internal/controller/issuerconfig/publisher_test.go b/internal/controller/issuerconfig/publisher_test.go index efce518d..79fd87cd 100644 --- a/internal/controller/issuerconfig/publisher_test.go +++ b/internal/controller/issuerconfig/publisher_test.go @@ -436,6 +436,26 @@ func TestSync(t *testing.T) { r.Empty(pinnipedAPIClient.Actions()) }) }) + + when("the ConfigMap does not have a valid kubeconfig", func() { + it.Before(func() { + clusterInfoConfigMap := &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{Name: "cluster-info", Namespace: "kube-public"}, + Data: map[string]string{ + "kubeconfig": "this is an invalid kubeconfig", + }, + } + err := kubeInformerClient.Tracker().Add(clusterInfoConfigMap) + r.NoError(err) + }) + + it("keeps waiting for it to be properly formatted", func() { + startInformersAndController() + err := controller.TestSync(t, subject, *syncContext) + r.NoError(err) + r.Empty(pinnipedAPIClient.Actions()) + }) + }) }) when("there is not a cluster-info ConfigMap in the kube-public namespace", func() {