Skip to content

Commit c9067c2

Browse files
Merge pull request #802 from openshift-cherrypick-robot/cherry-pick-798-to-release-4.20
[release-4.20] OCPBUGS-63319: (bugfix): configure status controller to remove unset versions
2 parents 31b775a + e3ba0e0 commit c9067c2

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

manifests/08_clusteroperator.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,3 @@ status:
4949
versions:
5050
- name: operator
5151
version: "0.0.1-snapshot"
52-
- name: oauth-openshift
53-
version: "0.0.1-snapshot_openshift"

pkg/operator/starter.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,11 @@ func prepareOauthAPIServerOperator(
474474
statusControllerOptions = append(statusControllerOptions, apiservercontrollerset.WithStatusControllerPdbCompatibleHighInertia("(APIServer|OAuthServer)"))
475475
}
476476

477+
// configure version removal so it removes versions it doesn't know about.
478+
statusControllerOptions = append(statusControllerOptions, func(ss *status.StatusSyncer) *status.StatusSyncer {
479+
return ss.WithVersionRemoval()
480+
})
481+
477482
const apiServerConditionsPrefix = "APIServer"
478483

479484
apiServerControllers, err := apiservercontrollerset.NewAPIServerControllerSet(

test/e2e-oidc/external_oidc_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ func (tc *testClient) validateOAuthState(t *testing.T, ctx context.Context, requ
727727
validationErrs = append(validationErrs, validateOAuthResources(ctx, dynamicClient, requireMissing)...)
728728
validationErrs = append(validationErrs, validateOAuthRoutes(ctx, tc.routeClient, tc.configClient, requireMissing)...)
729729
validationErrs = append(validationErrs, validateOAuthControllerConditions(tc.operatorClient, requireMissing)...)
730+
validationErrs = append(validationErrs, validateOperandVersions(ctx, tc.configClient, requireMissing)...)
730731
return len(validationErrs) == 0, nil
731732
})
732733

@@ -872,6 +873,33 @@ func validateOAuthControllerConditions(operatorClient v1helpers.OperatorClient,
872873
return nil
873874
}
874875

876+
func validateOperandVersions(ctx context.Context, cfgClient *configclient.Clientset, requireMissing bool) []error {
877+
operands := sets.New("oauth-apiserver", "oauth-openshift")
878+
879+
authnClusterOperator, err := cfgClient.ConfigV1().ClusterOperators().Get(ctx, "authentication", metav1.GetOptions{})
880+
if err != nil {
881+
return []error{fmt.Errorf("fetching authentication ClusterOperator: %w", err)}
882+
}
883+
884+
foundOperands := []string{}
885+
for _, version := range authnClusterOperator.Status.Versions {
886+
if operands.Has(version.Name) {
887+
foundOperands = append(foundOperands, version.Name)
888+
}
889+
}
890+
891+
if requireMissing && len(foundOperands) > 0 {
892+
return []error{fmt.Errorf("authentication ClusterOperator status has operands %v in versions when they should be unset", foundOperands)}
893+
}
894+
895+
foundSet := sets.New(foundOperands...)
896+
if !requireMissing && !foundSet.Equal(operands) {
897+
return []error{fmt.Errorf("authentication ClusterOperator status expected to have operands %v in versions but got %v", operands.UnsortedList(), foundOperands)}
898+
}
899+
900+
return nil
901+
}
902+
875903
func (tc *testClient) testOIDCAuthentication(t *testing.T, ctx context.Context, kcClient *test.KeycloakClient, usernameClaim, usernamePrefix string, expectAuthSuccess bool) {
876904
// re-authenticate to ensure we always have a fresh token
877905
var err error

0 commit comments

Comments
 (0)