diff --git a/test/e2e/clusterctl_upgrade.go b/test/e2e/clusterctl_upgrade.go index 6e21ef75fedf..65e97f4d07b9 100644 --- a/test/e2e/clusterctl_upgrade.go +++ b/test/e2e/clusterctl_upgrade.go @@ -447,6 +447,9 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg }) Expect(workloadClusterTemplate).ToNot(BeNil(), "Failed to get the cluster template") + log.Logf("Applying the cluster template yaml to the cluster in dry-run") + Eventually(managementClusterProxy.CreateOrUpdate(ctx, workloadClusterTemplate, framework.WithCreateOpts([]client.CreateOption{client.DryRunAll}...), framework.WithUpdateOpts([]client.UpdateOption{client.DryRunAll}...)), "1m", "10s").ShouldNot(HaveOccurred()) + log.Logf("Applying the cluster template yaml to the cluster") Expect(managementClusterProxy.CreateOrUpdate(ctx, workloadClusterTemplate)).To(Succeed()) diff --git a/test/framework/cluster_proxy.go b/test/framework/cluster_proxy.go index 88e25f5355bf..3dc92278dc1a 100644 --- a/test/framework/cluster_proxy.go +++ b/test/framework/cluster_proxy.go @@ -109,6 +109,8 @@ type ClusterProxy interface { // createOrUpdateConfig contains options for use with CreateOrUpdate. type createOrUpdateConfig struct { labelSelector labels.Selector + createOpts []client.CreateOption + updateOpts []client.UpdateOption } // CreateOrUpdateOption is a configuration option supplied to CreateOrUpdate. @@ -121,6 +123,20 @@ func WithLabelSelector(labelSelector labels.Selector) CreateOrUpdateOption { } } +// WithCreateOpts allows definition of the Create options to be used in resource Create. +func WithCreateOpts(createOpts ...client.CreateOption) CreateOrUpdateOption { + return func(c *createOrUpdateConfig) { + c.createOpts = createOpts + } +} + +// WithUpdateOpts allows definition of the Update options to be used in resource Update. +func WithUpdateOpts(updateOpts ...client.UpdateOption) CreateOrUpdateOption { + return func(c *createOrUpdateConfig) { + c.updateOpts = updateOpts + } +} + // ClusterLogCollector defines an object that can collect logs from a machine. type ClusterLogCollector interface { // CollectMachineLog collects log from a machine. @@ -320,7 +336,7 @@ func (p *clusterProxy) CreateOrUpdate(ctx context.Context, resources []byte, opt if err := p.GetClient().Get(ctx, objectKey, existingObject); err != nil { // Expected error -- if the object does not exist, create it if apierrors.IsNotFound(err) { - if err := p.GetClient().Create(ctx, &o); err != nil { + if err := p.GetClient().Create(ctx, &o, config.createOpts...); err != nil { retErrs = append(retErrs, err) } } else { @@ -328,7 +344,7 @@ func (p *clusterProxy) CreateOrUpdate(ctx context.Context, resources []byte, opt } } else { o.SetResourceVersion(existingObject.GetResourceVersion()) - if err := p.GetClient().Update(ctx, &o); err != nil { + if err := p.GetClient().Update(ctx, &o, config.updateOpts...); err != nil { retErrs = append(retErrs, err) } }