Skip to content

fix(#3170): dispatch SRPM status check even when DB already shows success - #3171

Open
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/3170-babysit-srpm-status-check
Open

fix(#3170): dispatch SRPM status check even when DB already shows success#3171
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/3170-babysit-srpm-status-check

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

Summary

  • Remove the srpm_build.status == BuildStatus.pending guard from the SRPM processing block in update_copr_builds(), so update_srpm_build_state() is called whenever an SRPM build exists — regardless of DB status
  • Guard set_status(BuildStatus.error) in the CoprNoResultException handler to only apply when the SRPM build is still pending, preventing overwriting a valid success/failure status
  • Add regression test test_check_copr_build_srpm_status_check_dispatched_when_db_already_success that verifies the SRPM status check handler is dispatched even when the DB already shows success
  • Update existing test_check_copr_build_already_successful to account for the new behavior

Root Cause

When copr_build_end handlers for individual chroots ran between babysit retries, they updated the SRPM build's DB row to success as a side effect — but did not send the SRPM's GitHub status check. On the next babysit run, the srpm_build.status == BuildStatus.pending guard caused the entire SRPM processing block to be skipped, leaving the SRPM status check stuck in "pending" on GitHub.

Why This Is Safe

update_srpm_build_state() already has its own guard (build_copr_srpm.state not in (COPR_SUCC_STATE, COPR_FAIL_STATE)) that only proceeds when the Copr API confirms the SRPM build has ended. The CoprBuildEndHandler dispatch via Celery is idempotent — re-sending a status check that was already set is a no-op on GitHub's side.

Testing

  • New regression test covers the exact race condition scenario from the issue
  • Existing test updated to mock the newly-called get_source_chroot API
  • Tests require containerized execution (make check-in-container) due to Fedora-specific system dependencies (RPM Python bindings)

Closes #3170

Post-script verification

  • Branch is not main/master (agent/3170-babysit-srpm-status-check)
  • Secret scan passed (gitleaks — ca574c7e4de53a31d6870742f12976f16ad2dd55..HEAD)
  • PR body secret scan passed (gitleaks — no-git)

shows success

Remove the `srpm_build.status == BuildStatus.pending` guard from
the SRPM processing block in `update_copr_builds()`. When
`copr_build_end` handlers for individual chroots update the SRPM
build DB row to success as a side effect before the babysit task
runs, babysit previously skipped the entire SRPM processing
block, leaving the SRPM GitHub status check stuck in "pending".

Now babysit always calls `update_srpm_build_state()` when an SRPM
build exists, regardless of the DB status. This is safe because
`update_srpm_build_state()` has its own guard that only proceeds
when the Copr API confirms the build ended (succeeded/failed),
and the `CoprBuildEndHandler` dispatch is idempotent.

The `set_status(BuildStatus.error)` call in the
`CoprNoResultException` handler is now guarded to only apply when
the SRPM build is still pending, preventing an already-succeeded
SRPM build from being incorrectly set to error if the Copr API
data has expired.

Note: Unit/integration tests could not run in the sandbox due to
missing system RPM Python bindings (Fedora-specific). The project
uses containerized testing (`make check-in-container`). Manual
verification of test suite is required.

Closes #3170
@fullsend-ai-review

fullsend-ai-review Bot commented Aug 25, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 7:57 AM UTC · Completed 8:12 AM UTC

Commit: 3f0c4a4 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Effort: high · Cost: $4.23

@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

High

  • [missing-test] tests/integration/test_babysit.py — Four existing tests (test_check_copr_build_updated, test_check_copr_build_waiting_started, test_check_copr_build_waiting_already_started, test_check_update_copr_builds_timeout) set up SRPMBuildModel.get_by_copr_build_id returning a mock with status=BuildStatus.success but do not mock build_proxy.get_source_chroot(). Before this PR, the srpm_build.status == BuildStatus.pending guard caused the SRPM processing block to be skipped entirely, so get_source_chroot was never called in those tests. After removing that guard, the code enters the try block and calls get_source_chroot, which is not registered on the pure flexmock build_proxy in these tests. The PR correctly updated test_check_copr_build_already_successful with get_source_chroot mocking and an update_srpm_build_state expectation, but the same fix was not applied to the other four affected tests.
    Remediation: Add get_source_chroot mocking to the build_proxy flexmock in each of these four tests (matching the pattern used in test_check_copr_build_already_successful), and add appropriate expectations for update_srpm_build_state or celery_run_async depending on whether the SRPM state should trigger handler dispatch.

Next steps:

  • /fs-fix — agent addresses review findings automatically
  • /fs-fix <your instruction> — agent fixes with your specific guidance
  • Push commits directly — review re-runs automatically on push
  • /fs-fix-stop — disable automatic fix runs for this PR

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The following review comments could not be posted on the diff (GitHub returned 422) and are included here instead:

  • tests/integration/test_babysit.py (file-level): Line 231 · [high] missing-test

Four existing tests (test_check_copr_build_updated, test_check_copr_build_waiting_started, test_check_copr_build_waiting_already_started, test_check_update_copr_builds_timeout) set up SRPMBuildModel.get_by_copr_build_id returning a mock with status=BuildStatus.success but do not mock build_proxy.get_source_chroot(). Before this PR, the srpm_build.status == BuildStatus.pending guard skipped the SRPM processing block, so get_source_chroot was never called. After removing that guard, the code enters the try block and calls get_source_chroot, which is not registered on the pure flexmock build_proxy. The PR updated test_check_copr_build_already_successful but missed these four tests.

Suggested fix: Add get_source_chroot mocking to the build_proxy flexmock in each of these four tests (matching the pattern in test_check_copr_build_already_successful), and add appropriate expectations for update_srpm_build_state.

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the review comment for full details.

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

Labels

ready-for-review Ready for review

Projects

Development

Successfully merging this pull request may close these issues.

babysit_copr_build skips when DB shows success but status check may not be updated

2 participants