Skip to content

[BUG] --cloud-only --date ignores schedules of inactive assignments #752

Closed

Description

@sadsfae

Summary

quads --cloud-only --cloud <cloud> --date "<past date>" returns the hosts currently in the cloud instead of the hosts assigned to that cloud at the requested date. The same command works on 2.2.

Steps to reproduce

  1. Find a host whose schedule was in cloud03 on a past date:
    quads --ls-schedule --host host-a.example.com | grep cloud03
    e.g. start=2025-12-29T13:00, end=2026-08-17T17:07, cloud=cloud03
  2. Query the same date:
    quads --cloud-only --cloud cloud03 --date "2026-08-16 22:00"
  3. Query a different date:
    quads --cloud-only --cloud cloud03 --date "2026-10-02 22:00"

Both queries print the current cloud03 membership, not the historical assignment.

Expected

The hosts whose schedules overlap the requested date, even if the owning assignment was terminated later.

Actual

ScheduleDao.get_current_schedule filters Assignment.active.is_(True). Historical schedules belong to assignments that are inactive now, so they are dropped. action_cloudonly then falls through to its no-schedule branch and prints the current cloud membership.

Regression

Commit ab3dc63d (fix: skip schedules of inactive assignments, issue #746) added the active filter to src/quads/server/dao/schedule.py. That fix is still needed for current and move queries, since stale future schedules on terminated assignments must not drive moves. It must not apply to point-in-time historical queries.

Read-only evidence from a development server:

  • 14 cloud03 schedule rows overlap 2024-06-14 17:00, all under one assignment with active=false.
  • SQL with the 2.2 predicate (no active filter) returns 14 rows; the development predicate (a.active is true) returns 0.
  • GET /api/v3/schedules/current?cloud=cloud03&date=2024-06-14T17:00 returns [].

Proposed fix

Acceptance criteria

  • A past --cloud-only --date query returns the historical schedule hosts.
  • Current and future --cloud-only and /moves queries still exclude schedules from inactive assignments.
  • TestMovesTerminatedAssignment passes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions