Skip to content

Commit 19038d5

Browse files
Merge pull request #1032 from everettraven/bugfix/ocpbugs-60219
OCPBUGS-60219: make console operator responsible for creating oauth client
2 parents 6ad68cc + 12765b7 commit 19038d5

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

manifests/01-oauth.yaml

Lines changed: 0 additions & 13 deletions
This file was deleted.

manifests/03-rbac-role-cluster.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ rules:
2525
- get
2626
- list
2727
- watch
28+
- create
2829
- apiGroups:
2930
- oauth.openshift.io
3031
resources:

pkg/console/controllers/oauthclients/oauthclients.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88

99
corev1 "k8s.io/api/core/v1"
10+
"k8s.io/apimachinery/pkg/api/errors"
1011
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1112
"k8s.io/apimachinery/pkg/util/wait"
1213
corev1informers "k8s.io/client-go/informers/core/v1"
@@ -15,6 +16,7 @@ import (
1516
"k8s.io/klog/v2"
1617

1718
configv1 "github.com/openshift/api/config/v1"
19+
oauthv1 "github.com/openshift/api/oauth/v1"
1820
operatorv1 "github.com/openshift/api/operator/v1"
1921
configv1informers "github.com/openshift/client-go/config/informers/externalversions/config/v1"
2022
configv1lister "github.com/openshift/client-go/config/listers/config/v1"
@@ -40,7 +42,7 @@ import (
4042
// oauthClientsController:
4143
//
4244
// updates:
43-
// - oauthclient.oauth.openshift.io/console (created by CVO)
45+
// - oauthclient.oauth.openshift.io/console (creates if doesn't exist)
4446
// writes:
4547
// - consoles.operator.openshift.io/cluster .status.conditions:
4648
// - type=OAuthClientSyncProgressing
@@ -207,10 +209,21 @@ func (c *oauthClientsController) syncOAuthClient(
207209
consoleURL string,
208210
) (reason string, err error) {
209211
oauthClient, err := c.oauthClientLister.Get(oauthsub.Stub().Name)
210-
if err != nil {
212+
if err != nil && !errors.IsNotFound(err) {
211213
// at this point we must die & wait for someone to fix the lack of an outhclient. there is nothing we can do.
212-
return "FailedGet", fmt.Errorf("oauth client for console does not exist and cannot be created (%w)", err)
214+
return "FailedGet", fmt.Errorf("getting console oauth client (%w)", err)
215+
}
216+
217+
if errors.IsNotFound(err) {
218+
oauthClient = &oauthv1.OAuthClient{
219+
ObjectMeta: metav1.ObjectMeta{
220+
Name: oauthsub.Stub().Name,
221+
},
222+
GrantMethod: oauthv1.GrantHandlerAuto,
223+
RespondWithChallenges: false,
224+
}
213225
}
226+
214227
clientCopy := oauthClient.DeepCopy()
215228
oauthsub.RegisterConsoleToOAuthClient(clientCopy, consoleURL, secretsub.GetSecretString(sec))
216229
_, _, oauthErr := oauthsub.CustomApplyOAuth(c.oauthClient, clientCopy, ctx)
@@ -234,5 +247,4 @@ func (c *oauthClientsController) deregisterClient(ctx context.Context) error {
234247
updated := oauthsub.DeRegisterConsoleFromOAuthClient(existingOAuthClient.DeepCopy())
235248
_, err = c.oauthClient.OAuthClients().Update(ctx, updated, metav1.UpdateOptions{})
236249
return err
237-
238250
}

0 commit comments

Comments
 (0)