Skip to content

Commit

Permalink
Remove run_job_template from the queueable list (#352)
Browse files Browse the repository at this point in the history
This allows run_job_template action to run in parallel unconditionally

Also add a test to run lauch and monitor a job template execution

Resolves AAP-8991
  • Loading branch information
bzwei authored Feb 7, 2023
2 parents d3097ab + 59fa875 commit 823a478
Show file tree
Hide file tree
Showing 5 changed files with 365 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ansible_rulebook/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ async def run_rulesets(


class RuleSetRunner:
ANSIBLE_ACTIONS = ("run_playbook", "run_module", "run_job_template")
ANSIBLE_ACTIONS = (
"run_playbook",
"run_module",
)

def __init__(
self,
Expand Down
18 changes: 16 additions & 2 deletions ansible_rulebook/job_template_runner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2022 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import asyncio
import json
import logging
Expand Down Expand Up @@ -82,12 +96,12 @@ async def run_job_template(
name: str,
organization: str,
job_params: dict,
event_handler: Callable[[dict], Any],
event_handler: Union[Callable[[dict], Any], None] = None,
) -> dict:
job = await self.launch(name, organization, job_params)

url_info = urlparse(job["url"])
url = f"{url_info.path}/job_events/"
url = f"{url_info.path}job_events/"
counters = []
params = dict(parse_qsl(url_info.query))

Expand Down
1 change: 1 addition & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ pytest-asyncio
pytest-timeout
pytest-xdist
pytest-cov
pytest-vcr
Loading

0 comments on commit 823a478

Please sign in to comment.