Skip to content

Ensure AddPostStartHook always succeeds, or die - #15881

Merged
openshift-merge-robot merged 2 commits into
openshift:masterfrom
simo5:pshfatal
Aug 25, 2017
Merged

openshift-merge-robot merged 2 commits into
openshift:masterfrom
simo5:pshfatal

Conversation

@simo5

@simo5 simo5 commented Aug 21, 2017 •

Copy link
Copy Markdown

Fixes #15819

@simo5

simo5 commented Aug 21, 2017

Copy link
Copy Markdown
Author

@enj PTAL

@openshift-merge-robot openshift-merge-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 21, 2017
@simo5

simo5 commented Aug 21, 2017

Copy link
Copy Markdown
Author

Flake #15874

@simo5
simo5 requested a review from smarterclayton August 22, 2017 12:23
@simo5

simo5 commented Aug 22, 2017

Copy link
Copy Markdown
Author

Bug for the ansible flake:
openshift/openshift-ansible#5146

@simo5

simo5 commented Aug 22, 2017

Copy link
Copy Markdown
Author

/test extended_conformance_install_update

@sdodson

sdodson commented Aug 22, 2017

Copy link
Copy Markdown
Member

/retest
openshift-eng/aos-cd-jobs#578 should've fixed ci jobs

@simo5
simo5 requested review from enj and removed request for smarterclayton August 22, 2017 14:33
@simo5

simo5 commented Aug 22, 2017

Copy link
Copy Markdown
Author

@sdodson it's fixed, thanks

@simo5
simo5 force-pushed the pshfatal branch 2 times, most recently from 447368e to a1b4f50 Compare August 22, 2017 18:37
@simo5
simo5 requested a review from deads2k August 22, 2017 18:37
@openshift-merge-robot openshift-merge-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 22, 2017
@simo5

simo5 commented Aug 22, 2017

Copy link
Copy Markdown
Author

@deads2k PTAL

@simo5 simo5 changed the title Ensure RBAC PostStartHook fatals the server on error Ensure AddPostStartHook always succeeds, or die Aug 22, 2017
@enj

enj commented Aug 22, 2017

Copy link
Copy Markdown
Contributor

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Drive by - this casing is inconsistent and should be fixed

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sorry fail to see the inconsistency, ensure is lower case because it is a private function.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I could see camel-casing in this direction security.openshift.io-BootstrapSCC. The group matches the group, allows blind composition later, and sorts well.

@smarterclayton

smarterclayton commented Aug 22, 2017 via email

Copy link
Copy Markdown
Contributor

@enj

enj commented Aug 23, 2017

Copy link
Copy Markdown
Contributor

"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.

@deads2k what would like to change it to since you named it as such?

@deads2k

deads2k commented Aug 23, 2017

Copy link
Copy Markdown
Contributor

@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.

Comment thread pkg/cmd/server/origin/ensure.go Outdated

// 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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

ok

@simo5

simo5 commented Aug 23, 2017

Copy link
Copy Markdown
Author

@smarterclayton @deads2k for the casing, ok if we open a separate issue ?
I am not really touching those functions here, just changing a user, so the fact those names appear in this PR is just incidental.

@deads2k

deads2k commented Aug 23, 2017

Copy link
Copy Markdown
Contributor

@smarterclayton @deads2k for the casing, ok if we open a separate issue ?
I am not really touching those functions here, just changing a user, so the fact those names appear in this PR is just incidental.

I don't really care. The names aren't special.

@simo5

simo5 commented Aug 23, 2017

Copy link
Copy Markdown
Author

Ok I am opening a followup issue for the casing then, given that:

  • this PR is not really touching names
  • there seem no consensus on what they should be changed to anyway

@simo5

simo5 commented Aug 23, 2017

Copy link
Copy Markdown
Author

Ok move that discussion here #15926 please

@simo5

simo5 commented Aug 23, 2017

Copy link
Copy Markdown
Author

Updated @deads2k PTAL

@simo5

simo5 commented Aug 23, 2017

Copy link
Copy Markdown
Author

Flaked on #14575

@simo5

simo5 commented Aug 23, 2017

Copy link
Copy Markdown
Author

/test extended_conformance_gce

enj
enj previously requested changes Aug 23, 2017
return nil
}

// AddPostStartHookOrDie allows you to add a PostStartHook, but dies on failure

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dies on registration failure

}

// AddPostStartHookOrDie allows you to add a PostStartHook, but dies on failure
func (s *GenericAPIServer) AddPostStartHookOrDie(name string, hook PostStartHookFunc) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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]>
@simo5
simo5 dismissed enj’s stale review August 23, 2017 20:48

fixed upstream and here

@deads2k

deads2k commented Aug 24, 2017

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 24, 2017
@openshift-merge-robot

Copy link
Copy Markdown
Contributor

[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.

Details Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 24, 2017
@simo5

simo5 commented Aug 24, 2017

Copy link
Copy Markdown
Author

/test extended_conformance_gce

@openshift-merge-robot

Copy link
Copy Markdown
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@openshift-merge-robot

Copy link
Copy Markdown
Contributor

Automatic merge from submit-queue

@openshift-merge-robot
openshift-merge-robot merged commit d8e3a92 into openshift:master Aug 25, 2017
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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants