From 85d806a40daca94748fed2035864354c195512ed Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Tue, 27 Feb 2024 12:20:02 +0100 Subject: [PATCH] foo --- test/framework/clusterctl/clusterctl_helpers.go | 2 +- test/framework/management_cluster_helpers.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/framework/clusterctl/clusterctl_helpers.go b/test/framework/clusterctl/clusterctl_helpers.go index f5ad48a08cd9..d40db505ed98 100644 --- a/test/framework/clusterctl/clusterctl_helpers.go +++ b/test/framework/clusterctl/clusterctl_helpers.go @@ -257,7 +257,7 @@ func UpgradeManagementClusterAndWait(ctx context.Context, input UpgradeManagemen } log.Logf("Waiting for cert-manager to inject the new certificates to webhook relevant objects") - framework.WaitForProviderCAInjection(ctx, client) + framework.WaitForProviderCAInjection(ctx, client, filepath.Join(input.LogFolder, "foo", "crds")) } diff --git a/test/framework/management_cluster_helpers.go b/test/framework/management_cluster_helpers.go index 362801ae86ac..66bc39e87748 100644 --- a/test/framework/management_cluster_helpers.go +++ b/test/framework/management_cluster_helpers.go @@ -18,6 +18,7 @@ package framework import ( "context" + "os" "time" . "github.com/onsi/gomega" @@ -25,6 +26,7 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/yaml" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/test/framework/internal/log" @@ -33,7 +35,7 @@ import ( // WaitForProviderCAInjection tries to query a list of all CRD objects for a provider // to ensure the webhooks are correctly setup, especially that cert-manager did inject // the up-to-date CAs into the relevant objects. -func WaitForProviderCAInjection(ctx context.Context, lister Lister) { +func WaitForProviderCAInjection(ctx context.Context, lister Lister, outpath string) { crdList := &apiextensionsv1.CustomResourceDefinitionList{} Eventually(func() error { return lister.List(ctx, crdList, client.HasLabels{clusterv1.ProviderNameLabel}) @@ -41,8 +43,14 @@ func WaitForProviderCAInjection(ctx context.Context, lister Lister) { for i := range crdList.Items { crd := crdList.Items[i] + data, err := yaml.Marshal(crd) + Expect(err).ToNot(HaveOccurred()) + os.WriteFile(outpath, data, 0600) // Use all versions so we also test conversion webhooks for _, version := range crd.Spec.Versions { + if !version.Served { + continue + } gvk := schema.GroupVersionKind{ Group: crd.Spec.Group, Version: version.Name,