-
Notifications
You must be signed in to change notification settings - Fork 506
Add hot loop test automation #6212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
sergiordlr
wants to merge
1
commit into
openshift:main
Choose a base branch
from
sergiordlr:add_tc_89596_hot_loop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,8 +15,10 @@ import ( | |
| e2e "k8s.io/kubernetes/test/e2e/framework" | ||
| ) | ||
|
|
||
| const mapiBaseErrorMessageTemplate = `1 Degraded MAPI MachineSets | 0 Degraded ControlPlaneMachineSets | 0 Degraded CAPI MachineSets | 0 Degraded CAPI MachineDeployments | Error(s):` + | ||
| ` error syncing MAPI MachineSet %s: failed to reconcile machineset %s, err:` | ||
| const mapiBaseErrorMessageTemplate = `1 Degraded MAPI MachineSets | 0 Degraded ControlPlaneMachineSets | 0 Degraded CAPI MachineSets | 0 CAPI MachineDeployments | Error(s):` + | ||
| ` error syncing MAPI MachineSet %s:` | ||
|
|
||
| const mapiReconcileErrorMessageTemplate = mapiBaseErrorMessageTemplate + ` failed to reconcile machineset %s, err:` | ||
|
|
||
| var _ = g.Describe("[sig-mco][Suite:openshift/machine-config-operator/disruptive][Serial][Disruptive] MCO Bootimages", func() { | ||
| defer g.GinkgoRecover() | ||
|
|
@@ -410,7 +412,7 @@ var _ = g.Describe("[sig-mco][Suite:openshift/machine-config-operator/disruptive | |
| clonedMSName = fmt.Sprintf("cloned-tc-%s-copy", GetCurrentTestPolarionIDNumber()) | ||
| clonedSecretName = fmt.Sprintf("cloned-user-data-%s-copy", GetCurrentTestPolarionIDNumber()) | ||
| // We make the the regexp end in a "$" to make sure that no more versions than the expected ones are present | ||
| expectedFailedMessageRegexp = regexp.QuoteMeta(fmt.Sprintf(mapiBaseErrorMessageTemplate+ | ||
| expectedFailedMessageRegexp = regexp.QuoteMeta(fmt.Sprintf(mapiReconcileErrorMessageTemplate+ | ||
| ` error grabbing user data secret referenced in machineset: secrets "%s" not found`, clonedMSName, clonedMSName, clonedSecretName)) + "$" | ||
| ) | ||
|
|
||
|
|
@@ -423,7 +425,7 @@ var _ = g.Describe("[sig-mco][Suite:openshift/machine-config-operator/disruptive | |
| clonedMSName = fmt.Sprintf("cloned-tc-%s-copy", GetCurrentTestPolarionIDNumber()) | ||
| clonedSecretName = fmt.Sprintf("cloned-user-data-%s-copy", GetCurrentTestPolarionIDNumber()) | ||
| // We make the the regexp end in a "$" to make sure that no more versions than the expected ones are present | ||
| expectedFailedMessageRegexp = regexp.QuoteMeta(fmt.Sprintf(mapiBaseErrorMessageTemplate+ | ||
| expectedFailedMessageRegexp = regexp.QuoteMeta(fmt.Sprintf(mapiReconcileErrorMessageTemplate+ | ||
| " failed to unmarshal decoded user-data to json (secret %s): invalid character 'h' in literal true (expecting 'r')t", clonedMSName, clonedMSName, clonedSecretName)) + "$" | ||
| ) | ||
|
|
||
|
|
@@ -441,7 +443,7 @@ var _ = g.Describe("[sig-mco][Suite:openshift/machine-config-operator/disruptive | |
| clonedMSName = fmt.Sprintf("cloned-tc-%s-copy", GetCurrentTestPolarionIDNumber()) | ||
| clonedSecretName = fmt.Sprintf("cloned-user-data-%s-copy", GetCurrentTestPolarionIDNumber()) | ||
| // We make the the regexp end in a "$" to make sure that no more versions than the expected ones are present | ||
| expectedFailedMessageRegexp = regexp.QuoteMeta(fmt.Sprintf(mapiBaseErrorMessageTemplate+ | ||
| expectedFailedMessageRegexp = regexp.QuoteMeta(fmt.Sprintf(mapiReconcileErrorMessageTemplate+ | ||
| " converting ignition stub failed: failed to parse Ignition config: parsing Ignition config failed:"+ | ||
| " unknown version. Supported spec versions: 2.2,3.0,3.1,3.2,3.3,3.4,3.5", clonedMSName, clonedMSName)) + "$" | ||
| ) | ||
|
|
@@ -679,6 +681,76 @@ var _ = g.Describe("[sig-mco][Suite:openshift/machine-config-operator/disruptive | |
| exutil.By("Set the original architecture in the cloneed machineset") | ||
| setArchitectureAndCheckStatus(clonedMS, machineConfiguration, arch.String()) | ||
| }) | ||
|
|
||
| g.It("[PolarionID:89596][OTP] ManagedBootImages. Hot loop detection and recovery", g.Label("Platform:aws", "Platform:gce", "Platform:vsphere", "Platform:azure"), func() { | ||
| var ( | ||
| clonedMSName = fmt.Sprintf("cloned-tc-%s-%s", GetCurrentTestPolarionIDNumber(), exutil.GetRandomString()[:5]) | ||
| machineSet = NewMachineSetList(oc.AsAdmin(), MachineAPINamespace).GetAllOrFail()[0] | ||
| fakeImageName = getBackdatedBootImage(oc.AsAdmin()) | ||
| expectedHotLoopMessageRegex = regexp.QuoteMeta(fmt.Sprintf(mapiBaseErrorMessageTemplate+ | ||
| " refusing to reconcile machineset %s, hot loop detected.", clonedMSName, clonedMSName)) | ||
| ) | ||
|
|
||
| exutil.By("Opt-in boot images update") | ||
| o.Expect( | ||
| machineConfiguration.SetAllManagedBootImagesConfig(MachineSetResource), | ||
| ).To(o.Succeed(), "Error configuring ALL managedBootImages in the 'cluster' MachineConfiguration resource") | ||
| logger.Infof("OK!\n") | ||
|
|
||
| exutil.By("Clone the first machineset") | ||
| clonedMS, err := machineSet.Duplicate(clonedMSName) | ||
| o.Expect(err).NotTo(o.HaveOccurred(), "Error duplicating %s", machineSet) | ||
| defer clonedMS.Delete() | ||
| logger.Infof("OK!\n") | ||
|
|
||
| exutil.By("Trigger hot loop by repeatedly setting a wrong boot image") | ||
| // HotLoopLimit is 3. After 3 patches to the same target value by MCO, | ||
| // the next attempt to patch triggers the hot loop detection. | ||
| for i := 1; i <= 3; i++ { | ||
| logger.Infof("Hot loop iteration %d/3: setting wrong boot image", i) | ||
| o.Expect(clonedMS.SetCoreOsBootImage(fakeImageName)).To(o.Succeed(), | ||
| "Error setting a fake boot image in %s (iteration %d)", clonedMS, i) | ||
|
|
||
| logger.Infof("Waiting for MCO to fix the boot image (iteration %d)", i) | ||
| o.Eventually(clonedMS.GetCoreOsBootImage, "5m", "20s").ShouldNot(o.Equal(fakeImageName), | ||
| "MCO did not fix the boot image in %s (iteration %d)", clonedMS, i) | ||
| } | ||
| logger.Infof("OK!\n") | ||
|
|
||
| exutil.By("Set wrong boot image one more time to trigger the hot loop error") | ||
| o.Expect(clonedMS.SetCoreOsBootImage(fakeImageName)).To(o.Succeed(), | ||
| "Error setting a fake boot image in %s", clonedMS) | ||
| logger.Infof("OK!\n") | ||
|
|
||
| exutil.By("Check that the hot loop error is reported in the MachineConfiguration resource") | ||
| o.Eventually(machineConfiguration, "5m", "20s").Should(HaveConditionField("BootImageUpdateDegraded", "status", "True"), | ||
| "Expected %s to be BootImageUpdateDegraded due to hot loop.\n%s", machineConfiguration.PrettyString()) | ||
|
|
||
| o.Eventually(machineConfiguration, "5m", "20s").Should(HaveConditionField("BootImageUpdateDegraded", "message", o.MatchRegexp(expectedHotLoopMessageRegex)), | ||
| "Expected hot loop error message in %s.\n%s", machineConfiguration.PrettyString()) | ||
|
Comment on lines
+727
to
+730
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix assertion format strings with missing arguments. These failure messages use two Suggested fix- o.Eventually(machineConfiguration, "5m", "20s").Should(HaveConditionField("BootImageUpdateDegraded", "status", "True"),
- "Expected %s to be BootImageUpdateDegraded due to hot loop.\n%s", machineConfiguration.PrettyString())
+ o.Eventually(machineConfiguration, "5m", "20s").Should(HaveConditionField("BootImageUpdateDegraded", "status", "True"),
+ "Expected BootImageUpdateDegraded=True due to hot loop.\n%s", machineConfiguration.PrettyString())
- o.Eventually(machineConfiguration, "5m", "20s").Should(HaveConditionField("BootImageUpdateDegraded", "message", o.MatchRegexp(expectedHotLoopMessageRegex)),
- "Expected hot loop error message in %s.\n%s", machineConfiguration.PrettyString())
+ o.Eventually(machineConfiguration, "5m", "20s").Should(HaveConditionField("BootImageUpdateDegraded", "message", o.MatchRegexp(expectedHotLoopMessageRegex)),
+ "Expected hot loop error message.\n%s", machineConfiguration.PrettyString())
- o.Eventually(machineConfiguration, "5m", "20s").Should(HaveConditionField("BootImageUpdateDegraded", "status", "False"),
- "Expected %s NOT to be BootImageUpdateDegraded after clearing hot loop.\n%s", machineConfiguration.PrettyString())
+ o.Eventually(machineConfiguration, "5m", "20s").Should(HaveConditionField("BootImageUpdateDegraded", "status", "False"),
+ "Expected BootImageUpdateDegraded=False after clearing hot loop.\n%s", machineConfiguration.PrettyString())Also applies to: 746-747 🤖 Prompt for AI Agents |
||
| logger.Infof("OK!\n") | ||
|
|
||
| exutil.By("Opt-out to clear the hot loop state") | ||
| o.Expect( | ||
| machineConfiguration.SetNoneManagedBootImagesConfig(MachineSetResource), | ||
| ).To(o.Succeed(), "Error configuring None managedBootImages in the 'cluster' MachineConfiguration resource") | ||
| logger.Infof("OK!\n") | ||
|
|
||
| exutil.By("Opt-in again to verify the hot loop state was cleared") | ||
| o.Expect( | ||
| machineConfiguration.SetAllManagedBootImagesConfig(MachineSetResource), | ||
| ).To(o.Succeed(), "Error configuring ALL managedBootImages in the 'cluster' MachineConfiguration resource") | ||
| logger.Infof("OK!\n") | ||
|
|
||
| exutil.By("Check that the degraded status is cleared and the boot image is restored") | ||
| o.Eventually(machineConfiguration, "5m", "20s").Should(HaveConditionField("BootImageUpdateDegraded", "status", "False"), | ||
| "Expected %s NOT to be BootImageUpdateDegraded after clearing hot loop.\n%s", machineConfiguration.PrettyString()) | ||
|
|
||
| o.Eventually(clonedMS.GetCoreOsBootImage, "5m", "20s").ShouldNot(o.Equal(fakeImageName), | ||
| "MCO should have fixed the boot image in %s after clearing the hot loop", clonedMS) | ||
| CheckCurrentOSImageIsUpdated(clonedMS) | ||
| logger.Infof("OK!\n") | ||
| }) | ||
| }) | ||
|
|
||
| func DuplicateMachineSetWithCustomBootImage(ms *MachineSet, newBootImage, newName string) (*MachineSet, error) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle deferred cleanup errors explicitly.
defer clonedMS.Delete()ignores the returned error (Line 703). In this disruptive test, failed cleanup can leak resources and cause cross-test instability.Suggested fix
As per coding guidelines, Go code should never ignore error returns.
📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Coding guidelines