Skip to content

Commit

Permalink
Add timeout param to start_compose
Browse files Browse the repository at this point in the history
  • Loading branch information
empovit committed Jul 17, 2023
1 parent 73a34cd commit 72aee2e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- Add "builder_request_timeout" argument to infra.osbuild.builder
4 changes: 2 additions & 2 deletions plugins/module_utils/weldrapiv1.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def delete_blueprints_workspace(self, blueprint):
raise NotImplementedError

# Composes
def post_compose(self, compose_settings):
def post_compose(self, compose_settings, timeout=120):
"""
initiate a compose
Expand All @@ -294,7 +294,7 @@ def post_compose(self, compose_settings):
data=compose_settings,
headers={"Content-Type": "application/json"},
unix_socket=self.weldr.unix_socket,
timeout=120,
timeout=timeout,
)
result = dict()
result["status_code"] = info["status"]
Expand Down
9 changes: 8 additions & 1 deletion plugins/modules/start_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@
type: str
default: ""
required: false
timeout:
description:
- timeout for osbuild-compose requests, in seconds
type: int
default: 120
required: false
notes:
- THIS MODULE IS NOT IDEMPOTENT UNLESS C(allow_duplicate) is set to C(false)
- The params C(profile) and C(image_name) are required together.
Expand Down Expand Up @@ -150,6 +156,7 @@
ostree_ref=dict(type="str", required=False, default=""),
ostree_parent=dict(type="str", required=False, default=""),
ostree_url=dict(type="str", required=False, default=""),
timeout=dict(type="int", required=False, default=120),
)


Expand Down Expand Up @@ -224,7 +231,7 @@ def start_compose(module, weldr):
}

try:
result: dict = weldr.api.post_compose(json.dumps(compose_settings))
result: dict = weldr.api.post_compose(json.dumps(compose_settings), timeout=module.params["timeout"])
except socket.timeout:
# it's possible we don't get a response back from weldr because on the
# very first run including a new content source composer will build a repo cache
Expand Down
1 change: 1 addition & 0 deletions roles/builder/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ builder_compose_customizations:
builder_image_storage_threshold: 3 # percentage
builder_image_storage_cleared: false
builder_system_ipv4: "{{ ansible_default_ipv4.address }}"
builder_request_timeout: 120
6 changes: 6 additions & 0 deletions roles/builder/meta/argument_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,9 @@ argument_specs:
builder_aap_ks_password:
type: "str"
required: false

builder_request_timeout:
type: "int"
required: false
default: 120
description: "Optionally, set OSBuild composer API timeout in seconds"
3 changes: 3 additions & 0 deletions roles/builder/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
infra.osbuild.start_compose: # noqa only-builtins
blueprint: "{{ builder_blueprint_name }}"
compose_type: "{{ _builder_compose_type }}"
timeout: "{{ builder_request_timeout }}"
register: builder_compose_start_out

- name: Wait for compose to finish
Expand Down Expand Up @@ -252,6 +253,7 @@
compose_type: "{{ builder_compose_type }}"
ostree_url: "{{ builder_ostree_url if builder_ostree_url is defined else 'http://' + builder_system_ipv4 + '/' + builder_blueprint_name + '/repo/' }}" # noqa yaml[line-length]
ostree_ref: "{{ builder_blueprint_ref | default(omit) }}"
timeout: "{{ builder_request_timeout }}"
register: builder_compose_start_out
when:
- "'edge' not in builder_compose_type and 'iot' not in builder_compose_type"
Expand All @@ -262,6 +264,7 @@
compose_type: "{{ builder_compose_type }}"
ostree_url: "{{ builder_ostree_url if builder_ostree_url is defined else 'http://' + builder_system_ipv4 + '/' + builder_blueprint_name + '/repo/' }}" # noqa yaml[line-length]
ostree_ref: "{{ builder_blueprint_ref | default(omit) }}"
timeout: "{{ builder_request_timeout }}"
register: builder_compose_start_out
when:
- "'edge' in builder_compose_type or 'iot' in builder_compose_type"
Expand Down
1 change: 1 addition & 0 deletions tests/unit/plugins/modules/test_start_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"ostree_ref": "",
"ostree_parent": "",
"ostree_url": "",
"timeout": 60,
}


Expand Down

0 comments on commit 72aee2e

Please sign in to comment.