8000 [AAP-96820] Let the heartbeat and adoption take a clock by chrismeyersfsu · Pull Request #16725 · ansible/awx · GitHub
[go: up one dir, main page]

Skip to content

[AAP-96820] Let the heartbeat and adoption take a clock - #16725

Closed
chrismeyersfsu wants to merge 1 commit into
cmeyers-adoption-seam2-receptor-workfrom
cmeyers/adoption-seam3-clock
Closed

chrismeyersfsu wants to merge 1 commit into
cmeyers-adoption-seam2-receptor-workfrom
cmeyers/adoption-seam3-clock

Conversation

@chrismeyersfsu
@chrismeyersfsu chrismeyersfsu commented Oct 11, 2026 •
Copy link
Copy Markdown
Member
SUMMARY

Stacked on #16724.

The heartbeat and adoption read the current time in several places: judging lost peers, picking orphaned jobs, the adoption deadline (HADR_JOB_ADOPTION_TIMEOUT), and an adopted job's finish time. They now read it from a clock callable that defaults to django.utils.timezone.now:

Behavior is unchanged. The default is resolved at call time, so existing tests that patch awx.main.tasks.system.now still work.

Unlike patching the time module-wide, a clock argument lets one test give two simulated controllers different clocks, and set the time to the second instea 8000 d of sleeping.

awx/main/tests/fake_clock.py adds FakeClock. The new functional tests cover:

  • a peer is lost one second after the grace period, not before;
  • clock skew, both ways: a judge with a fast clock finds a healthy peer lost, and a dead peer whose clock ran fast is found late, only after real time passes its future last_seen;
  • the adoption deadline end to end, against the fake receptor: an orphan one second inside the deadline is replayed and finished at the clock's time; one second past it is failed without contacting receptor.

These record today's behavior. Failure testing of #16669 hit the fast-judge case on a live cluster: a controller with a fast clock marked its healthy peers lost.

ISSUE TYPE
  • Bug, Docs Fix or other nominal change
COMPONENT NAME
  • Other (dispatcher heartbeat)
STEPS TO REPRODUCE AND EXTRA INFO
$ py.test awx/main/tests/unit/tasks awx/main/tests/functional/tasks awx/main/tests/functional/test_dispatch.py awx/main/tests/unit/test_tasks.py
462 passed
$ ruff check / ruff format --check
All checks passed!

The heartbeat's judgment of lost peers and orphaned jobs, the adoption
deadline, and an adopted job's finish time now read the time from a
clock callable that defaults to django.utils.timezone.now.
cluster_node_heartbeat delegates to run_heartbeat(binder, clock), and
adopt_job_async to adopt_job(job_id, open_work, clock). Behavior is
unchanged.

awx.main.tests.fake_clock provides FakeClock. New functional tests check
the lost-peer grace period to the second, clock skew in both
directions (a fast judge finds a healthy peer lost; a dead peer with a
fast clock is found late), and the adoption deadline end to end against
the fake receptor.

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai
coderabbitai Bot commented Oct 11, 2026
Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Comment @coderabbitai help to get the list of available commands.

@chrismeyersfsu
Copy link
Copy Markdown
Member Author

Replaced by #16730 (stack #16732). This PR closed when its branch was renamed to remove a /, which CI's image tag can't contain.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0