Skip to content

Jenkins fails to pick up first build of new buildconfig #106

Closed

Description

@jim-minter

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

Activity

  1. jim-minter commented on Nov 11, 2016

    @jim-minter
    Author
  2. jimmidyson commented on Nov 11, 2016

    @jimmidyson
    Contributor

    This is probably another problem of using watches: watch events are unordered for different resources. Have to think about that one.

  3. bparees commented on Nov 11, 2016

    @bparees

    it's been a while since i tried it, but a long time ago you used to be able to

    1. create the buildconfig
    2. start the build
    3. create jenkins (obviously this assumes autoprovision is off)

    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)

  4. jim-minter commented on Nov 11, 2016

    @jim-minter
    Author

    @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.

  5. jimmidyson commented on Nov 11, 2016

    @jimmidyson
    Contributor

    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?

  6. bparees commented on Nov 11, 2016

    @bparees

    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).

  7. jimmidyson commented on Nov 11, 2016

    @jimmidyson
    Contributor

    I meant for builds generally. So if order isn't guaranteed then that's fine. Will take a look at adding relists.

  8. jimmidyson commented on Nov 14, 2016

    @jimmidyson
    Contributor

    So what is a good relist interval do you think?

  9. bparees commented on Nov 14, 2016

    @bparees

    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?

  10. jim-minter commented on Nov 21, 2016

    @jim-minter
    Author

    @jimmidyson sorry, what do you mean by 'relist'?

  11. jimmidyson commented on Nov 21, 2016

    @jimmidyson
    Contributor

    @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.

  12. bparees commented on Nov 29, 2016

    @bparees

    @jimmidyson you think this was fixed by the latest round of watcher/lister fixes?

  13. jimmidyson commented on Nov 29, 2016

    @jimmidyson
    Contributor

    Yep - thanks!

  14. jim-minter commented on Nov 30, 2016

    @jim-minter
    Author

    Confirmed here.

  15. jimmidyson commented on Nov 30, 2016

    @jimmidyson
    Contributor
  16. added a commit that references this issue on Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions