Skip to content

Commit

Permalink
fix(agent-job-notification): Handle corrupt backup restore attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
balamurali27 committed Jan 1, 2025
1 parent fc4aae9 commit 902cd62
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 @@ -58,6 +58,7 @@ class JobErr(Enum):
DATA_TRUNCATED_FOR_COLUMN = auto()
BROKEN_PIPE_ERR = auto()
CANT_CONNECT_TO_MYSQL = auto()
GZIP_TAR_ERR = auto()


DOC_URLS = {
Expand All @@ -66,6 +67,7 @@ class JobErr(Enum):
JobErr.DATA_TRUNCATED_FOR_COLUMN: "https://frappecloud.com/docs/faq/site#data-truncated-for-column",
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",
}


Expand Down Expand Up @@ -96,6 +98,8 @@ def handlers() -> list[UserAddressableHandlerTuple]:
("Data truncated for column", update_with_data_truncated_for_column_err),
("BrokenPipeError", update_with_broken_pipe_err),
("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),
]


Expand Down Expand Up @@ -258,6 +262,18 @@ def update_with_cant_connect_to_mysql_err(details: Details, job: AgentJob):
return True


def update_with_gzip_tar_err(details: Details, job: AgentJob):
details["title"] = "Corrupt backup file"

details["message"] = f"""<p>An error occurred when extracting the backup to {job.site}.</p>
<p>To rectify this issue, please follow the steps mentioned in <i>Help</i>.</p>
"""

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

return True


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

0 comments on commit 902cd62

Please sign in to comment.