Skip to content

Commit adfcb39

Browse files
Merge pull request #29598 from djoshy/add-opt-out
MCO-1594: updates for ManagedBootImageStatus
2 parents 59d86be + b897f1b commit adfcb39

File tree

7 files changed

+65
-13
lines changed

7 files changed

+65
-13
lines changed

test/extended/machine_config/boot_image_update_agnostic.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1515
"k8s.io/kubernetes/test/e2e/framework"
16+
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
1617
)
1718

1819
func AllMachineSetTest(oc *exutil.CLI, fixture string) {
@@ -46,17 +47,18 @@ func PartialMachineSetTest(oc *exutil.CLI, fixture string) {
4647
// Label this machineset with the test=boot label
4748
err = oc.Run("label").Args(mapiMachinesetQualifiedName, machineSetUnderTest.Name, "-n", mapiNamespace, "test=boot").Execute()
4849
o.Expect(err).NotTo(o.HaveOccurred())
49-
50+
defer func() {
51+
// Unlabel the machineset at the end of test
52+
err = oc.Run("label").Args(mapiMachinesetQualifiedName, machineSetUnderTest.Name, "-n", mapiNamespace, "test-").Execute()
53+
o.Expect(err).NotTo(o.HaveOccurred())
54+
}()
5055
// Step through all machinesets and verify that only the opted in machineset's boot images are reconciled.
5156
machineSets, err := machineClient.MachineV1beta1().MachineSets("openshift-machine-api").List(context.TODO(), metav1.ListOptions{})
5257
o.Expect(err).NotTo(o.HaveOccurred())
5358
for _, ms := range machineSets.Items {
5459
verifyMachineSetUpdate(oc, ms, machineSetUnderTest.Name == ms.Name)
5560
}
5661

57-
// Unlabel the machineset
58-
err = oc.Run("label").Args(mapiMachinesetQualifiedName, machineSetUnderTest.Name, "-n", mapiNamespace, "test-").Execute()
59-
o.Expect(err).NotTo(o.HaveOccurred())
6062
}
6163

6264
func NoneMachineSetTest(oc *exutil.CLI, fixture string) {
@@ -76,6 +78,7 @@ func NoneMachineSetTest(oc *exutil.CLI, fixture string) {
7678
}
7779

7880
func DegradeOnOwnerRefTest(oc *exutil.CLI, fixture string) {
81+
e2eskipper.Skipf("This test is temporarily disabled until boot image skew enforcement is implemented")
7982
// This fixture applies a boot image update configuration that opts in all machinesets
8083
err := oc.Run("apply").Args("-f", fixture).Execute()
8184
o.Expect(err).NotTo(o.HaveOccurred())

test/extended/machine_config/boot_image_update_aws.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var _ = g.Describe("[sig-mco][OCPFeatureGate:ManagedBootImagesAWS][Serial]", fun
1919
partialMachineSetFixture = filepath.Join(MCOMachineConfigurationBaseDir, "managedbootimages-partial.yaml")
2020
allMachineSetFixture = filepath.Join(MCOMachineConfigurationBaseDir, "managedbootimages-all.yaml")
2121
noneMachineSetFixture = filepath.Join(MCOMachineConfigurationBaseDir, "managedbootimages-none.yaml")
22+
emptyMachineSetFixture = filepath.Join(MCOMachineConfigurationBaseDir, "managedbootimages-empty.yaml")
2223
oc = exutil.NewCLIWithoutNamespace("machine-config")
2324
)
2425

@@ -33,7 +34,7 @@ var _ = g.Describe("[sig-mco][OCPFeatureGate:ManagedBootImagesAWS][Serial]", fun
3334

3435
g.AfterEach(func() {
3536
// Clear out boot image configuration between tests
36-
err := oc.Run("apply").Args("-f", noneMachineSetFixture).Execute()
37+
err := oc.Run("apply").Args("-f", emptyMachineSetFixture).Execute()
3738
o.Expect(err).NotTo(o.HaveOccurred())
3839
})
3940

test/extended/machine_config/boot_image_update_gcp.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var _ = g.Describe("[sig-mco][OCPFeatureGate:ManagedBootImages][Serial]", func()
1919
partialMachineSetFixture = filepath.Join(MCOMachineConfigurationBaseDir, "managedbootimages-partial.yaml")
2020
allMachineSetFixture = filepath.Join(MCOMachineConfigurationBaseDir, "managedbootimages-all.yaml")
2121
noneMachineSetFixture = filepath.Join(MCOMachineConfigurationBaseDir, "managedbootimages-none.yaml")
22+
emptyMachineSetFixture = filepath.Join(MCOMachineConfigurationBaseDir, "managedbootimages-empty.yaml")
2223
oc = exutil.NewCLIWithoutNamespace("machine-config")
2324
)
2425

@@ -33,7 +34,7 @@ var _ = g.Describe("[sig-mco][OCPFeatureGate:ManagedBootImages][Serial]", func()
3334

3435
g.AfterEach(func() {
3536
// Clear out boot image configuration between tests
36-
err := oc.Run("apply").Args("-f", noneMachineSetFixture).Execute()
37+
err := oc.Run("apply").Args("-f", emptyMachineSetFixture).Execute()
3738
o.Expect(err).NotTo(o.HaveOccurred())
3839
})
3940

test/extended/machine_config/helpers.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ func verifyMachineSetUpdate(oc *exutil.CLI, machineSet machinev1beta1.MachineSet
9898
newProviderSpecPatch, originalProviderSpecPatch, newBootImage, originalBootImage := createFakeUpdatePatch(oc, machineSet)
9999
err := oc.Run("patch").Args(mapiMachinesetQualifiedName, machineSet.Name, "-p", fmt.Sprintf(`{"spec":{"template":{"spec":{"providerSpec":{"value":%s}}}}}`, newProviderSpecPatch), "-n", mapiNamespace, "--type=merge").Execute()
100100
o.Expect(err).NotTo(o.HaveOccurred())
101-
101+
defer func() {
102+
// Restore machineSet to original boot image as the machineset may be used by other test variants, regardless of success/fail
103+
err = oc.Run("patch").Args(mapiMachinesetQualifiedName, machineSet.Name, "-p", fmt.Sprintf(`{"spec":{"template":{"spec":{"providerSpec":{"value":%s}}}}}`, originalProviderSpecPatch), "-n", mapiNamespace, "--type=merge").Execute()
104+
o.Expect(err).NotTo(o.HaveOccurred())
105+
framework.Logf("Restored build name in the machineset %s from \"%s\" to \"%s\"", machineSet.Name, newBootImage, originalBootImage)
106+
}()
102107
// Ensure boot image controller is not progressing
103108
framework.Logf("Waiting until the boot image controller is not progressing...")
104109
WaitForBootImageControllerToComplete(oc)
@@ -112,12 +117,6 @@ func verifyMachineSetUpdate(oc *exutil.CLI, machineSet machinev1beta1.MachineSet
112117
o.Expect(providerSpecDisks).ShouldNot(o.ContainSubstring(newBootImage))
113118
} else {
114119
o.Expect(providerSpecDisks).Should(o.ContainSubstring(newBootImage))
115-
// Restore machineSet to original boot image in this case, as the machineset may be used by other test variants
116-
117-
o.Expect(err).NotTo(o.HaveOccurred())
118-
err = oc.Run("patch").Args(mapiMachinesetQualifiedName, machineSet.Name, "-p", fmt.Sprintf(`{"spec":{"template":{"spec":{"providerSpec":{"value":%s}}}}}`, originalProviderSpecPatch), "-n", mapiNamespace, "--type=merge").Execute()
119-
o.Expect(err).NotTo(o.HaveOccurred())
120-
framework.Logf("Restored build name in the machineset %s from \"%s\" to \"%s\"", machineSet.Name, originalBootImage, newBootImage)
121120
}
122121
}
123122

test/extended/testdata/bindata.go

+34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: operator.openshift.io/v1
2+
kind: MachineConfiguration
3+
metadata:
4+
name: cluster
5+
namespace: openshift-machine-config-operator
6+
spec:
7+
logLevel: Normal
8+
operatorLogLevel: Normal

test/extended/testdata/machine_config/machineconfigurations/managedbootimages-none.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ metadata:
66
spec:
77
logLevel: Normal
88
operatorLogLevel: Normal
9+
managedBootImages:
10+
machineManagers:
11+
- resource: machinesets
12+
apiGroup: machine.openshift.io
13+
selection:
14+
mode: None

0 commit comments

Comments
 (0)