Skip to content

Commit 6ec039f

Browse files
committed
Remove pause/resume jobs
1 parent 0d18de2 commit 6ec039f

2 files changed

Lines changed: 8 additions & 15 deletions

File tree

src/api/organization/project/branch/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,11 @@
112112
BranchServiceStatus.STARTING,
113113
BranchServiceStatus.STOPPING,
114114
BranchServiceStatus.RESTARTING,
115-
BranchServiceStatus.PAUSING,
116-
BranchServiceStatus.RESUMING,
117115
BranchServiceStatus.UPDATING,
118116
BranchServiceStatus.DELETING,
119117
BranchServiceStatus.RESIZING,
120118
}
121-
_PROTECTED_BRANCH_STATUSES: set[BranchServiceStatus] = {BranchServiceStatus.PAUSED}
119+
_PROTECTED_BRANCH_STATUSES: set[BranchServiceStatus] = {BranchServiceStatus.STOPPED, BranchServiceStatus.PAUSED}
122120
_CREATING_STATUS_ERROR_GRACE_PERIOD = timedelta(minutes=5)
123121
_STARTING_STATUS_ERROR_GRACE_PERIOD = timedelta(minutes=5)
124122

@@ -1957,6 +1955,7 @@ async def control_branch(
19571955
branch: BranchDep,
19581956
):
19591957
action = request.scope["route"].name.split(":")[-1]
1958+
action = {"pause": "stop", "resume": "start"}.get(action, action)
19601959
assert action in _CONTROL_TO_POWER_STATE
19611960
task_id = dispatch_control(str(branch.id), action)
19621961
branch.control_task_id = task_id

src/api/organization/project/branch/control_tasks.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
"""Celery task for branch start/stop/pause/resume lifecycle management.
1+
"""Celery task for branch start/stop lifecycle management.
22
3-
For start/resume the task polls the health monitor until the branch is
4-
ACTIVE_HEALTHY, then writes that status and clears itself from the branch.
5-
For stop/pause the task waits for the NeonVM phase to reach stopped/succeeded.
3+
For start the task polls the health monitor until the branch is ACTIVE_HEALTHY,
4+
then writes that status and clears itself from the branch.
5+
For stop the task waits for the NeonVM phase to reach stopped/succeeded.
66
While the task is running any status query returns the in-progress shadow
7-
status (STARTING/RESUMING/STOPPING/PAUSING) instead of the DB value.
7+
status (STARTING/STOPPING) instead of the DB value.
88
"""
99

1010
import asyncio
@@ -27,27 +27,21 @@
2727
logger = logging.getLogger(__name__)
2828

2929
_CONTROL_TO_POWER_STATE: dict[str, PowerState] = {
30-
"pause": "Stopped",
31-
"resume": "Running",
3230
"start": "Running",
3331
"stop": "Stopped",
3432
}
3533

3634
_CONTROL_TRANSITION_INITIAL: dict[str, BranchServiceStatus] = {
37-
"pause": BranchServiceStatus.PAUSING,
38-
"resume": BranchServiceStatus.RESUMING,
3935
"start": BranchServiceStatus.STARTING,
4036
"stop": BranchServiceStatus.STOPPING,
4137
}
4238

4339
_CONTROL_TRANSITION_FINAL: dict[str, BranchServiceStatus] = {
44-
"pause": BranchServiceStatus.PAUSED,
4540
"stop": BranchServiceStatus.STOPPED,
4641
}
4742

4843
_DESIRED_PHASES: dict[str, set[Phase]] = {
4944
"stop": {Phase.stopped, Phase.succeeded},
50-
"pause": {Phase.stopped, Phase.succeeded},
5145
}
5246

5347
_POLL_INTERVAL_SEC = 5
@@ -96,7 +90,7 @@ async def _async_perform_control(branch_id: str, action: str) -> dict:
9690
try:
9791
await set_virtualmachine_power_state(namespace, name, _CONTROL_TO_POWER_STATE[action])
9892

99-
if action in ("start", "resume"):
93+
if action == "start":
10094
while True:
10195
current = await query_deployment_status(namespace, name)
10296
if current == BranchServiceStatus.ACTIVE_HEALTHY:

0 commit comments

Comments
 (0)