diff options
author | Gabriel Muniz <gmuniz@redhat.com> | 2023-06-22 16:07:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-22 16:07:26 +0200 |
commit | 721a2002dc13ace68d700e3126c111af0277332a (patch) | |
tree | 5560c38bdc35671a765455fbc284f641de2defbe /awxkit | |
parent | Rename work signing private key filename (#14156) (diff) | |
download | awx-721a2002dc13ace68d700e3126c111af0277332a.tar.xz awx-721a2002dc13ace68d700e3126c111af0277332a.zip |
Add --interval to launch monitor command (#14068)
Co-authored-by: Jessica Steurer <70719005+jay-steurer@users.noreply.github.com>
Diffstat (limited to 'awxkit')
-rw-r--r-- | awxkit/awxkit/cli/custom.py | 7 | ||||
-rw-r--r-- | awxkit/awxkit/cli/stdout.py | 8 |
2 files changed, 11 insertions, 4 deletions
diff --git a/awxkit/awxkit/cli/custom.py b/awxkit/awxkit/cli/custom.py index c4a13cebfc..431fef07e8 100644 --- a/awxkit/awxkit/cli/custom.py +++ b/awxkit/awxkit/cli/custom.py @@ -56,6 +56,11 @@ class Launchable(object): parser.choices[self.action].add_argument('--monitor', action='store_true', help='If set, prints stdout of the launched job until it finishes.') parser.choices[self.action].add_argument('--action-timeout', type=int, help='If set with --monitor or --wait, time out waiting on job completion.') parser.choices[self.action].add_argument('--wait', action='store_true', help='If set, waits until the launched job finishes.') + parser.choices[self.action].add_argument( + '--interval', + type=float, + help='If set with --monitor or --wait, amount of time to wait in seconds between api calls. Minimum value is 2.5 seconds to avoid overwhelming the api', + ) launch_time_options = self.page.connection.options(self.options_endpoint) if launch_time_options.ok: @@ -71,6 +76,7 @@ class Launchable(object): self.page.connection.session, print_stdout=not kwargs.get('wait'), action_timeout=kwargs.get('action_timeout'), + interval=kwargs.get('interval'), ) if status: response.json['status'] = status @@ -83,6 +89,7 @@ class Launchable(object): 'monitor': kwargs.pop('monitor', False), 'wait': kwargs.pop('wait', False), 'action_timeout': kwargs.pop('action_timeout', False), + 'interval': kwargs.pop('interval', 5), } response = self.page.get().related.get(self.action).post(kwargs) self.monitor(response, **monitor_kwargs) diff --git a/awxkit/awxkit/cli/stdout.py b/awxkit/awxkit/cli/stdout.py index ea64f72aa0..455d4d9805 100644 --- a/awxkit/awxkit/cli/stdout.py +++ b/awxkit/awxkit/cli/stdout.py @@ -9,7 +9,7 @@ from .utils import cprint, color_enabled, STATUS_COLORS from awxkit.utils import to_str -def monitor_workflow(response, session, print_stdout=True, action_timeout=None, interval=0.25): +def monitor_workflow(response, session, print_stdout=True, action_timeout=None, interval=5): get = response.url.get payload = { 'order_by': 'finished', @@ -58,7 +58,7 @@ def monitor_workflow(response, session, print_stdout=True, action_timeout=None, # all at the end fetch(seen) - time.sleep(0.25) + time.sleep(max(2.5, interval)) json = get().json if json.finished: fetch(seen) @@ -68,7 +68,7 @@ def monitor_workflow(response, session, print_stdout=True, action_timeout=None, return get().json.status -def monitor(response, session, print_stdout=True, action_timeout=None, interval=0.25): +def monitor(response, session, print_stdout=True, action_timeout=None, interval=5): get = response.url.get payload = {'order_by': 'start_line', 'no_truncate': True} if response.type == 'job': @@ -105,7 +105,7 @@ def monitor(response, session, print_stdout=True, action_timeout=None, interval= if next_line: payload['start_line__gte'] = next_line - time.sleep(0.25) + time.sleep(max(2.5, interval)) json = get().json if json.event_processing_finished is True or json.status in ('error', 'canceled'): fetch(next_line) |