Skip to content

Commit

Permalink
Fix issue where project sync reports fail because it is already running
Browse files Browse the repository at this point in the history
  • Loading branch information
Tompage1994 committed Apr 12, 2024
1 parent e9381ea commit 6a38a29
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions changelogs/fragments/proj_sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
bugfixes:
- Fixes issue where project sync reports fail because it is already running
...
14 changes: 12 additions & 2 deletions plugins/module_utils/eda_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,11 +822,21 @@ def sync_project(self, id, wait=True, interval=1, timeout=None):
self.fail_json(msg="The project sync failed", task=project["import_error"])
else:
if "json" in response and "__all__" in response["json"]:
self.fail_json(msg="Unable to sync project: {0}".format(response["json"]["__all__"][0]))
if "detail" in response["json"]["__all__"][0] and response["json"]["__all__"][0]["detail"] == "Project import or sync is already running.":
self.json_output["changed"] = False
self.json_output["detail"] = response["json"]["__all__"][0]["detail"]
self.exit_json(**self.json_output)
else:
self.fail_json(msg="Unable to sync project: {0}".format(response["json"]["__all__"][0]))
elif "json" in response:
# This is from a project delete (if there is an active job against it)
if "error" in response["json"]:
self.fail_json(msg="Unable to sync project: {0}".format(response["json"]["error"]))
if "detail" in response["json"]["error"] and response["json"]["error"]["detail"] == "Project import or sync is already running.":
self.json_output["changed"] = False
self.json_output["detail"] = response["json"]["error"]["detail"]
self.exit_json(**self.json_output)
else:
self.fail_json(msg="Unable to sync project: {0}".format(response["json"]["error"]))
else:
self.fail_json(msg="Unable to sync project: {0}".format(response["json"]))
else:
Expand Down

0 comments on commit 6a38a29

Please sign in to comment.