Skip to content

Commit 5e62dcf

Browse files
authored
Merge pull request #10609 from sbueringer/pr-improv-clusterctl-upgrade
🌱 Drop support for INIT env variables in clusterctl upgrade test
2 parents ae096cd + 3ab03f9 commit 5e62dcf

File tree

2 files changed

+12
-28
lines changed

2 files changed

+12
-28
lines changed

docs/book/src/developer/providers/migrations/v1.7-to-v1.8.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ maintainers of providers and consumers of our Go API.
1717

1818
### Other
1919

20+
- The support for INIT env variables was dropped in the clusterctl upgrade tests. If you were using `INIT_WITH_BINARY`,
21+
`INIT_WITH_PROVIDERS_CONTRACT` or `INIT_WITH_KUBERNETES_VERSION` consider using the corresponding fields in `ClusterctlUpgradeSpecInput`.
22+
If you prefer to use environment variables, read them e.g. via `os.Getenv` and then set the spec fields accordingly.
23+
2024
### Suggested changes for providers
2125

2226
- From Cluster API v1.7 the manager pods are created with `terminationMessagePolicy` set to `FallbackToLogsOnError` for the manager container. This offers the chance that the pod's termination message will contain something useful if the manager exits unexpectedly, which in turn makes debugging easier. We also recommend this setting to provider managers. For an example, see the corresponding change in [CAPV](https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/pull/2988) or [CAPO](https://github.com/kubernetes-sigs/cluster-api-provider-openstack/pull/2070).

test/e2e/clusterctl_upgrade.go

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,18 @@ import (
5555
"sigs.k8s.io/cluster-api/util"
5656
)
5757

58-
const (
59-
initWithBinaryVariableName = "INIT_WITH_BINARY"
60-
initWithProvidersContract = "INIT_WITH_PROVIDERS_CONTRACT"
61-
initWithKubernetesVersion = "INIT_WITH_KUBERNETES_VERSION"
62-
)
63-
6458
// ClusterctlUpgradeSpecInput is the input for ClusterctlUpgradeSpec.
6559
type ClusterctlUpgradeSpecInput struct {
6660
E2EConfig *clusterctl.E2EConfig
6761
ClusterctlConfigPath string
6862
BootstrapClusterProxy framework.ClusterProxy
6963
ArtifactFolder string
70-
// InitWithBinary can be used to override the INIT_WITH_BINARY e2e config variable with the URL of the clusterctl binary of the old version of Cluster API. The spec will interpolate the
64+
// InitWithBinary must be used to specify the URL of the clusterctl binary of the old version of Cluster API. The spec will interpolate the
7165
// strings `{OS}` and `{ARCH}` to `runtime.GOOS` and `runtime.GOARCH` respectively, e.g. https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.3.23/clusterctl-{OS}-{ARCH}
7266
InitWithBinary string
73-
// InitWithProvidersContract can be used to override the INIT_WITH_PROVIDERS_CONTRACT e2e config variable with a specific
74-
// provider contract to use to initialise the secondary management cluster, e.g. `v1alpha3`
67+
// InitWithProvidersContract can be used to set the contract used to initialise the secondary management cluster, e.g. `v1alpha3`
7568
InitWithProvidersContract string
76-
// InitWithKubernetesVersion can be used to override the INIT_WITH_KUBERNETES_VERSION e2e config variable with a specific
77-
// Kubernetes version to use to create the secondary management cluster, e.g. `v1.25.0`
69+
// InitWithKubernetesVersion must be used to set a Kubernetes version to use to create the secondary management cluster, e.g. `v1.25.0`
7870
InitWithKubernetesVersion string
7971
// InitWithCoreProvider specifies the core provider version to use when initializing the secondary management cluster, e.g. `cluster-api:v1.3.0`.
8072
// If not set, the core provider version is calculated based on the contract.
@@ -164,7 +156,7 @@ type ClusterctlUpgradeSpecInputUpgrade struct {
164156
// then run clusterctl upgrade to the latest version of Cluster API and ensure correct operation by
165157
// scaling a MachineDeployment.
166158
//
167-
// To use this spec the variables INIT_WITH_BINARY and INIT_WITH_PROVIDERS_CONTRACT must be set or specified directly
159+
// To use this spec the fields InitWithBinary and InitWithKubernetesVersion must be specified
168160
// in the spec input. See ClusterctlUpgradeSpecInput for further information.
169161
//
170162
// In order to get this to work, infrastructure providers need to implement a mechanism to stage
@@ -210,34 +202,22 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
210202
Expect(input.E2EConfig).ToNot(BeNil(), "Invalid argument. input.E2EConfig can't be nil when calling %s spec", specName)
211203
Expect(input.ClusterctlConfigPath).To(BeAnExistingFile(), "Invalid argument. input.ClusterctlConfigPath must be an existing file when calling %s spec", specName)
212204
Expect(input.BootstrapClusterProxy).ToNot(BeNil(), "Invalid argument. input.BootstrapClusterProxy can't be nil when calling %s spec", specName)
205+
Expect(input.InitWithBinary).ToNot(BeEmpty(), "Invalid argument. input.InitWithBinary can't be empty when calling %s spec", specName)
206+
Expect(input.InitWithKubernetesVersion).ToNot(BeEmpty(), "Invalid argument. input.InitWithKubernetesVersion can't be empty when calling %s spec", specName)
213207

214208
clusterctlBinaryURLTemplate := input.InitWithBinary
215-
if clusterctlBinaryURLTemplate == "" {
216-
Expect(input.E2EConfig.ResolveReleases(ctx)).To(Succeed(), "Failed to resolve release markers in e2e test config file")
217-
Expect(input.E2EConfig.Variables).To(HaveKey(initWithBinaryVariableName), "Invalid argument. %s variable must be defined when calling %s spec", initWithBinaryVariableName, specName)
218-
Expect(input.E2EConfig.Variables[initWithBinaryVariableName]).ToNot(BeEmpty(), "Invalid argument. %s variable can't be empty when calling %s spec", initWithBinaryVariableName, specName)
219-
clusterctlBinaryURLTemplate = input.E2EConfig.GetVariable(initWithBinaryVariableName)
220-
}
221209
clusterctlBinaryURLReplacer := strings.NewReplacer("{OS}", runtime.GOOS, "{ARCH}", runtime.GOARCH)
222210
initClusterctlBinaryURL = clusterctlBinaryURLReplacer.Replace(clusterctlBinaryURLTemplate)
223211

224212
// NOTE: by default we are considering all the providers, no matter of the contract.
225-
// However, given that we want to test both v1alpha3 --> v1beta1 and v1alpha4 --> v1beta1, the INIT_WITH_PROVIDERS_CONTRACT
226-
// variable can be used to select versions with a specific contract.
213+
// However, given that we want to test both v1alpha3 --> v1beta1 and v1alpha4 --> v1beta1,
214+
// InitWithProvidersContract can be used to select versions with a specific contract.
227215
initContract = "*"
228-
if input.E2EConfig.HasVariable(initWithProvidersContract) {
229-
initContract = input.E2EConfig.GetVariable(initWithProvidersContract)
230-
}
231216
if input.InitWithProvidersContract != "" {
232217
initContract = input.InitWithProvidersContract
233218
}
234219

235220
initKubernetesVersion = input.InitWithKubernetesVersion
236-
if initKubernetesVersion == "" {
237-
Expect(input.E2EConfig.Variables).To(HaveKey(initWithKubernetesVersion), "Invalid argument. %s variable must be defined when calling %s spec", initWithKubernetesVersion, specName)
238-
Expect(input.E2EConfig.Variables[initWithKubernetesVersion]).ToNot(BeEmpty(), "Invalid argument. %s variable can't be empty when calling %s spec", initWithKubernetesVersion, specName)
239-
initKubernetesVersion = input.E2EConfig.GetVariable(initWithKubernetesVersion)
240-
}
241221

242222
if len(input.Upgrades) == 0 {
243223
// Upgrade once to v1beta1 if no upgrades are specified.

0 commit comments

Comments
 (0)