Skip to content

Commit

Permalink
Rescheduling including TODO regarding job state machine bug (check th…
Browse files Browse the repository at this point in the history
…e comment)
  • Loading branch information
ryuwd committed Sep 17, 2024
1 parent 69d82fe commit 22449b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions diracx-db/src/diracx/db/sql/job/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ async def insert(
"TimeStamp": datetime.now(tz=timezone.utc),
}

async def rescheduleJob(self, job_id) -> dict[str, Any]:
async def rescheduleJob(self, job_id, *, reset_counter=False) -> dict[str, Any]:
"""Reschedule given job."""
from DIRAC.Core.Utilities.ClassAd.ClassAdLight import ClassAd
from DIRAC.Core.Utilities.ReturnValues import SErrorException
Expand Down Expand Up @@ -326,7 +326,10 @@ async def rescheduleJob(self, job_id) -> dict[str, Any]:
f"Job {job_id} not Verified: Status {jobAttrs['Status']}, Minor Status: {jobAttrs['MinorStatus']}"
)

reschedule_counter = int(jobAttrs["RescheduleCounter"]) + 1
if reset_counter:
reschedule_counter = 0
else:
reschedule_counter = int(jobAttrs["RescheduleCounter"]) + 1

# TODO: update maxRescheduling:
# self.maxRescheduling = self.getCSOption("MaxRescheduling", self.maxRescheduling)
Expand Down Expand Up @@ -396,6 +399,9 @@ async def rescheduleJob(self, job_id) -> dict[str, Any]:
else:
site = siteList[0]

## TODO: Enforce state machine first
# then overwrite the other attributes once we know it makes sense
# to continue.
jobAttrs["Site"] = site

jobAttrs["Status"] = JobStatus.RECEIVED
Expand Down
4 changes: 3 additions & 1 deletion diracx-routers/src/diracx/routers/jobs/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,14 @@ async def reschedule_bulk_jobs(
@router.post("/{job_id}/reschedule")
async def reschedule_single_job(
job_id: int,
reset_job: Annotated[bool, Query()],
job_db: JobDB,
check_permissions: CheckWMSPolicyCallable,
):
await check_permissions(action=ActionType.MANAGE, job_db=job_db, job_ids=[job_id])

try:
result = await job_db.rescheduleJob(job_id)
result = await job_db.rescheduleJob(job_id, reset_counter=reset_job)
except ValueError as e:
raise HTTPException(status_code=HTTPStatus.NOT_FOUND, detail=str(e)) from e
return result
Expand Down

0 comments on commit 22449b1

Please sign in to comment.