Repository navigation
Create a generic trigger controller for image streams - #13242
Conversation
|
[merge] |
| Instantiator BuildConfigInstantiator | ||
| } | ||
|
|
||
| func (r *BuildConfigReaction) ImageChanged(obj interface{}, is *imageapi.ImageStream, operations []TriggerOperation) error { |
There was a problem hiding this comment.
I think this is equivalent to the bc image_change_controller.
| // from is the object this should trigger from. The kind and name fields must be set. | ||
| From ObjectReference `json:"from"` | ||
| // fieldPath is a JSONPath string to the field to edit on the object. Required. | ||
| FieldPath string `json:"fieldPath"` |
| // namespaced, or if left empty on a namespaced object, means the current namespace. | ||
| Namespace string `json:"namespace,omitempty"` | ||
| // apiVersion is the group and version the type exists in. Optional. | ||
| APIVersion string `json:"apiVersion,omitempty"` |
There was a problem hiding this comment.
do we need Group here as well?
There was a problem hiding this comment.
APIVersion is group and version.
| return nil, false, nil | ||
| } | ||
| r.Namespace = m.GetNamespace() | ||
| r.Key = r.Namespace + "/" + m.GetName() |
There was a problem hiding this comment.
i believe there is a helper for this somewhere in indexer.
There was a problem hiding this comment.
It can return an error, which isn't the case here.
| if len(namespace) == 0 { | ||
| namespace = entry.Namespace | ||
| } | ||
| keys = append(keys, namespace+"/"+name) |
There was a problem hiding this comment.
and the same helper should be used here.
| return triggerCache{ | ||
| ThreadSafeStore: cache.NewThreadSafeStore( | ||
| cache.Indexers{ | ||
| "images": func(obj interface{}) ([]string, error) { |
There was a problem hiding this comment.
@Kargakis you were advocating last time I was making my private indexers that they should all live in shared package :-)
There was a problem hiding this comment.
Last time you didn't have a generic controller below you :)
| entry := obj.(*TriggerCacheEntry) | ||
| var keys []string | ||
| for _, t := range entry.Triggers { | ||
| if t.From.Kind != "ImageStreamTag" || len(t.From.APIVersion) != 0 || t.Paused { |
There was a problem hiding this comment.
@smarterclayton this will work just for images or do we plan to make it generic enough to work with other resource types, like secrets or config maps?
There was a problem hiding this comment.
A suggest has already been made for a PodPreset trigger. I think we can refactor this at that time - trigger.ObjectFieldTrigger is fairly generic, but not totally generic. Maybe pkg/trigger and then some helper code for this and others to be reused.
|
@smarterclayton this looks really good, I will have closer look later today :) |
|
@soltysh FYI since you were interested in this area |
|
As a follow-up to this, we should probably collapse DC config change triggers into the DC controller. |
0d0ef62 to
e066b6a
Compare
|
Ok, this should be close to a working prototype:
Because image stream triggers are level driven, we can keep merging the queued operations forever. If a triggered object and image stream are created at the same time, there is a window where:
However, we can queue incomplete operations for the triggered object (tag didn't exist, go ahead and queue the operation), and as part of the resourceWorker do a lazy lookup on those tags. If the tags don't exist, requeue for later (backoff). That should ensure that we don't miss an update cycle. That is not yet implemented here. |
e066b6a to
9daaa24
Compare
|
Fixed the race condition - I check the for image updates on a triggered object after the item is added to the index - that means that either the image is in the cache already (processed by imageStreamWorker) or guaranteed to get the item from the index in the imageStreamWorker if it hasn't completed. |
c6dd9b0 to
263d9da
Compare
| } | ||
|
|
||
| // ObjectReference identifies an object by its name and kind. | ||
| type ObjectReference struct { |
There was a problem hiding this comment.
Why not use the existing ObjectReference type?
There was a problem hiding this comment.
So that it's not dependent on kapi. Also doesn't need the same fields. Still effectively versioned, but not tied to Kube.
| "github.com/openshift/origin/pkg/image/api/v1/trigger" | ||
| ) | ||
|
|
||
| func calculateBuildConfigTriggers(bc *buildapi.BuildConfig, retrieveOperations bool) ([]trigger.ObjectFieldTrigger, []TriggerOperation) { |
| } | ||
|
|
||
| // ImageStreamNamespaceLister helps list and get ImageStreams. | ||
| type ImageStreamNamespaceLister interface { |
There was a problem hiding this comment.
The listers and informers in this file need to move to a different place.
There was a problem hiding this comment.
This is waiting for Andy's rebase anyway, so generated informers makes this irrelevant.
|
Try to keep the deployment example in a separate commit to make clearer what's needed for adding support for a resource. |
263d9da to
064c600
Compare
| Instantiate(namespace string, request *buildapi.BuildRequest) (*buildapi.Build, error) | ||
| } | ||
|
|
||
| type BuildConfigReaction struct { |
07cab0b to
fc12799
Compare
| @@ -0,0 +1,24 @@ | |||
| package trigger | |||
There was a problem hiding this comment.
Should move out of the image api
There was a problem hiding this comment.
These triggers are image specific. The struct is under the API because they are serialized into annotations for the generic path.
|
Evaluated for origin merge up to fb5994d |
|
[test]
…On Mon, May 15, 2017 at 3:29 PM, OpenShift Bot ***@***.***> wrote:
continuous-integration/openshift-jenkins/testextended FAILURE (
https://ci.openshift.redhat.com/jenkins/job/test_pull_
request_origin_extended/396/) (Base Commit: a740a1a
<a740a1a>)
(Extended Tests: core(build))
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#13242 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_p4UrqIbHxJ6qsFHFQmAza9KDSNBjks5r6KewgaJpZM4MTt7h>
.
|
|
[test] |
|
[test]
…On Tue, May 16, 2017 at 5:42 PM, OpenShift Bot ***@***.***> wrote:
continuous-integration/openshift-jenkins/test SUCCESS (
https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/1504/)
(Base Commit: 5de6326
<5de6326>
)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#13242 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_pwF2fv8NUVSmqN48qkpuPO5xkMn5ks5r6hgsgaJpZM4MTt7h>
.
|
fb5994d to
d17781c
Compare
|
#14156 [test] |
d17781c to
ede55af
Compare
Build a cache from changes to a set of watched objects that allow us to efficiently detect which objects can be *triggered* by image changes. Add a controller that watches image streams and mutates those objects whenever the tag reference in the object no longer points to the same docker image reference. Fit the existing deployment config and build config triggers into this framework, and add support for a new annotation based trigger. The annotation trigger will use an array of references serialized under key `image.alpha.openshift.io/triggers` that points to an image stream tag and identifies a field path to mutate. Rather than implementing a generic field path accessor, we define fast paths for known object types. Future work should be able to leverage the unstructured type to add triggers for third party resources or other unknown objects. Note that triggers do not grant access to pull images.
Only on a limited set of types for now. Future work should detect which types can have triggers.
We were not identifying container names correctly.
Remove the old build image trigger controller
ede55af to
0aec48e
Compare
|
Evaluated for origin testextended up to 0aec48e |
|
Evaluated for origin test up to 0aec48e |
|
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/1545/) (Base Commit: b370e3a) |
|
continuous-integration/openshift-jenkins/testextended FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_extended/421/) (Base Commit: b370e3a) (Extended Tests: core(build)) |
|
In order to get more soak on this I'm going to direct merge to bypass the queue. |
|
We need the soak time in master more than the other things in the queue do. |
Create the structure for a generic image change trigger controller. The controller is passed a set of informers, which also specify how the data is loaded off the object for triggers and how the updated image is processed. The controller indexes triggers to provide O(1) notifications, and in theory, based on a shared informer, should be as efficient as can be.
Demonstrates how an annotation based trigger could be loaded and how builds can be triggered.
TODOs:
@bparees @mfojtik