Skip to content

Commit

Permalink
fix(site-migration): Only allow if all domains are active
Browse files Browse the repository at this point in the history
  • Loading branch information
balamurali27 committed Jan 20, 2025
1 parent f30aff6 commit 9c5ffce
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion press/press/doctype/site_migration/site_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from press.agent import Agent
from press.exceptions import (
CannotChangePlan,
InactiveDomains,
InsufficientSpaceOnServer,
MissingAppsInBench,
OngoingAgentJob,
Expand Down Expand Up @@ -123,11 +124,21 @@ def validate_apps(self):
MissingAppsInBench,
)

def check_for_inactive_domains(self):
if domains := frappe.db.exists(
"Site Domain", {"site": self.site, "status": ("!=", "Active")}, pluck="name"
):
frappe.throw(
f"Inactive custom domains exist: {','.join(domains)}. Please remove or fix the same.",
InactiveDomains,
)

@frappe.whitelist()
def start(self):
self.status = "Pending"
self.save()
self.check_for_ongoing_agent_jobs()
self.check_for_inactive_domains()
self.validate_apps()
self.check_enough_space_on_destination_server()
site: Site = frappe.get_doc("Site", self.site)
Expand Down Expand Up @@ -683,11 +694,13 @@ def run_scheduled_migrations():
try:
site_migration.start()
except OngoingAgentJob:
pass
pass # ongoing jobs will finish in some time
except MissingAppsInBench as e:
site_migration.cleanup_and_fail(reason=str(e), force_activate=True)
except InsufficientSpaceOnServer as e:
site_migration.cleanup_and_fail(reason=str(e), force_activate=True)
except InactiveDomains as e:
site_migration.cleanup_and_fail(reason=str(e), force_activate=True)
except Exception as e:
log_error("Site Migration Start Error", exception=e)

Expand Down

0 comments on commit 9c5ffce

Please sign in to comment.