Skip to content

Commit

Permalink
Allow to configure api calls timeout (#362)
Browse files Browse the repository at this point in the history
* Add a configurable timeout for API calls

Raise the default timeout to 60s as e.g. repo creation with a large number
or repositories on firts install can be quite long and generate errors

* Add a test for non default timeout

* Documentation

[ci skip]
  • Loading branch information
zeitounator authored Nov 8, 2022
1 parent 61e1578 commit d01b338
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,15 @@ The fully qualified domain name and scheme under which the nexus instance will b
nexus_api_validate_certs: "{{ nexus_api_scheme == 'https' }}"
nexus_api_context_path: "{{ nexus_default_context_path }}"
nexus_api_port: "{{ nexus_default_port }}"
nexus_api_timeout: 60
```
These vars control how the role connects to the nexus API for provisionning.
**For advance usage only. You most probably do not want to change these default settings**

Note: the `nexus_api_timeout` was added in v2.4.19 and overrides the default
[`uri` module timeout](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/uri_module.html) of 30s
for all calls to the API

### Branding capabalities
```yaml
nexus_branding_header: ""
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ nexus_api_scheme: http
nexus_api_validate_certs: "{{ nexus_api_scheme == 'https' }}"
nexus_api_context_path: "{{ nexus_default_context_path }}"
nexus_api_port: "{{ nexus_default_port }}"
nexus_api_timeout: 60

# security realms
nexus_nuget_api_key_realm: false
Expand Down
1 change: 1 addition & 0 deletions molecule/nexus_common_test_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ httpd_copy_ssl_files: false
httpd_ssl_cert_file_location: "{{ default_cert }}"
httpd_ssl_cert_key_location: "{{ default_key }}"
nexus_public_hostname: localhost
nexus_api_timeout: 45

nexus_custom_jvm_settings:
- XX:+UseG1GC
Expand Down
1 change: 1 addition & 0 deletions tasks/call_script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
uri:
url: "{{ nexus_api_scheme }}://{{ nexus_api_hostname }}:{{ nexus_api_port }}\
{{ nexus_api_context_path }}{{ nexus_rest_api_endpoint }}/{{ script_name }}/run"
timeout: "{{ nexus_api_timeout | int }}"
user: 'admin'
password: "{{ current_nexus_admin_password }}"
headers:
Expand Down
2 changes: 2 additions & 0 deletions tasks/declare_script_each.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
uri:
url: "{{ nexus_api_scheme }}://{{ nexus_api_hostname }}:{{ nexus_api_port }}\
{{ nexus_api_context_path }}{{ nexus_rest_api_endpoint }}/{{ item }}"
timeout: "{{ nexus_api_timeout | int }}"
user: 'admin'
password: "{{ current_nexus_admin_password }}"
method: DELETE
Expand All @@ -14,6 +15,7 @@
uri:
url: "{{ nexus_api_scheme }}://{{ nexus_api_hostname }}:{{ nexus_api_port }}\
{{ nexus_api_context_path }}{{ nexus_rest_api_endpoint }}"
timeout: "{{ nexus_api_timeout | int }}"
user: 'admin'
password: "{{ current_nexus_admin_password }}"
body_format: json
Expand Down

0 comments on commit d01b338

Please sign in to comment.