-
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
lookup buildconfigs in shared indexed cache instead of listing #10923
lookup buildconfigs in shared indexed cache instead of listing #10923
Conversation
6a58a10
to
e5a4636
Compare
@Kargakis @smarterclayton ptal |
[test] |
[testextended][extended:core(builds)] |
}, | ||
} | ||
} | ||
|
||
func (factory *ImageChangeControllerFactory) waitForSyncedStores() { | ||
for !factory.BuildConfigIndexSynced() { |
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.
@Kargakis this appears to never return true... am I missing some additional initialization step?
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 would suggest rewritting the controller to use Informers instead of the RunnableController framework. Currently nothing initializes the cache so it never syncs. By using the shared informer framework, the master will do it for you.
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.
yeah i'm not signing up for rewriting the controllers just yet, that's a much larger piece of work so for now i just want to fix the performance problem.
when i remove the sync check, it actually does work, so the cache is getting properly populated. I couldn't tell from your other PR what is supposed to trigger the cache to be initialized..I assumed since it was a shared informer, that should already be happening even if i'm not using it...
94fe34b
to
e30d636
Compare
@@ -291,7 +291,9 @@ func (c *MasterConfig) RunBuildPodController() { | |||
func (c *MasterConfig) RunBuildImageChangeTriggerController() { | |||
bcClient, _ := c.BuildImageChangeTriggerControllerClients() | |||
bcInstantiator := buildclient.NewOSClientBuildConfigInstantiatorClient(bcClient) | |||
factory := buildcontrollerfactory.ImageChangeControllerFactory{Client: bcClient, BuildConfigInstantiator: bcInstantiator} | |||
bcIndex := &oscache.StoreToBuildConfigListerImpl{c.Informers.BuildConfigs().Indexer()} | |||
bcIndexSynced := c.Informers.BuildConfigs().Informer().HasSynced |
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.
@Kargakis the informer is being created/initialized here, no?
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 method starts all shared informers and it's called in master here.
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.
right, so why is my cache never synced? my informer should be one of the ones getting started, right?
e30d636
to
dfc6fdc
Compare
You have to call .Informer() prior to RunBuildPodController - otherwise On Thu, Sep 15, 2016 at 12:12 PM, OpenShift Bot [email protected]
|
@smarterclayton i am: the issue appears to be that despite putting this in a go routine: everything hangs inside the waitForSync called within the Create() function, and the sync never occurs unless the main thread is able to make progress. I've even added runtime.Gosched() calls inside my wait loop, but it seems to never give up control so it can return. |
dfc6fdc
to
584b411
Compare
factory := buildcontrollerfactory.ImageChangeControllerFactory{Client: bcClient, BuildConfigInstantiator: bcInstantiator, BuildConfigIndex: bcIndex, BuildConfigIndexSynced: bcIndexSynced} | ||
go func() { | ||
factory.Create().Run() | ||
}() |
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.
@smarterclayton @Kargakis this was the issue. go factory.Create().Run()
hangs everything because the Create() call (which is where i'm doing the wait for sync operation) is not run in a go routine. sigh.
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.
You should not have to call Run(). master.Start should be calling Start for you after you exit. If that's not the case, debug until you find out why.
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.
@smarterclayton
Every other controller that's being created is calling its own run method after creating the controller. Are you saying these are all wrong?
https://github.com/openshift/origin/blob/master/pkg/cmd/server/origin/run_components.go#L88-L89
https://github.com/openshift/origin/blob/master/pkg/cmd/server/origin/run_components.go#L108
https://github.com/openshift/origin/blob/master/pkg/cmd/server/origin/run_components.go#L158
https://github.com/openshift/origin/blob/master/pkg/cmd/server/origin/run_components.go#L176
https://github.com/openshift/origin/blob/master/pkg/cmd/server/origin/run_components.go#L337
https://github.com/openshift/origin/blob/master/pkg/cmd/server/origin/run_components.go#L358
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.
Ok, I was looking at something else before. This is fine.
Do not call factory.Create.Run() yourself. Load the informer in master On Thu, Sep 15, 2016 at 4:02 PM, OpenShift Bot [email protected]
|
Hm? That factory is for the controller, not the informer, it's the same pattern And the informer is being created the same way the other controllers are Ben Parees | OpenShift On Sep 15, 2016 23:13, "Clayton Coleman" [email protected] wrote:
|
func (factory *ImageChangeControllerFactory) waitForSyncedStores() { | ||
for !factory.BuildConfigIndexSynced() { | ||
glog.V(4).Infof("Waiting for the bc caches to sync before starting the imagechange buildconfig controller worker") | ||
<-time.After(StoreSyncedPollPeriod) |
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.
select between this and Stop
return configs, nil | ||
} | ||
|
||
func (s *StoreToBuildConfigListerImpl) buildconfigs(namespace string) storebuildconfigsNamespacer { |
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.
Should be exported.
@@ -15,6 +17,40 @@ const ( | |||
func ImageStreamReferenceIndexFunc(obj interface{}) ([]string, error) { | |||
switch t := obj.(type) { | |||
// TODO: Add support for build configs |
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.
remove TODO
584b411
to
7e63abc
Compare
@Kargakis thanks, comments addressed. |
flake #10951 |
continuous-integration/openshift-jenkins/test Waiting: Determining build queue position |
return nil, err | ||
} | ||
if !exists { | ||
return nil, kapierrors.NewNotFound(buildapi.Resource("BuildConfig"), name) |
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.
should be "buildconfigs"
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.
should this be deploymentconfigs as well?
https://github.com/openshift/origin/blob/master/pkg/client/cache/deploymentconfig.go#L89
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.
Yes - anyplace you see "Resource" should be treated like the lower case name as seen by the client.
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.
has been changed.
} | ||
|
||
var configs []*buildapi.BuildConfig | ||
|
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.
no newline here
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 a pattern previously established but sure...will delete.
https://github.com/openshift/origin/blob/master/pkg/client/cache/deploymentconfig.go#L63-L65
} | ||
|
||
func (s *StoreToBuildConfigListerImpl) BuildConfigs(namespace string) storebuildconfigsNamespacer { | ||
return storebuildconfigsNamespacer{s.Indexer, namespace} |
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.
storeBuildConfigsNamespacer (camelCase)
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.
will do.
// GetConfigsForImageStream returns all the build configs that are triggered by the provided image stream | ||
// by searching through using the ImageStreamReferenceIndex (build configs are indexed in the cache | ||
// by image stream references). | ||
func (s *StoreToBuildConfigListerImpl) GetConfigsForImageStreamTrigger(stream *imageapi.ImageStream) ([]*buildapi.BuildConfig, 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.
I don't love taking an image stream here - it would be better to take a stream namespace and name.
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 followed the pattern that was already established:
https://github.com/openshift/origin/blob/master/pkg/client/cache/deploymentconfig.go#L57
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 don't love taking an image stream here. I'd prefer these look like StoreToReplicationControllerLister
. DeploymentConfig is old.
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 don't see an equivalent example in StoreToReplicationControllerLister, GetPodControllers() for example takes a Pod object, not a namespace+podname. Which is done because it needs the pod labels. But there's no other similar "look up by this other index object" example.
I kind of prefer this existing signature because it also makes it clear the object you are to pass in must be an ImageStream, whereas just taking (string,string) does not make that as obvious. It also leaves us the freedom to use other parts of the imagestream for the lookup in the future w/o refactoring anything. What is the advantage/reason for preferring (namespace,name) as the signature?
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.
We're trying to converge these accessors on the client interfaces, so taking namespace and name is closer to the actual goal. Also creating the object in some contexts is silly (create a whole deployment config to provide a name and namespace) and can actually hide the fact that only namespace and name should be used.
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.
@deads2k - @smarterclayton says you get the final say on this. see discussion 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.
@deads2k - @smarterclayton says you get the final say on this. see discussion above.
Namespace and name please. For the same reasons clayton listed.
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.
will change.
// TODO: Add support for build configs | ||
case *buildapi.BuildConfig: | ||
var keys []string | ||
|
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.
no newline
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'll delete the one in the deploymentconfig case just below this as well.... though personally i like a newline separation between variable declarations and code logic.
// uses the input image of the buildconfig as the imagestream | ||
// to trigger off, so we need to look that up. | ||
if from == nil { | ||
from = buildutil.GetInputReference(t.Spec.Strategy) |
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.
You need to index on source.
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.
what source?
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 source
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'm still confused. Why do i need to index on build source? we're not doing any lookups on build source currently. (and by build source what build source do you mean? git source? image input source? secret-as-source?)
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.
Don't you have to check .Spec.Source.Images
in order to find the other triggers?
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.
no. will add a more explanatory comment in the code.
7e63abc
to
177b021
Compare
@smarterclayton changes i understood have been made. still not clear what you're saying about invoking Run() on the controller after creation, or what you mean about indexing on source. |
1ed11db
to
aba0916
Compare
flake #10773 |
@smarterclayton pushed changes in a new commit. unresolved comments:
|
@smarterclayton bump on #10923 (comment) |
@smarterclayton need to resolve #10923 (comment) |
3ee36a2
to
f5a2cd8
Compare
@smarterclayton ok the comment block in index.go has been updated to explain what's going on with the imagetrigger indexing. other than the open question of what the right signature is for |
f5a2cd8
to
85adf0f
Compare
@smarterclayton this is ready for final review. |
// instead it triggers on the image being used as the builder/base image | ||
// as referenced in the build strategy, so if this is an ICT w/ no | ||
// explicit image reference, use the image referenced by the strategy | ||
// because this is the default ICT. |
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.
As a note for the next version of the API, we should default this onto the ICT so that it's explicit rather than being implicit. Implicit creates more complicated code and complicates clients.
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 think we needed this because our first version of the ICT didn't even let you specify the image, so this default behavior was needed to maintain compatibility.
Please squash |
85adf0f
to
58ef19d
Compare
I think you broke the shared build config test making it flake now On Tue, Sep 27, 2016 at 12:22 PM, OpenShift Bot [email protected]
|
Removing merge until we can be sure it isn't impacted. |
got a link to the failure? |
@smarterclayton so the failure on TestConcurrentBuildImageChangeTriggerControllers is because the cache never syncs. I don't know why that isn't affecting other imagechangetrigger tests... is there something about multiple controllers running that is going to stop the cache from reaching a synced state?
|
@smarterclayton @deads2k i think the failure was caused because the namespace and name arguments were reversed when i switched the api from taking an imagestream. Which is another example of why i think that's a bad api and it's better to take the explicit object instead of 2 strings that can be reversed and cause subtle bugs. |
58ef19d
to
afbbd76
Compare
[merge] |
afbbd76
to
373b27b
Compare
Evaluated for origin testextended up to 373b27b |
Evaluated for origin test up to 373b27b |
continuous-integration/openshift-jenkins/testextended SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin_extended/529/) (Extended Tests: core(builds)) |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/9406/) |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/9406/) (Image: devenv-rhel7_5093) |
Evaluated for origin merge up to 373b27b |
[merge] |
fixes #10616