Repository navigation
Ensure AddPostStartHook always succeeds, or die - #15881
Conversation
|
@enj PTAL |
|
Flake #15874 |
|
Bug for the ansible flake: |
|
/test extended_conformance_install_update |
|
/retest |
|
@sdodson it's fixed, thanks |
447368e to
a1b4f50
Compare
|
@deads2k PTAL |
|
This LGTM, but I will wait for David to have a look. |
| ensureAddPostStartHook(s.GenericAPIServer, "project.openshift.io-projectcache", c.startProjectCache) | ||
| ensureAddPostStartHook(s.GenericAPIServer, "project.openshift.io-projectauthorizationcache", c.startProjectAuthorizationCache) | ||
| ensureAddPostStartHook(s.GenericAPIServer, "security.openshift.io-bootstrapscc", c.bootstrapSCC) | ||
| ensureAddPostStartHook(s.GenericAPIServer, "authorization.openshift.io-ensureSARolesDefault", c.ensureDefaultNamespaceServiceAccountRoles) |
There was a problem hiding this comment.
Drive by - this casing is inconsistent and should be fixed
There was a problem hiding this comment.
Sorry fail to see the inconsistency, ensure is lower case because it is a private function.
There was a problem hiding this comment.
I could see camel-casing in this direction security.openshift.io-BootstrapSCC. The group matches the group, allows blind composition later, and sorts well.
|
"authorization.openshift.io-ensureSARolesDefault" is inconsistent with
every other hook name because it has upper case letters. If we have a
pattern, we should follow it.
…On Tue, Aug 22, 2017 at 5:35 PM, Simo Sorce ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pkg/cmd/server/origin/openshift_apiserver.go
<#15881 (comment)>:
> @@ -342,12 +342,12 @@ func (c completedConfig) New(delegationTarget genericapiserver.DelegationTarget)
initOpenshiftVersionRoute(s.GenericAPIServer.Handler.GoRestfulContainer, "/version/openshift")
// register our poststarthooks
- s.GenericAPIServer.AddPostStartHook("quota.openshift.io-clusterquotamapping", c.startClusterQuotaMapping)
- s.GenericAPIServer.AddPostStartHook("project.openshift.io-projectcache", c.startProjectCache)
- s.GenericAPIServer.AddPostStartHook("project.openshift.io-projectauthorizationcache", c.startProjectAuthorizationCache)
- s.GenericAPIServer.AddPostStartHook("security.openshift.io-bootstrapscc", c.bootstrapSCC)
- s.GenericAPIServer.AddPostStartHook("authorization.openshift.io-ensureSARolesDefault", c.ensureDefaultNamespaceServiceAccountRoles)
- s.GenericAPIServer.AddPostStartHook("authorization.openshift.io-ensureopenshift-infra", c.ensureOpenShiftInfraNamespace)
+ ensureAddPostStartHook(s.GenericAPIServer, "quota.openshift.io-clusterquotamapping", c.startClusterQuotaMapping)
+ ensureAddPostStartHook(s.GenericAPIServer, "project.openshift.io-projectcache", c.startProjectCache)
+ ensureAddPostStartHook(s.GenericAPIServer, "project.openshift.io-projectauthorizationcache", c.startProjectAuthorizationCache)
+ ensureAddPostStartHook(s.GenericAPIServer, "security.openshift.io-bootstrapscc", c.bootstrapSCC)
+ ensureAddPostStartHook(s.GenericAPIServer, "authorization.openshift.io-ensureSARolesDefault", c.ensureDefaultNamespaceServiceAccountRoles)
Sorry fail to see the inconsistency, ensure is lower case because it is a
private function.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#15881 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_p8fO_BVp7neFOknOeVHPtrmUMwBAks5sa0mmgaJpZM4O9kJl>
.
|
@deads2k what would like to change it to since you named it as such? |
I'm biased towards lower case. Notice that the groups match, then a dash, then a camelCase name. |
|
|
||
| // TODO: We should have a single place where we register all post start hook | ||
| // and make this function unnecessary | ||
| func ensureAddPostStartHook(genericAPIServer *genericapiserver.GenericAPIServer, name string, hook genericapiserver.PostStartHookFunc) { |
There was a problem hiding this comment.
Move this upstream. AddPostStartHookOrDie. We want the separate function with an error to allow testing of the error condition (collision on names as I recall).
There was a problem hiding this comment.
@deads2k upstream doesn't really need it as they run all their AddPostStartHook() calls into a function that already fatals if an error is returned. So it seem like upstreaming an OrDie version there would be useless for upstream.
That's why we have a TODO to create also a registration function in origin as well that properly deal with it at some point.
There was a problem hiding this comment.
@deads2k upstream doesn't really need it as they run all their AddPostStartHook() calls into a function that already fatals if an error is returned. So it seem like upstreaming an OrDie version there would be useless for upstream.
I don't think they'll object to having an OrDie variant and it makes out dependency set cleaner as collapse onto upstream.
|
@smarterclayton @deads2k for the casing, ok if we open a separate issue ? |
I don't really care. The names aren't special. |
|
Ok I am opening a followup issue for the casing then, given that:
|
|
Ok move that discussion here #15926 please |
|
Updated @deads2k PTAL |
|
Flaked on #14575 |
|
/test extended_conformance_gce |
| return nil | ||
| } | ||
|
|
||
| // AddPostStartHookOrDie allows you to add a PostStartHook, but dies on failure |
| } | ||
|
|
||
| // AddPostStartHookOrDie allows you to add a PostStartHook, but dies on failure | ||
| func (s *GenericAPIServer) AddPostStartHookOrDie(name string, hook PostStartHookFunc) error { |
There was a problem hiding this comment.
This should not return anything.
| // AddPostStartHookOrDie allows you to add a PostStartHook, but dies on failure | ||
| func (s *GenericAPIServer) AddPostStartHookOrDie(name string, hook PostStartHookFunc) error { | ||
| err := s.AddPostStartHook(name, hook) | ||
| if err != nil { |
There was a problem hiding this comment.
if err := s.AddPostStartHook(name, hook); err != nil {
It is nice to have variables scoped to an if statement.
Simplifies usage and consolidate the error message so it is always the same everywhere. Signed-off-by: Simo Sorce <[email protected]>
Or die. Signed-off-by: Simo Sorce <[email protected]>
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: deads2k, simo5 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 |
|
/test extended_conformance_gce |
|
/test all [submit-queue is verifying that this PR is safe to merge] |
|
Automatic merge from submit-queue |
Fixes #15819