Add shift handover and RunPod, and make CX-Tools work in a container
Handover - The Confluence shift doc becomes the landing page: shift metadata, the top-of-page checks, key updates with their Zendesk/Jira refs and status, and the free-text comments. "Hand over shift" closes the shift, opens the next one and carries the live items across, dropping anything done or marked "remove at end of shift" - the retyping this replaces. - The RunPod table on that page is read from live host state instead of being copied in by hand, with the six-colour key preserved. RunPod - GraphQL client keyed on CX_RUNPOD_API_KEY. The old console login is kept as a fallback but cannot run unattended: the account has 2FA, so Clerk verifies the password and then asks for an emailed code and never issues a session. That is the real cause of the "No active session found" failure, and the client now says so instead of failing opaquely. TOTP is supported if the account moves to an authenticator app. - Hosts and their listing history are persisted, so "most problematic hosts" can be ranked and each machine has a timeline of who listed or unlisted it, with the Zendesk comment and the error hint. - The unlisting emails are parsed for the error block (they arrive quoted-printable) and classified into a likely cause and a next step. Zendesk and Jira - Unlisting raises a Zendesk ticket that follows the format of RunPod's own email, keyed on the machine so one machine keeps one thread, posted as an internal note. - Jira is split in two: the Infrahub/OIE instance and the RunPod/RMA one, which may be a different Atlassian site. Blank RunPod values fall back to the defaults rather than failing. Running in a container - CX-Tools reads its keys from 1Password, which needs a desktop app. Config is a dataclass whose lookups live in per-field default factories, so passing CX_INFRAHUB_TOKEN/CX_INFRAINSIGHT_TOKEN in means those factories never run and CX-Tools itself stays unmodified. - CX-Tools reaches OpenStack with `docker exec <region>-osc`, so the image now carries the Docker client (the static binary, not the docker.io package) and compose mounts the host socket with group_add for it. Verified from inside the container: live OpenStack and Infrahub calls both succeed. Also fixes Settings, which read the environment at class-definition time and so ignored anything set afterwards; a fresh Settings() silently returned stale values. Caught by the Jira scoping tests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,7 @@ class DeliveryError(RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
def _guard(kind: str) -> None:
|
||||
def _guard(kind: str, scope: str = "default") -> None:
|
||||
if not settings.feature_send_enabled:
|
||||
raise DeliveryError(
|
||||
"Sending is disabled on this instance (CX_FEATURE_SEND_ENABLED is off). "
|
||||
@@ -38,9 +38,15 @@ def _guard(kind: str) -> None:
|
||||
if kind == "zendesk" and not settings.zendesk_ready:
|
||||
raise DeliveryError("Zendesk is not configured. Set CX_FEATURE_ZENDESK plus "
|
||||
"CX_ZENDESK_SUBDOMAIN, CX_ZENDESK_EMAIL and CX_ZENDESK_TOKEN.")
|
||||
if kind == "jira" and not settings.jira_ready:
|
||||
raise DeliveryError("Jira is not configured. Set CX_FEATURE_JIRA plus "
|
||||
"CX_JIRA_BASE, CX_JIRA_EMAIL, CX_JIRA_TOKEN and CX_JIRA_PROJECT.")
|
||||
if kind == "jira":
|
||||
creds = settings.jira_for(scope)
|
||||
if not (settings.feature_jira and creds["base"] and creds["email"] and creds["token"]):
|
||||
prefix = "CX_RUNPOD_JIRA_" if scope == "runpod" else "CX_JIRA_"
|
||||
raise DeliveryError(
|
||||
f"Jira ({scope}) is not configured. Set CX_FEATURE_JIRA plus {prefix}BASE, "
|
||||
f"{prefix}EMAIL and {prefix}TOKEN - or leave the {prefix}* values blank to reuse "
|
||||
"the default instance."
|
||||
)
|
||||
|
||||
|
||||
def sends_today(db: Session) -> int:
|
||||
@@ -125,12 +131,20 @@ async def send_zendesk(db: Session, case: Case, actor: User, *, to: str, subject
|
||||
|
||||
async def create_jira(db: Session, case: Case, actor: User, *, summary: str, description: str,
|
||||
project: str = "", issue_type: str = "",
|
||||
labels: Optional[list[str]] = None) -> dict[str, Any]:
|
||||
_guard("jira")
|
||||
labels: Optional[list[str]] = None,
|
||||
scope: str = "default") -> dict[str, Any]:
|
||||
"""Raise a Jira issue on the instance that owns this kind of work.
|
||||
|
||||
`scope="runpod"` targets the RunPod/RMA project, which may live on an
|
||||
entirely different Atlassian site - hence separate credentials rather than
|
||||
just a different project key.
|
||||
"""
|
||||
_guard("jira", scope)
|
||||
_check_cap(db)
|
||||
|
||||
base = settings.jira_base.rstrip("/")
|
||||
auth = (settings.jira_email, settings.jira_token)
|
||||
creds = settings.jira_for(scope)
|
||||
base = creds["base"].rstrip("/")
|
||||
auth = (creds["email"], creds["token"])
|
||||
label = f"cx-triage-{case.fingerprint}"
|
||||
all_labels = sorted(set((labels or []) + ["cx-triage", label]))
|
||||
|
||||
@@ -147,9 +161,9 @@ async def create_jira(db: Session, case: Case, actor: User, *, summary: str, des
|
||||
return {"ok": True, "key": key, "url": url, "action": "existing"}
|
||||
|
||||
payload = {"fields": {
|
||||
"project": {"key": project or settings.jira_project},
|
||||
"project": {"key": project or creds["project"]},
|
||||
"summary": summary[:250],
|
||||
"issuetype": {"name": issue_type or settings.jira_issue_type},
|
||||
"issuetype": {"name": issue_type or creds["issue_type"]},
|
||||
"labels": all_labels,
|
||||
"description": {
|
||||
"type": "doc", "version": 1,
|
||||
|
||||
Reference in New Issue
Block a user