Skip to content

Polling a sequential schedule: 500 on a deferred job, and on the wrap-up job's id for a sensor's schedule #2874

Open

Description

@Flix6x

Two crashes when following up on POST /assets/<id>/schedules/trigger with "sequential": true, on main (8d59a64c9, rq 2.12):

  1. GET /api/v3_0/jobs/<id> for a job that is deferred answers 500: AttributeError: 'Job' object has no attribute 'status', in job_status_description (flexmeasures/data/services/utils.py), which builds waiting for {preferred_job.status} job. RQ 2 has get_status() instead. The wrap-up job of a sequential schedule is deferred until its last subjob has run, so a client that polls the returned job id early always gets this 500.
  2. GET /api/v3_0/sensors/<id>/schedules/<uuid>, with the wrap-up job's id (which is what the trigger endpoint returns), on a chain that finished, answers 500: KeyError: 'start' at schedule_start = job.kwargs["start"] in SensorAPI.get_schedule. The wrap-up job has no kwargs. It could resolve the subjob for that sensor from the wrap-up job's argument (the list of subjob ids), or answer with a clear 400.

Found while reviewing #2409, which makes a failed chain end in a terminal state (and answers this endpoint with UNKNOWN_SCHEDULE for a failed chain).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions