Skip to content

Commit

Permalink
fix(agent-job-notification): Handle incompatible backup errs
Browse files Browse the repository at this point in the history
  • Loading branch information
balamurali27 committed Jan 1, 2025
1 parent 902cd62 commit 574b138
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions press/press/doctype/agent_job/agent_job_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class JobErr(Enum):
BROKEN_PIPE_ERR = auto()
CANT_CONNECT_TO_MYSQL = auto()
GZIP_TAR_ERR = auto()
UNKNOWN_COMMAND_HYPHEN = auto()


DOC_URLS = {
Expand All @@ -68,6 +69,7 @@ class JobErr(Enum):
JobErr.BROKEN_PIPE_ERR: None,
JobErr.CANT_CONNECT_TO_MYSQL: "https://frappecloud.com/docs/cant-connect-to-mysql-server",
JobErr.GZIP_TAR_ERR: "https://frappecloud.com/docs/sites/migrate-an-existing-site#tar-gzip-command-fails-with-unexpected-eof",
JobErr.UNKNOWN_COMMAND_HYPHEN: "https://frappecloud.com/docs/unknown-command-",
}


Expand Down Expand Up @@ -100,6 +102,7 @@ def handlers() -> list[UserAddressableHandlerTuple]:
("ERROR 2002 (HY000)", update_with_cant_connect_to_mysql_err),
("gzip: stdin: unexpected end of file", update_with_gzip_tar_err),
("tar: Unexpected EOF in archive", update_with_gzip_tar_err),
("Unknown command '\\-'.", update_with_unknown_command_hyphen_err),
]


Expand Down Expand Up @@ -274,6 +277,19 @@ def update_with_gzip_tar_err(details: Details, job: AgentJob):
return True

Check warning on line 277 in press/press/doctype/agent_job/agent_job_notifications.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/agent_job/agent_job_notifications.py#L277

Added line #L277 was not covered by tests


def update_with_unknown_command_hyphen_err(details: Details, job: AgentJob):
details["title"] = "Incompatible site backup"

Check warning on line 281 in press/press/doctype/agent_job/agent_job_notifications.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/agent_job/agent_job_notifications.py#L281

Added line #L281 was not covered by tests

details["message"] = f"""<p>An error occurred when extracting the backup to {job.site}.</p>

Check warning on line 283 in press/press/doctype/agent_job/agent_job_notifications.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/agent_job/agent_job_notifications.py#L283

Added line #L283 was not covered by tests
<p>This happens when the backup is taken from a later version of MariaDB and restored on a older version.</p>
<p>To rectify this issue, please follow the steps mentioned in <i>Help</i>.</p>
"""

details["assistance_url"] = DOC_URLS[JobErr.UNKNOWN_COMMAND_HYPHEN]

Check warning on line 288 in press/press/doctype/agent_job/agent_job_notifications.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/agent_job/agent_job_notifications.py#L288

Added line #L288 was not covered by tests

return True

Check warning on line 290 in press/press/doctype/agent_job/agent_job_notifications.py

View check run for this annotation

Codecov / codecov/patch

press/press/doctype/agent_job/agent_job_notifications.py#L290

Added line #L290 was not covered by tests


def get_default_title(job: AgentJob) -> str:
if job.job_type == "Update Site Migrate":
return "Site Migrate"
Expand Down

0 comments on commit 574b138

Please sign in to comment.