-
Notifications
You must be signed in to change notification settings - Fork 158
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
Update secret-controller to create OAuth client #177
Update secret-controller to create OAuth client #177
Conversation
f834776
to
f2bc925
Compare
Review request - @samuelvl |
// Create OauthClient resource | ||
oauthClient := &ocv1.OAuthClient{ | ||
TypeMeta: metav1.TypeMeta{}, | ||
ObjectMeta: metav1.ObjectMeta{ |
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.
OAuhClient is missing ownerreferences for garbage collection, as done in:
opendatahub-operator/pkg/controller/secretgenerator/secretgenerator_controller.go
Lines 107 to 109 in 10e7bba
OwnerReferences: []metav1.OwnerReference{ | |
*metav1.NewControllerRef(foundSecret, foundSecret.GroupVersionKind()), | |
}, |
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.
Updated code to delete OauthClient
using delete events for secret. As discussed offline, adding OwnerReferences doesn't work because OauthClient is a ClusterScoped resource
I am using this kfdef to test the PR with the
I dont't see any error in the logs. |
It should be created in subsequent reconcile, since the route is created at the same time. Used the provided Kfdef -
|
@VaishnaviHire I think my problem is I'm using the odh-operator overlay and the operator pod is not running correctly. What are the deployment instructions? |
Quickest would be to deploy the operator with Operator Hub and replace the value in CSV |
f2bc925
to
682154d
Compare
6824ddf
to
863eb5d
Compare
listopts := []client.ListOption{ | ||
client.MatchingLabels{secretLabel: secretName}} |
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.
We can change the createOAuthClient
function to avoid using a LIST operation here. Name the OAuthClient object with the original secret name, instead of using the route name:
err = r.createOAuthClient(foundSecret.Name, secret.Value, oauthClientRoute.Spec.Host)
func (r *ReconcileSecretGenerator) createOAuthClient(name string, secret string, uri string) error {
...
}
This way, in the deleteOAuthClient
method you can just retrieve the OAuthClient
by doing a GET operation (much better performance).
|
||
// getRoute returns an OpenShift route object. It waits until the .spec.host value exists to avoid possible race conditions, fails otherwise. | ||
func (r *ReconcileSecretGenerator) getRoute(name string, namespace string) (*routev1.Route, error) { | ||
oauthClientRoute := &routev1.Route{} |
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.
Replace s/oauthClientRoute/route to make it more generic (it can return any route, not only the OAuth client route).
} | ||
|
||
func (r *ReconcileSecretGenerator) createOAuthClient(secretName string, name string, secret string, uri string) error { | ||
// Create OauthClient resource |
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.
There are multiple places with this typo, OauthClient
should be OAuthClient
.
863eb5d
to
307b011
Compare
307b011
to
78e50e1
Compare
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.
Tested in opendatahub-io/odh-dashboard#658
/lgtm
@LaVLaS Could you approve this PR? I have already reviewed it |
/retest |
1 similar comment
/retest |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: LaVLaS, samuelvl The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
…rve-alerts Redefine Kserve Controller Manager scrape config
Fixes #175
Description
How Has This Been Tested?
Operator Image: quay.io/vhire/opendatahub-operator:testoauth
The seceret Controller will generate a secret and an Oauth client
Merge criteria: