-
Notifications
You must be signed in to change notification settings - Fork 4.8k
OCPBUGS-111997: Add Degraded=True exception for authentication operator during upgrade #31535
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -674,3 +674,103 @@ func TestOverlapsNoExecuteTaintManagerTest(t *testing.T) { | |||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func buildOperatorConditionInterval(operator, conditionType, status, reason string, from, to time.Time) monitorapi.Interval { | ||||||||||||||||||||||||||||||||
| return monitorapi.Interval{ | ||||||||||||||||||||||||||||||||
| Source: monitorapi.SourceClusterOperatorMonitor, | ||||||||||||||||||||||||||||||||
| Condition: monitorapi.Condition{ | ||||||||||||||||||||||||||||||||
| Locator: monitorapi.Locator{ | ||||||||||||||||||||||||||||||||
| Keys: map[monitorapi.LocatorKey]string{ | ||||||||||||||||||||||||||||||||
| monitorapi.LocatorClusterOperatorKey: operator, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| Message: monitorapi.Message{ | ||||||||||||||||||||||||||||||||
| Reason: monitorapi.IntervalReason(reason), | ||||||||||||||||||||||||||||||||
| HumanMessage: "test condition", | ||||||||||||||||||||||||||||||||
| Annotations: map[monitorapi.AnnotationKey]string{ | ||||||||||||||||||||||||||||||||
| monitorapi.AnnotationCondition: conditionType, | ||||||||||||||||||||||||||||||||
| monitorapi.AnnotationStatus: status, | ||||||||||||||||||||||||||||||||
| monitorapi.AnnotationReason: reason, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| From: from, | ||||||||||||||||||||||||||||||||
| To: to, | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| func Test_authenticationDegradedExceptionDuringUpgrade(t *testing.T) { | ||||||||||||||||||||||||||||||||
| upgradeStart := time.Date(2026, 8, 17, 16, 0, 0, 0, time.UTC) | ||||||||||||||||||||||||||||||||
| upgradeEnd := time.Date(2026, 8, 17, 17, 30, 0, 0, time.UTC) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| upgradeEvents := makeUpgradeEventList([]upgradeEvent{ | ||||||||||||||||||||||||||||||||
| {eventTime: upgradeStart, reason: monitorapi.UpgradeStartedReason}, | ||||||||||||||||||||||||||||||||
| {eventTime: upgradeEnd, reason: monitorapi.UpgradeCompleteReason}, | ||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| tests := []struct { | ||||||||||||||||||||||||||||||||
| name string | ||||||||||||||||||||||||||||||||
| reason string | ||||||||||||||||||||||||||||||||
| wantFatal bool | ||||||||||||||||||||||||||||||||
| }{ | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| name: "compound reason containing OAuthServerDeployment_UnavailablePod should be excepted", | ||||||||||||||||||||||||||||||||
| reason: "APIServerDeployment_UnavailablePod::OAuthServerDeployment_UnavailablePod", | ||||||||||||||||||||||||||||||||
| wantFatal: false, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| name: "OAuthServerDeployment_UnavailablePod alone should be excepted", | ||||||||||||||||||||||||||||||||
| reason: "OAuthServerDeployment_UnavailablePod", | ||||||||||||||||||||||||||||||||
| wantFatal: false, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| name: "APIServerDeployment_UnavailablePod alone should NOT be excepted", | ||||||||||||||||||||||||||||||||
| reason: "APIServerDeployment_UnavailablePod", | ||||||||||||||||||||||||||||||||
| wantFatal: true, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| name: "unrelated Degraded reason should NOT be excepted", | ||||||||||||||||||||||||||||||||
| reason: "SomeOtherDegradedReason", | ||||||||||||||||||||||||||||||||
| wantFatal: true, | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| for _, tt := range tests { | ||||||||||||||||||||||||||||||||
| t.Run(tt.name, func(t *testing.T) { | ||||||||||||||||||||||||||||||||
| condFrom := upgradeStart.Add(50 * time.Minute) | ||||||||||||||||||||||||||||||||
| condTo := condFrom.Add(10 * time.Second) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| conditionEvent := buildOperatorConditionInterval( | ||||||||||||||||||||||||||||||||
| "authentication", "Degraded", "True", tt.reason, | ||||||||||||||||||||||||||||||||
| condFrom, condTo, | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| var events monitorapi.Intervals | ||||||||||||||||||||||||||||||||
| events = append(events, upgradeEvents...) | ||||||||||||||||||||||||||||||||
| events = append(events, conditionEvent) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| results := testUpgradeOperatorStateTransitions(events, nil, configv1.HighlyAvailableTopologyMode) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| testName := "[bz-apiserver-auth] clusteroperator/authentication should not change condition/Degraded" | ||||||||||||||||||||||||||||||||
| var hasFailure, hasSuccess bool | ||||||||||||||||||||||||||||||||
| for _, tc := range results { | ||||||||||||||||||||||||||||||||
| if tc.Name == testName { | ||||||||||||||||||||||||||||||||
| if tc.FailureOutput != nil { | ||||||||||||||||||||||||||||||||
| hasFailure = true | ||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||
| hasSuccess = true | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if tt.wantFatal { | ||||||||||||||||||||||||||||||||
| assert.True(t, hasFailure, "expected a failure JUnit for reason %s", tt.reason) | ||||||||||||||||||||||||||||||||
| assert.False(t, hasSuccess, "expected no success JUnit for reason %s (should be hard failure)", tt.reason) | ||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||
| if hasFailure { | ||||||||||||||||||||||||||||||||
| assert.True(t, hasSuccess, "expected both failure and success JUnit (flake) for reason %s", tt.reason) | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+766
to
+773
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. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Assert the expected successful JUnit case. At Line 769, the accepted-reason branch passes when Proposed fix } else {
- if hasFailure {
- assert.True(t, hasSuccess, "expected both failure and success JUnit (flake) for reason %s", tt.reason)
- }
+ assert.False(t, hasFailure, "expected no failure JUnit for reason %s", tt.reason)
+ assert.True(t, hasSuccess, "expected a success JUnit for reason %s", tt.reason)
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.