Skip to content
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

add an observer for webhookTokenAuthenticator #890

Merged
merged 2 commits into from Jul 10, 2020

Conversation

stlaz
Copy link
Member

@stlaz stlaz commented Jun 22, 2020

Adds an observer that's supposed to observe the authentication.Spec.WebhookTokenAuthenticator field and sync a potential referenced secret to openshift-kube-apiserver NS

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 22, 2020
@stlaz stlaz force-pushed the webhook-authenticators branch 2 times, most recently from b66e007 to 753ec77 Compare June 23, 2020 14:29
@stlaz
Copy link
Member Author

stlaz commented Jun 24, 2020

/retest

@stlaz stlaz force-pushed the webhook-authenticators branch 2 times, most recently from b6dbace to e40b56b Compare June 26, 2020 10:14
@stlaz stlaz changed the title [wip] add an observer for webhookTokenAuthenticator add an observer for webhookTokenAuthenticator Jun 29, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 29, 2020
@stlaz
Copy link
Member Author

stlaz commented Jun 29, 2020

/retest


if secretErrors := validateKubeconfigSecret(kubeconfigSecret); len(secretErrors) > 0 {
return existingConfig, append(errs,
fmt.Errorf("secret openshift-config/%s: %w", webhookSecretName, utilerrors.NewAggregate(secretErrors)))
Copy link
Contributor

Choose a reason for hiding this comment

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

secret openshift-config/%s is not a real error message. Am not sure that appending on aggregate error will look good at the end.

Copy link
Member Author

Choose a reason for hiding this comment

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

I turned it into an actual error message

resourceSyncer.SyncSecret(
resourcesynccontroller.ResourceLocation{Namespace: operatorclient.TargetNamespace, Name: "webhook-authenticator"},
resourcesynccontroller.ResourceLocation{Namespace: operatorclient.GlobalUserSpecifiedConfigNamespace, Name: webhookSecretName},
)
Copy link
Contributor

Choose a reason for hiding this comment

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

syncing from an observer is an unexpected side-effect. How do we do this elsewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is being done in other observers as well:

errs = append(errs, syncObservedResources(resourceSync, resourceSyncRules)...)

err = listers.ResourceSyncer().SyncConfigMap(
resourcesynccontroller.ResourceLocation{
Namespace: targetNamespaceName,
Name: "oauth-metadata",
},
resourcesynccontroller.ResourceLocation{
Namespace: sourceNamespace,
Name: sourceConfigMap,
},
)

We're handling the field that's a reference to a secret here, it makes sense to me to handle the sync as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is backed by the resource sync controller, which then essential does this:

	c.configMapSyncRules[destination] = source

So this sync is ongoing, the call only registers a rule, does not do the a synchronous sync. And a new, different source overrides the old source.

So, I think this is fine.


var (
webhookTokenAuthenticatorPath = []string{"apiServerArguments", "authentication-token-webhook-config-file"}
webhookTokenAuthenticatorFile = []interface{}{"/etc/kubernetes/static-pod-resources/secrets/webhook-authenticator/kubeConfig"}
Copy link
Member

Choose a reason for hiding this comment

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

is kubeConfig right? (usually it is kubeconfig)

Copy link
Member Author

Choose a reason for hiding this comment

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

as per API doc, this is expected

)
}

if observedWebhookConfigured != existingWebhookConfigured {
Copy link
Member

Choose a reason for hiding this comment

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

we usually use reflect.DeepEqual()

Copy link
Member Author

Choose a reason for hiding this comment

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

this is a comparison of two booleans

@mfojtik
Copy link
Member

mfojtik commented Jul 10, 2020

couple nits, LGTM otherwise

@mfojtik
Copy link
Member

mfojtik commented Jul 10, 2020

/lgtm
/approve

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 10, 2020
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mfojtik, stlaz

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 10, 2020
@stlaz
Copy link
Member Author

stlaz commented Jul 10, 2020

/retest

@openshift-merge-robot openshift-merge-robot merged commit 53f0782 into openshift:master Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants