Add events to SA as OAuth client flow#13621
Add events to SA as OAuth client flow#13621openshift-merge-robot merged 2 commits intoopenshift:masterfrom
Conversation
|
Evaluated for origin test up to c8c6237 |
|
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/560/) (Base Commit: f0670df) |
|
Is this using events as validation? |
|
|
||
| // TODO: is this safe to tell - could leak Route info? | ||
| a.recorder.Eventf(sa, kapi.EventTypeNormal, "OAuthAllRedirectURIs", "Has the following redirectURIs: %v", saClient.RedirectURIs) | ||
|
|
There was a problem hiding this comment.
You're sending one event per oauth login to the master? That's... probably going to eat into our write budget.
Sort of? We cannot do validation on SA annotations. This lets the user know if something looks off.
Based on some offline discussions with Jordan, I plan to change this to send a single warning event when something looks incorrect. That event would contain a sorted list of problems noticed. Thus if the user goes through the same error flow multiple times, the same event should just have its counter incremented. No events will be generated when everything is working as expected. |
|
Origin Action Required: Pull request cannot be automatically merged, please rebase your branch from latest HEAD and push again |
|
/assign liggitt
incrementing a counter is still an etcd write. |
|
We need some mechanism for sure. But it has to be no more than O(0) writes
measured over 5s-1m.
On Jul 31, 2017, at 9:00 AM, David Eads <notifications@github.com> wrote:
/assign liggitt
Thus if the user goes through the same error flow multiple times, the same
event should just have its counter incremented. No events will be generated
when everything is working as expected.
incrementing a counter is still an etcd write.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#13621 (comment)>,
or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABG_px3GUYLyKmkPvL64jKpx_Dftm3O7ks5sTc_RgaJpZM4MzFl0>
.
|
c8c6237 to
659945d
Compare
|
@benjaminapetersen Might be best to stop trying to humanize these and display the reason as-is |
|
@liggitt what do you expect to happen when non-fatal errors are encountered in a |
6f7a3fe to
c159076
Compare
c159076 to
24fc801
Compare
24fc801 to
f65d877
Compare
|
flake #16144 |
|
/retest |
|
I've rebased and excluded the event limit configuration patch (in lieu of further developments upstream) - should be all set here. @enj @smarterclayton PTAL |
f65d877 to
88f5dd7
Compare
pkg/oauth/apiserver/apiserver.go
Outdated
| combinedOAuthClientGetter := saoauth.NewServiceAccountOAuthClientGetter( | ||
| coreClient, | ||
| coreClient, | ||
| // TODO: fix this construction |
There was a problem hiding this comment.
I would expect coreClient.Events("") or if that does not work then:
coreV1Client, err := corev1.NewForConfig(c.CoreAPIServerClientConfig) + coreV1Client.Events("")
pkg/oauth/apiserver/auth.go
Outdated
| combinedOAuthClientGetter := saoauth.NewServiceAccountOAuthClientGetter( | ||
| c.KubeClient.Core(), | ||
| c.KubeClient.Core(), | ||
| // TODO: simplify this construction |
| // TODO pass a privileged client config through during construction. It is NOT a loopback client. | ||
| oauthServerConfig.RouteClient = routeClient | ||
| oauthServerConfig.KubeClient = masterConfig.PrivilegedLoopbackKubernetesClientsetInternal | ||
| oauthServerConfig.KubeExternalClient = masterConfig.PrivilegedLoopbackKubernetesClientsetExternal |
There was a problem hiding this comment.
You may not need this if you can reuse coreClient
There was a problem hiding this comment.
|
|
||
| combinedOAuthClientGetter := saoauth.NewServiceAccountOAuthClientGetter(coreClient, coreClient, routeClient, oauthClient.OAuthClients(), saAccountGrantMethod) | ||
| combinedOAuthClientGetter := saoauth.NewServiceAccountOAuthClientGetter( | ||
| coreClient, |
There was a problem hiding this comment.
Call the sub methods on this to get the specific interfaces you need.
There was a problem hiding this comment.
This did not seem possible with coreClient, are you suggesting a change in NewServiceAccountOAuthClientGetter() argument types as well?
| KubeClient kclientset.Interface | ||
|
|
||
| // KubeExternalClient is for creating user events | ||
| KubeExternalClient kclientsetexternal.Interface |
There was a problem hiding this comment.
Lets make sure we really need this per above comments.
| // Create a warning event combining the collected annotation errors upon failure. | ||
| defer func() { | ||
| if err != nil && len(saErrors) > 0 && len(failReason) > 0 { | ||
| a.eventRecorder.Eventf(sa, kapi.EventTypeWarning, failReason, "%s", joinErrors(saErrors)) |
There was a problem hiding this comment.
Use Event since you do not need the format.
| } | ||
|
|
||
| if len(tc.expectedEventMsg) > 0 { | ||
| ev := <-fakerecorder.Events |
There was a problem hiding this comment.
I think you want a select statement with a default to prevent this from ever dead locking.
| } { | ||
| if !reflect.DeepEqual(test.expected, parseModelsMap(test.annotations, decoder)) { | ||
| t.Errorf("%s: expected %#v, got %#v", test.name, test.expected, parseModelsMap(test.annotations, decoder)) | ||
| models, _ := parseModelsMap(test.annotations, decoder) |
There was a problem hiding this comment.
Don't ignore the errors.
| } { | ||
| a := buildRouteClient(test.routes) | ||
| actual := test.models.getRedirectURIs(a.redirectURIsFromRoutes(test.namespace, test.models.getNames())) | ||
| uris, _ := a.redirectURIsFromRoutes(test.namespace, test.models.getNames()) |
There was a problem hiding this comment.
Don't ignore the errors.
| a := buildRouteClient(test.routes) | ||
| if !reflect.DeepEqual(test.expected, a.redirectURIsFromRoutes(test.namespace, test.names)) { | ||
| t.Errorf("%s: expected %#v, got %#v", test.name, test.expected, a.redirectURIsFromRoutes(test.namespace, test.names)) | ||
| uris, _ := a.redirectURIsFromRoutes(test.namespace, test.names) |
There was a problem hiding this comment.
Don't ignore the errors.
88f5dd7 to
1ee9812
Compare
pkg/oauth/apiserver/auth.go
Outdated
| c.KubeClient.Core(), | ||
| c.KubeClient.Core(), | ||
| // TODO: simplify this construction | ||
| corev1.New(c.KubeExternalClient.Core().RESTClient()).Events(""), |
|
|
||
| // KubeExternalClient is for creating user events | ||
| KubeExternalClient kclientsetexternal.Interface | ||
|
|
There was a problem hiding this comment.
Add an events client directly in this config and build it in NewOAuthServerConfig
Collect errors during validation of a service account's OAuth configuration, logging them to a warning event upon a fatal error. Signed-off-by: Matt Rogers <mrogers@redhat.com>
Signed-off-by: Matt Rogers <mrogers@redhat.com>
1ee9812 to
dfe104f
Compare
|
/lgtm |
|
/approve I am happy with this (it's not my PR anymore). |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: enj, mrogers950 Assign the PR to them by writing The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
|
/retest |
|
xref #16568 Still need issue for the core client events problem. |
|
Automatic merge from submit-queue |
Add warning events for service account OAuth configuration errors to aid in troubleshooting. Display these events when describing service accounts.
https://trello.com/c/oRkv75dy/15-5-add-api-events-for-using-sa-as-oauth-clients