-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Refactor Build Controller to use Informers #14289
Conversation
[test] |
@bparees I'm still working on unit tests, but wanted to get this up sooner than later; ptal |
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.
my main concern is around the possibility of re-introducing races when updating the build status reason/message fields.
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: v1core.New(params.KubeClientExternal.Core().RESTClient()).Events("")}) | ||
|
||
buildListerUpdater := buildclient.NewOSClientBuildClient(params.OpenshiftClient) | ||
buildDeleter := buildclient.NewBuildDeleter(params.OpenshiftClient) |
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.
is there a good reason that NewOSClientBuildClient{} doesn't include implement Delete itself, rather than us having a separate buildDeleter{}?
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.
Nope, we can certainly change that
} | ||
|
||
<-stopCh | ||
glog.Infof("Shutting down build pod controller") |
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.
build controller.
return nil | ||
} | ||
|
||
func shouldIgnore(build *buildapi.Build) bool { |
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.
godoc
return update, nil | ||
} | ||
|
||
func (bc *BuildController) handleNewBuild(build *buildapi.Build, willBeDropped bool, pod *kapi.Pod, podErr error) (*buildUpdate, error) { |
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.
godoc
return bc.createBuildPod(build) | ||
} | ||
|
||
func (bc *BuildController) createPodSpec(originalBuild *buildapi.Build, ref string) (*kapi.Pod, error) { |
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.
godoc
@@ -0,0 +1,46 @@ | |||
package build |
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.
filename: podcreationstrategy.go
otherwise i'd expect this to create builds, given the package it's in.
case build.Spec.Strategy.CustomStrategy != nil: | ||
pod, err = f.customBuildStrategy.CreateBuildPod(build) | ||
case build.Spec.Strategy.JenkinsPipelineStrategy != nil: | ||
return nil, nil |
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.
it should be an error if we get here.
rbac.NewRule("get").Groups(imageGroup, legacyImageGroup).Resources("imagestreams").RuleOrDie(), | ||
rbac.NewRule("get", "list", "create", "delete").Groups(kapiGroup).Resources("pods").RuleOrDie(), | ||
rbac.NewRule("get", "list").Groups(imageGroup, legacyImageGroup).Resources("imagestreams").RuleOrDie(), | ||
rbac.NewRule("get", "list").Groups(imageGroup, legacyImageGroup).Resources("secrets").RuleOrDie(), |
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.
group looks wrong for secrets?
@@ -7,8 +7,7 @@ import ( | |||
|
|||
builddefaults "github.com/openshift/origin/pkg/build/admission/defaults" | |||
buildoverrides "github.com/openshift/origin/pkg/build/admission/overrides" | |||
buildclient "github.com/openshift/origin/pkg/build/client" | |||
buildcontrollerfactory "github.com/openshift/origin/pkg/build/controller/factory" | |||
buildcontroller "github.com/openshift/origin/pkg/build/controller/build" |
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.
is there a compelling reason not to fold this whole file into build_controller.go?
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.
this is part of @deads2k's recent change to the build controller. I believe this is a pattern we want to following going forward?
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.
hm. it looks weird to me, but i'll ignore it for now.
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.
Eventually we want to push this wiring down into sub-repos, but it wasn't a primary objective and we don't have a solid interface yet. Right now, the it would create really strange interdependencies.
pkg/cmd/server/start/start_master.go
Outdated
@@ -754,7 +754,6 @@ func startControllers(oc *origin.MasterConfig, kc *kubernetes.MasterConfig) erro | |||
|
|||
// no special order | |||
if configapi.IsBuildEnabled(&oc.Options) { | |||
oc.RunBuildPodController() |
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.
i'd like to understand why this block is special, instead of handling the buildconfigchangecontroller in the for loop above.
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.
the loop above is for the new style of controllers (where they live in an array and initialized via a function in that array) (ala kube). We have not yet changed the config change controller to initialize in that way.
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.
got it.
@bparees please take a look at the last commit. I addressed your comments and changed the way we handle details updates from the pod to use annotations. I really don't like the potential for races on the build phase/reason/message. I'd rather have the build controller be the only one that can update those. |
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.
couple nits but i like it and thanks for the speedy turnaround!
|
||
return update, nil | ||
} | ||
|
||
// handleNewBuild will check whether policy allows running the new build and if so, creates a pod | ||
// for the build and returns and update to move it to the Pending phase |
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.
s/and/an/
} | ||
if _, ok := build.Annotations[buildapi.BuildPodRequestedMessageAnnotation]; ok { | ||
update.setMessage(build.Annotations[buildapi.BuildPodRequestedMessageAnnotation]) | ||
} |
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.
cool, i like this!
pkg/build/registry/build/strategy.go
Outdated
|
||
newBuild.Annotations[api.BuildPodRequestedPhaseAnnotation] = string(phase) | ||
newBuild.Annotations[api.BuildPodRequestedReasonAnnotation] = string(reason) | ||
newBuild.Annotations[api.BuildPodRequestedMessageAnnotation] = message |
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.
godoc needs updating w/ this behavior change.
a65f31b
to
46ed2ab
Compare
Updates made, new annotation constants will require @openshift/api-review |
d03414f
to
8b2a09b
Compare
[test] |
@bparees still don't have a clean test. Latest run has one extended test failing... |
[testextended][extended:core(builds)] |
Just realized I didn't tag the entire team... apologies. @openshift/devex ptal |
@openshift/api-review bump |
add the code comment and i think it's ready for merge. feel free to put the tag on yourself after you add the comment. |
Removed special case for pending transition |
t := true | ||
pod.OwnerReferences = []metav1.OwnerReference{ | ||
{ | ||
APIVersion: "v1", |
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.
must be build.openshift.io/v1
`
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.
also consider something like:
https://github.com/openshift/origin/pull/14582/files#diff-d09310d3307d040cedbddcd5fa308067R30
t := true | ||
pod.OwnerReferences = []metav1.OwnerReference{ | ||
{ | ||
APIVersion: "v1", |
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.
@mfojtik noted that this needs to be buildapiv1.SchemeGroupVersion
6036be8
to
71846a9
Compare
rebased and fixed compile error with ImageStream informer |
Fixed unit test to use generated informer for ImageStreams |
Flake #13984 on extended test |
[testextended][extended:core(builds)] |
Evaluated for origin testextended up to 3091d6a |
continuous-integration/openshift-jenkins/testextended FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_extended/613/) (Base Commit: 0ab5ccf) (Extended Tests: core(builds)) |
[test] |
Evaluated for origin test up to 3091d6a |
[merge] |
Evaluated for origin merge up to 3091d6a |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/1003/) (Base Commit: eb50c84) (Extended Tests: blocker) (Image: devenv-rhel7_6361) |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/2254/) (Base Commit: 811a267) |
Collapses the build and build pod controller into a single controller using informers