Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions pkg/controllers/common/external_oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,26 @@ func (c *AuthConfigChecker) OIDCAvailable() (bool, error) {
return false, fmt.Errorf("getting kubeapiservers.operator.openshift.io/cluster: %v", err)
}

if len(kas.Status.NodeStatuses) == 0 {
return false, fmt.Errorf("determining observed revisions in kubeapiservers.operator.openshift.io/cluster; no node statuses found")
}

observedRevisions := sets.New[int32]()
nodesWithEmptyRevision := false
for _, nodeStatus := range kas.Status.NodeStatuses {
observedRevisions.Insert(nodeStatus.CurrentRevision)
if nodeStatus.CurrentRevision > 0 {
observedRevisions.Insert(nodeStatus.CurrentRevision)
} else {
nodesWithEmptyRevision = true
}
}

if nodesWithEmptyRevision {
return false, fmt.Errorf("determining observed revisions in kubeapiservers.operator.openshift.io/cluster; some nodes do not have a valid CurrentRevision")
Comment on lines 76 to 87
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we find one with an invalid revision, should we just return the error from within the loop, terminating it early?

As-is, I don't really see us gaining any benefit of continuing to loop once we've found at least one node with an invalid current revision.

Suggested change
nodesWithEmptyRevision := false
for _, nodeStatus := range kas.Status.NodeStatuses {
observedRevisions.Insert(nodeStatus.CurrentRevision)
if nodeStatus.CurrentRevision > 0 {
observedRevisions.Insert(nodeStatus.CurrentRevision)
} else {
nodesWithEmptyRevision = true
}
}
if nodesWithEmptyRevision {
return false, fmt.Errorf("determining observed revisions in kubeapiservers.operator.openshift.io/cluster; some nodes do not have a valid CurrentRevision")
for _, nodeStatus := range kas.Status.NodeStatuses {
if nodeStatus.CurrentRevision <= 0 {
return false, fmt.Errorf("determining observed revisions in kubeapiservers.operator.openshift.io/cluster; some nodes do not have a valid CurrentRevision")
}
observedRevisions.Insert(nodeStatus.CurrentRevision)
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course -- now that we don't use the count this is much better 👍

}

if observedRevisions.Len() == 0 {
return false, nil
return false, fmt.Errorf("determining observed revisions in kubeapiservers.operator.openshift.io/cluster; no observed revisions found")
}

for _, revision := range observedRevisions.UnsortedList() {
Expand Down
24 changes: 23 additions & 1 deletion pkg/controllers/common/external_oidc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,29 @@ func TestExternalOIDCConfigAvailable(t *testing.T) {
name: "no node statuses observed",
authType: configv1.AuthenticationTypeOIDC,
expectAvailable: false,
expectError: false,
expectError: true,
},
{
name: "some node revisions are zero",
authType: configv1.AuthenticationTypeOIDC,
nodeStatuses: []operatorv1.NodeStatus{
{CurrentRevision: 10},
{CurrentRevision: 10},
{CurrentRevision: 0},
},
expectAvailable: false,
expectError: true,
},
{
name: "node revisions are zero",
authType: configv1.AuthenticationTypeOIDC,
nodeStatuses: []operatorv1.NodeStatus{
{CurrentRevision: 0},
{CurrentRevision: 0},
{CurrentRevision: 0},
},
expectAvailable: false,
expectError: true,
},
{
name: "oidc disabled, no rollout",
Expand Down