reporting campaign status
Some checks failed
Build Sphinx Docs Set / Build Docs (pull_request) Successful in 7m42s
Test with tox / Test with tox (3.10) (pull_request) Failing after 8m9s
Build Project / Build Project (3.10) (pull_request) Successful in 8m22s
Build Project / Build Project (3.11) (pull_request) Successful in 8m21s
Build Project / Build Project (3.12) (pull_request) Successful in 8m21s
Test with tox / Test with tox (3.11) (pull_request) Successful in 8m33s
Test with tox / Test with tox (3.12) (pull_request) Successful in 1m14s
Some checks failed
Build Sphinx Docs Set / Build Docs (pull_request) Successful in 7m42s
Test with tox / Test with tox (3.10) (pull_request) Failing after 8m9s
Build Project / Build Project (3.10) (pull_request) Successful in 8m22s
Build Project / Build Project (3.11) (pull_request) Successful in 8m21s
Build Project / Build Project (3.12) (pull_request) Successful in 8m21s
Test with tox / Test with tox (3.11) (pull_request) Successful in 8m33s
Test with tox / Test with tox (3.12) (pull_request) Successful in 1m14s
This commit is contained in:
parent
f67c995846
commit
3e9ac43800
|
|
@ -226,8 +226,11 @@ class NodeAgent:
|
||||||
result = executor.run()
|
result = executor.run()
|
||||||
logger.info("Campaign %s completed — uploading recordings", campaign_id[:8])
|
logger.info("Campaign %s completed — uploading recordings", campaign_id[:8])
|
||||||
self._upload_recordings(campaign_id, config, result)
|
self._upload_recordings(campaign_id, config, result)
|
||||||
|
result_dict = result.to_dict() if hasattr(result, "to_dict") else None
|
||||||
|
self._report_campaign_status(campaign_id, "completed", result=result_dict)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.error("Campaign %s failed: %s", campaign_id[:8], exc)
|
logger.error("Campaign %s failed: %s", campaign_id[:8], exc)
|
||||||
|
self._report_campaign_status(campaign_id, "failed", error=str(exc))
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# Recording upload (chunked for large files)
|
# Recording upload (chunked for large files)
|
||||||
|
|
@ -268,6 +271,30 @@ class NodeAgent:
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.warning("Campaign %s: upload of %s failed: %s", campaign_id[:8], filename, exc)
|
logger.warning("Campaign %s: upload of %s failed: %s", campaign_id[:8], filename, exc)
|
||||||
|
|
||||||
|
def _report_campaign_status(
|
||||||
|
self,
|
||||||
|
campaign_id: str,
|
||||||
|
status: str,
|
||||||
|
result: "dict | None" = None,
|
||||||
|
error: "str | None" = None,
|
||||||
|
) -> None:
|
||||||
|
"""POST campaign completion/failure back to the hub so GET /status/{id} resolves."""
|
||||||
|
payload: dict = {"campaign_id": campaign_id, "status": status}
|
||||||
|
if result is not None:
|
||||||
|
payload["result"] = result
|
||||||
|
if error is not None:
|
||||||
|
payload["error"] = error
|
||||||
|
try:
|
||||||
|
resp = self._post(
|
||||||
|
f"/orchestrator/nodes/{self.node_id}/campaign-status",
|
||||||
|
json=payload,
|
||||||
|
timeout=15,
|
||||||
|
)
|
||||||
|
resp.raise_for_status()
|
||||||
|
logger.info("Campaign %s: reported status=%s to hub", campaign_id[:8], status)
|
||||||
|
except Exception as exc:
|
||||||
|
logger.warning("Campaign %s: failed to report status to hub: %s", campaign_id[:8], exc)
|
||||||
|
|
||||||
def _upload_file(self, base_url: str, file_path: str, metadata: dict) -> dict:
|
def _upload_file(self, base_url: str, file_path: str, metadata: dict) -> dict:
|
||||||
"""Upload *file_path*, choosing chunked or direct path based on file size."""
|
"""Upload *file_path*, choosing chunked or direct path based on file size."""
|
||||||
import requests as _requests
|
import requests as _requests
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user