Allow local requests from web hooks and services takes some time to get enabled

Summary

"Allow local requests from web hooks and services" takes some time to get enabled. This forces end-to-end tests to use a workaround such as wait/retry until an integration, such as Jira, saves correctly.

This happens if the setting is enabled via the UI or the API

Steps to reproduce

These steps will use integration with Jira as an example:

  1. Create a test docker Network: Run GitLab in docker: sudo docker network create tes

  2. Run GitLab in docker:

docker run \
    --hostname gitlab.test \
    --net test \
    --publish 443:443 --publish 80:80 --publish 22:22 \
    --name gitlab-jira \
gitlab/gitlab-ee:nightly

Since we will be accessing gitlab on gitlab.test, you would need and entry in your /private/etc/hosts file for gitlab.test pointing to 127.0.0.1.

  1. Initially, we need to ensure allow_local_requests_from_web_hooks_and_services is false. If not PUT it to false using the API /api/v4/application/settings or the UI from Admin Area > Settings > Network > Outbound requests > Allow requests to the local network.

  2. Run Jira in docker using the image registry.gitlab.com/gitlab-org/gitlab-qa/jira-gitlab:8.8-project-and-issue:

docker run \
  --publish 8080:8080 \
  --net test \
  --name jira \
  --hostname jira.test \
  registry.gitlab.com/gitlab-org/gitlab-qa/jira-gitlab:8.8-project-and-issue

The username and password for this JIRA instance is in 1P.

  1. Create a new project in GitLab

  2. Enable Jira Integration in this project. Set Web URL to http://jira.test:8080 and username to gitlab-qa. Use the password from 1P. Save changes. The will correctly fail with Requests to the local network are not allowed.

  3. Now enable allow_local_requests_from_web_hooks_and_services using the API. (You can also use the UI to enable this setting bug you need to be fast. As fast as the tests. 🙂 )

  4. Repeat step 6. You will see Requests to the local network are not allowed again.

  5. Wait for 10 seconds and then repeat step 6. This time, it succeeds.

What is the current bug behavior?

"Allow local requests from web hooks and services" takes some time to get enabled.

What is the expected correct behavior?

"Allow local requests from web hooks and services" should enable instantly.

Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info
System information
System:
Proxy:		no
Current User:	git
Using RVM:	no
Ruby Version:	2.6.5p114
Gem Version:	2.7.10
Bundler Version:1.17.3
Rake Version:	12.3.3
Redis Version:	5.0.7
Git Version:	2.26.2
Sidekiq Version:5.2.7
Go Version:	unknown

GitLab information
Version:	12.10.3-ee
Revision:	7c0ab260960
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	11.7
URL:		http://gitlab.test
HTTP Clone URL:	http://gitlab.test/some-group/some-project.git
SSH Clone URL:	git@gitlab.test:some-group/some-project.git
Elasticsearch:	no
Geo:		no
Using LDAP:	no
Using Omniauth:	yes
Omniauth Providers:

GitLab Shell
Version:	12.2.0
Repository storage paths:
- default: 	/var/opt/gitlab/git-data/repositories
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell
Git:		/opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check
Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 12.2.0 ? ... OK (12.2.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

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? ... skipped (no tmp uploads folder yet) 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: ... 1/1 ... yes 1/2 ... yes 1/3 ... yes 1/4 ... yes 1/5 ... yes 1/6 ... yes 1/7 ... yes 1/8 ... yes 1/9 ... yes Redis version >= 4.0.0? ... yes Ruby version >= 2.5.3 ? ... yes (2.6.5) Git version >= 2.22.0 ? ... yes (2.26.2) Git user has default SSH configuration? ... yes Active users: ... 1 Is authorized keys file accessible? ... yes Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Edited by Sanad Liaquat