Repository navigation
Closed
Description
I'm finding that sometimes when I create a buildconfig and build in OpenShift, that Jenkins doesn't start the build.
I think what's happening is that the buildconfig and build are created very quickly and the Jenkins watches run in the wrong order - build first, then buildconfig afterwards.
Nov 11, 2016 2:01:48 PM org.openshift.jenkins.plugins.openshiftlogin.OpenShiftOAuth2SecurityRealm updateAuthorizationStrategy
INFO: OpenShift OAuth: adding permissions to user developer based on OpenShift roles [view, edit, admin]
Nov 11, 2016 2:02:12 PM io.fabric8.jenkins.openshiftsync.BuildTrigger stop
INFO: Stopping the OpenShift Build trigger for project NOT STARTED
Nov 11, 2016 2:02:12 PM io.fabric8.jenkins.openshiftsync.BuildTrigger stop
INFO: Stopping the OpenShift Build trigger for project nodejs-ex-pipeline
Nov 11, 2016 2:02:12 PM io.fabric8.jenkins.openshiftsync.BuildTrigger stop
INFO: Stopping the OpenShift Build trigger for project nodejs-ex-pipeline
Nov 11, 2016 2:02:12 PM io.fabric8.jenkins.openshiftsync.BuildTrigger stop
INFO: Stopping the OpenShift Build trigger for project NOT STARTED
Nov 11, 2016 2:02:12 PM io.fabric8.jenkins.openshiftsync.PipelineJobListener upsertItem
INFO: Updated WorkflowJob nodejs-ex-pipeline replicating changes to OpenShift
Nov 11, 2016 2:02:12 PM io.fabric8.jenkins.openshiftsync.BuildConfigWatcher$2 call
INFO: Created job nodejs-ex-pipeline from BuildConfig NamespaceName{myproject:nodejs-ex-pipeline} with revision: 1138
Nov 11, 2016 2:02:12 PM io.fabric8.jenkins.openshiftsync.BuildTrigger stop
INFO: Stopping the OpenShift Build trigger for project NOT STARTED
Nov 11, 2016 2:02:12 PM io.fabric8.jenkins.openshiftsync.BuildConfigWatcher$2 call
INFO: Updated job nodejs-ex-pipeline from BuildConfig NamespaceName{myproject:nodejs-ex-pipeline} with revision: 1139
Nov 11, 2016 2:02:12 PM io.fabric8.jenkins.openshiftsync.BuildTrigger stop
INFO: Stopping the OpenShift Build trigger for project NOT STARTED
Nov 11, 2016 2:02:12 PM io.fabric8.jenkins.openshiftsync.BuildConfigWatcher$2 call
INFO: Updated job nodejs-ex-pipeline from BuildConfig NamespaceName{myproject:nodejs-ex-pipeline} with revision: 1141
Metadata
Metadata
Assignees
Labels
No labels
Activity
jim-minter commentedon Nov 11, 2016
@gabemontero
@jimmidyson
@bparees
jimmidyson commentedon Nov 11, 2016
This is probably another problem of using watches: watch events are unordered for different resources. Have to think about that one.
bparees commentedon Nov 11, 2016
it's been a while since i tried it, but a long time ago you used to be able to
and the sync pipeline would do all the right stuff (create the jenkins job, start the build).
I would think as long as the build stays in the "new" state, the sync plugin should eventually detect it and start the relevant pipeline job once it exists, even if the first pass misses it (ie there should be some re-list logic in the sync plugin that periodically rescans for missed events)
jim-minter commentedon Nov 11, 2016
@bparees I'm not 100% sure that the problem is that Jenkins is receiving watch events in the wrong order, it's just a hunch.
Anyway empirically your scenario works fine (and is effectively identical if autoprovision is on). The issue I'm seeing is 3) 1) 2), and something causing Jenkins to discard the build in the NEW state and not then eventually detect it.
jimmidyson commentedon Nov 11, 2016
This possibly could be a race between BC update triggering job update (any BC change does that) which in turn stop/start Jenkins job trigger (as I'm learning, this happens on job update even if trigger is unchanged).
The re-list logic looks like it's going to be necessary to avoid that, although then how do you handle e.g. serial builds when you miss new build event for build 1, receive a new build event for build 2 which triggers jenkins job before next relist which would trigger jenkinsi job for missing new build event for build 1?
bparees commentedon Nov 11, 2016
for non-pipeline builds? i'm going to have to guess but i'd assume we'd wait for build 2 to finish, then run build 1. Serial means one at a time, but it doesn't (explicitly) guarantee in order execution i don't think. (though obviously that is the default expectation).
jimmidyson commentedon Nov 11, 2016
I meant for builds generally. So if order isn't guaranteed then that's fine. Will take a look at adding relists.
jimmidyson commentedon Nov 14, 2016
So what is a good relist interval do you think?
bparees commentedon Nov 14, 2016
i guess re-listing anytime we get a BC update (thus starting/stopping the trigger) would be too frequent since it would happen on every build (since the BC gets updated w/ the latest sequence id).
historically we've done re-list at 2 minute intervals, but it's a bit scary if that means the consistently we're going to see 2 minute waits for the first pipeline build.
Could we re-list whenever a BC gets created?
Can you detail the timing window that currently exists?
jim-minter commentedon Nov 21, 2016
@jimmidyson sorry, what do you mean by 'relist'?
jimmidyson commentedon Nov 21, 2016
@jim-minter Currently this plugin is event driven: an event is fired from OpenShift (new build request, build cancellation request, etc) & the plugin reacts accordingly (start build, cancel build, etc). Events are not guaranteed to be received (e.g. re-connection window) so the plugin will need to periodically query (relist) OpenShift to try to ensure that no events are missed.
bparees commentedon Nov 29, 2016
@jimmidyson you think this was fixed by the latest round of watcher/lister fixes?
jimmidyson commentedon Nov 29, 2016
Yep - thanks!
jim-minter commentedon Nov 30, 2016
Confirmed here.
jimmidyson commentedon Nov 30, 2016
Thanks @jim-minter
Merge pull request openshift#106 from gabemontero/goto1015