Skip to content

Commit 90742d9

Browse files
fix: handle missing RESOURCE_SERVICE_PATH in sync task (ansible#624)
There is an error in eda-server when running the periodic task to sync shared resources: ``` default-worker.log:Sep 20 18:52:40 ip-10-0-14-133 automation-eda-controller-worker-0[86746]: 2024-09-20 18:52:40,887 aap_eda.tasks.shared_resources ERROR Failed to sync shared resources. Error: get_resource_server_client() missing 1 required positional argument: 'service_path' ``` That is solved by @AlanCoding through ansible/eda-server#1059 Here I just handle the error for the absence of the mandatory param in `get_resource_server_client`. According to the code, this param can not be empty. I wonder if this eventuality should be handled in the constructor: https://github.com/Alex-Izquierdo/django-ansible-base/blob/b7e9271ef7952dddff32d37927a3fa1060515bc6/ansible_base/resource_registry/rest_client.py#L66-L67 Jira: https://issues.redhat.com/browse/AAP-31736 Signed-off-by: Alex <[email protected]>
1 parent 8ebd392 commit 90742d9

File tree

1 file changed

+7
-2
lines changed
  • ansible_base/resource_registry/tasks

1 file changed

+7
-2
lines changed

ansible_base/resource_registry/tasks/sync.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,15 @@ def __iter__(self):
6666
def create_api_client() -> ResourceAPIClient:
6767
"""Factory for pre-configured ResourceAPIClient."""
6868
params = {"raise_if_bad_request": False}
69+
6970
if jwt_user_id := getattr(settings, "RESOURCE_JWT_USER_ID", None):
7071
params["jwt_user_id"] = jwt_user_id
71-
if service_path := getattr(settings, "RESOURCE_SERVICE_PATH", None):
72-
params["service_path"] = service_path
72+
73+
service_path = getattr(settings, "RESOURCE_SERVICE_PATH", None)
74+
if not service_path:
75+
raise ValueError("RESOURCE_SERVICE_PATH is not set.")
76+
params["service_path"] = service_path
77+
7378
client = get_resource_server_client(**params)
7479
return client
7580

0 commit comments

Comments
 (0)