You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Initial deployment of config with image and change triggers races with ImageStream tag event creation #2819
#2743 exposes some racy behavior between deployment controllers and ImageStream tag events on which the controllers rely. Given a DeploymentConfig with both image and change triggers, the following can happen:
The DeploymentConfigChangeController notices the new DeploymentConfig with LatestVersion 0 and attempts to generate a new DeploymentConfig with LatestVersion 1 (which would cause the initial deployment by the DeploymentConfigController later).
The ImageStream tag events referenced by the DeploymentConfig image triggers have not yet been populated by the system.
The generator call from step 1 fails because the generator attempts to validate the image trigger tag references against ImageStreams whose tag events have not yet been persisted.
The initial deployment attempt by the DeploymentConfigChangeController from step 1 fails, logs a message, and produces no events. The attempt is retried once, immediately.
In this case, the correct behavior is to create the initial deployment using whatever images were already assigned to the containers within the pod spec within the DeploymentConfig.
Talking with @abhgupta we began to wonder if this behavior is possibly correct. When using image triggers, you've asked openshift to manage the image field on the containers in your deployment's pod templates. Every time there's a config change or image change trigger event, we re-compute the container images based on your triggers and the latest ImageStream tag events. If we're unable to find the latest events at a point in time, is it reasonable to behave as today, where we stop with an error? If the ImageStream is later updated with new tag events, we'll attempt the deployment again.
In the specific race I outlined, I'm wondering why the case from #2743 didn't eventually succeed: if the initial deployment creation fails because no tag events are available, the initial creation should trigger again once the ImageStream's tags are populated, and the initial deployment should succeed. I can think of a case where a retry might never be attempted (config change for initial fires, fails due to missing tag events, imagestream event comes, image trigger is handled, but if the container image fields already happen to match what the trigger processing resolved from the tag events, there will be no diff and so no version bump and thus no deployment).
Let's try and agree on the correct behavior. Is the active rejection of the initial deployment attempt correct? If so we can work on ensuring the deployment does eventually happen. Otherwise we can specify the correct behavior.
Talking with @abhgupta we began to wonder if this behavior is possibly correct. When using image triggers, you've asked openshift to manage the image field on the containers in your deployment's pod templates.
You're asking Openshift to automatically redeploy you when you get new images on that tag. If that tag doesn't exist when your DC is created, there are two options. 1. It's a race, and you expect a tag shortly, and you don't expect to deploy twice. 2. It's intentional, and you want the app deployed using the images in the pod template.
There has to be something that the user can specify that distinguishes the two. It's probably a Boolean on the trigger, and the default value depends on whether 1 or 2 is common. It should be "wait" if the expected common case is 2, and some name that is the inverse if case 1 (so that users expect the default to be false).
Every time there's a config change or image change trigger event, we re-compute the container images based on your triggers and the latest ImageStream tag events. If we're unable to find the latest events at a point in time, is it reasonable to behave as today, where we stop with an error? If the ImageStream is later updated with new tag events, we'll attempt the deployment again.
In the specific race I outlined, I'm wondering why the case from #2743 didn't eventually succeed: if the initial deployment creation fails because no tag events are available, the initial creation should trigger again once the ImageStream's tags are populated, and the initial deployment should succeed. I can think of a case where a retry might never be attempted (config change for initial fires, fails due to missing tag events, imagestream event comes, image trigger is handled, but if the container image fields already happen to match what the trigger processing resolved from the tag events, there will be no diff and so no version bump and thus no deployment).
Let's try and agree on the correct behavior. Is the active rejection of the initial deployment attempt correct? If so we can work on ensuring the deployment does eventually happen. Otherwise we can specify the correct behavior.
—
Reply to this email directly or view it on GitHub.
@bparees This is the issue where we would appreciate some testing/validation help from you. The context is that if both config-change and image-change triggers are defined, then the config-change trigger can fail to create an initial deployment if the image tags are missing from the ImageStream resource. However, when the tags are available, we need to ensure that the image-change trigger fires and the deployment can be created.
Feel free to ping me or @ironcladlou in case something I said didn't make sense - my terminology regarding ImageStream and tags may not be precise.
@abhgupta@ironcladlou so you just want me to test the scenario? create a deployment referencing an imagestreamtag for which no image exists, modify the DC, see the deploy fail, then push an image an confirm it gets deployed?
For buildconfigs what we do is when the build is requested, if we can't resolve the imagestreamtag, we will retry for something like 30 minutes and then give up and fail the build. That covers the case where you create things simultaneously. I would have expected something similar from deploymentconfig so that i can update a deploymentconfig to point to a non-existent imagestream, then go create the imagestream.
of course as @ironcladlou notes, in that case the imagechange would also trigger the deploy so perhaps it's moot.
@abhgupta@ironcladlou so you just want me to test the scenario? create a deployment referencing an imagestreamtag for which no image exists, modify the DC, see the deploy fail, then push an image an confirm it gets deployed?
@abhgupta@ironcladlou I did an oc edit dc mydc and made a change, it did not result in a new deployment version and showed a failure in the logs:
I0610 11:49:03.553393 7208 controller.go:81] Ignoring DeploymentConfig change for default/router:1 (latestVersion=1); same as Deployment default/router-1
E0610 11:49:03.555136 7208 factory.go:68] couldn't create initial Deployment for DeploymentConfig default/frontend:0: DeploymentConfig "frontend" is invalid: triggers[0].imageChange.tag: invalid value 'latest': no image recorded for default/origin-ruby-sample:latest
I then triggered the build that pushed the imagestreamtag in question, which triggered an imagechange deployment which was successful.
Thanks @bparees - that resolves the immediate concerns for 3.0. Lowering the priority of this issue and keeping it to track the enhancements suggested by @smarterclayton in #2819 (comment)
@smarterclayton@abhgupta now that we have more experience with this scenario, I'm thinking this issue might be superceded by #3526. I don't think this issue as originally described is a problem, and is also slightly inaccurate (the original assessment implies there are no retries). The race isn't a problem, but the way we report it to users is. We just need the right mechanism to tell them what's wrong and what actions they can take.
Activity
ironcladlou commentedon Jun 4, 2015
cc @abhgupta @smarterclayton
ironcladlou commentedon Jun 5, 2015
Talking with @abhgupta we began to wonder if this behavior is possibly correct. When using image triggers, you've asked openshift to manage the image field on the containers in your deployment's pod templates. Every time there's a config change or image change trigger event, we re-compute the container images based on your triggers and the latest ImageStream tag events. If we're unable to find the latest events at a point in time, is it reasonable to behave as today, where we stop with an error? If the ImageStream is later updated with new tag events, we'll attempt the deployment again.
In the specific race I outlined, I'm wondering why the case from #2743 didn't eventually succeed: if the initial deployment creation fails because no tag events are available, the initial creation should trigger again once the ImageStream's tags are populated, and the initial deployment should succeed. I can think of a case where a retry might never be attempted (config change for initial fires, fails due to missing tag events, imagestream event comes, image trigger is handled, but if the container image fields already happen to match what the trigger processing resolved from the tag events, there will be no diff and so no version bump and thus no deployment).
Let's try and agree on the correct behavior. Is the active rejection of the initial deployment attempt correct? If so we can work on ensuring the deployment does eventually happen. Otherwise we can specify the correct behavior.
smarterclayton commentedon Jun 5, 2015
There has to be something that the user can specify that distinguishes the two. It's probably a Boolean on the trigger, and the default value depends on whether 1 or 2 is common. It should be "wait" if the expected common case is 2, and some name that is the inverse if case 1 (so that users expect the default to be false).
abhgupta commentedon Jun 10, 2015
@bparees This is the issue where we would appreciate some testing/validation help from you. The context is that if both config-change and image-change triggers are defined, then the config-change trigger can fail to create an initial deployment if the image tags are missing from the ImageStream resource. However, when the tags are available, we need to ensure that the image-change trigger fires and the deployment can be created.
Feel free to ping me or @ironcladlou in case something I said didn't make sense - my terminology regarding ImageStream and tags may not be precise.
bparees commentedon Jun 10, 2015
@abhgupta @ironcladlou so you just want me to test the scenario? create a deployment referencing an imagestreamtag for which no image exists, modify the DC, see the deploy fail, then push an image an confirm it gets deployed?
For buildconfigs what we do is when the build is requested, if we can't resolve the imagestreamtag, we will retry for something like 30 minutes and then give up and fail the build. That covers the case where you create things simultaneously. I would have expected something similar from deploymentconfig so that i can update a deploymentconfig to point to a non-existent imagestream, then go create the imagestream.
of course as @ironcladlou notes, in that case the imagechange would also trigger the deploy so perhaps it's moot.
ironcladlou commentedon Jun 10, 2015
I think that covers it
bparees commentedon Jun 10, 2015
@abhgupta @ironcladlou I did an oc edit dc mydc and made a change, it did not result in a new deployment version and showed a failure in the logs:
I0610 11:49:03.553393 7208 controller.go:81] Ignoring DeploymentConfig change for default/router:1 (latestVersion=1); same as Deployment default/router-1
E0610 11:49:03.555136 7208 factory.go:68] couldn't create initial Deployment for DeploymentConfig default/frontend:0: DeploymentConfig "frontend" is invalid: triggers[0].imageChange.tag: invalid value 'latest': no image recorded for default/origin-ruby-sample:latest
I then triggered the build that pushed the imagestreamtag in question, which triggered an imagechange deployment which was successful.
abhgupta commentedon Jun 10, 2015
Thanks @bparees - that resolves the immediate concerns for 3.0. Lowering the priority of this issue and keeping it to track the enhancements suggested by @smarterclayton in #2819 (comment)
ironcladlou commentedon Jul 1, 2015
@smarterclayton @abhgupta now that we have more experience with this scenario, I'm thinking this issue might be superceded by #3526. I don't think this issue as originally described is a problem, and is also slightly inaccurate (the original assessment implies there are no retries). The race isn't a problem, but the way we report it to users is. We just need the right mechanism to tell them what's wrong and what actions they can take.
ironcladlou commentedon Oct 1, 2015
Closing per #2819 (comment)