Merge Request Jenkins Race Condition
Summary
There is a race condition when Only allow merge requests to be merged if the pipeline succeeds is set for a project with Jenkins integrations. Merges are allowed after a push to gitlab but before the Jenkins pipeline has started (it usually takes 30ish seconds for our build to get running on an executor). This allows users to merge untested code. This issue was also reported a year agon on the ce tracker (https://gitlab.com/gitlab-org/gitlab-ce/issues/45775)
Steps to reproduce
- Set up a project with Gitlab-Jenkins integration using webhooks
- Set
Only allow merge requests to be merged if the pipeline succeedsin the project configuration - Create a feature branch off of master
- Create a merge request to merge the feature branch into master
- Push a commit to the feature branch in Gitlab
- Immediately after pushing hit the 'merge' button to merge the feature branch into master without running the tests
What is the current bug behavior?
Users can merge code to a project with the Only allow merge requests to be merged if the pipeline succeeds before the Jenkins pipeline has started
What is the expected correct behavior?
Users cannot merge code to a project with the Only allow merge requests to be merged if the pipeline succeeds before the Jenkins pipeline has started
Results of GitLab environment info
Expand for output related to GitLab environment info
$ sudo gitlab-rake gitlab:env:infoSystem information System: CentOS 7.3.1611 Proxy: no Current User: git Using RVM: no Ruby Version: 2.4.4p296 Gem Version: 2.7.6 Bundler Version:1.16.2 Rake Version: 12.3.1 Redis Version: 3.2.11 Git Version: 2.17.1 Sidekiq Version:5.1.3 Go Version: unknown
GitLab information Version: 11.0.4-ee Revision: 3350cd6 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql DB Version: 9.6.8 URL: [REDACTED] HTTP Clone URL: [REDACTED] SSH Clone URL: [REDACTED] Elasticsearch: no Geo: no Using LDAP: yes Using Omniauth: no
GitLab Shell Version: 7.1.4 Repository storage paths: default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
$ sudo gitlab-rake gitlab:check SANITIZE=true Checking GitLab Shell ...GitLab Shell version >= 7.1.4 ? ... OK (7.1.4) Repo base directory exists? default... yes Repo storage directories are symlinks? default... no Repo paths owned by git:root, or git:git? default... yes Repo paths access is drwxrws---? default... yes hooks directories in repos are links: ... 5/1 ... ok 9/3 ... ok 9/6 ... ok 9/7 ... ok 9/8 ... ok 5/9 ... ok 9/10 ... ok 4/11 ... ok 9/14 ... ok 5/15 ... ok 36/17 ... ok 20/19 ... ok 20/20 ... ok 41/25 ... ok 5/27 ... ok 9/28 ... ok 5/29 ... ok 6/30 ... ok 5/33 ... ok 5/34 ... ok 20/35 ... ok Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Reply by email is disabled in config/gitlab.yml Checking LDAP ...
Server: [REDACTED] LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) [REDACTED] Checking LDAP ... Finished
Checking GitLab ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 5/1 ... yes 9/3 ... yes 9/6 ... yes 9/7 ... yes 9/8 ... yes 5/9 ... yes 9/10 ... yes 4/11 ... yes 9/14 ... yes 5/15 ... yes 36/17 ... yes 20/19 ... yes 20/20 ... yes 41/25 ... yes 5/27 ... yes 9/28 ... yes 5/29 ... yes 6/30 ... yes 5/33 ... yes 5/34 ... yes 20/35 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.4.4) Git version >= 2.9.5 ? ... yes (2.17.1) Git user has default SSH configuration? ... yes Active users: ... [REDACTED] Elasticsearch version 5.1 - 5.5? ... skipped (elasticsearch is disabled)
Checking GitLab ... Finished
merge requests ~bug ~P3 ~S3 devopsverify Verify