Skip to content

controllers/repos: keep 'extra' when a POST does not send it - #159

Merged
djgalloway merged 1 commit into
mainfrom
wip-repo-keep-extra
Oct 23, 2026
Merged

djgalloway merged 1 commit into
mainfrom
wip-repo-keep-extra

Conversation

@djgalloway

Copy link
Copy Markdown
Contributor

Problem

POST /api/repos/<project>/ always sets extra=request.json.get("extra", {}), so any POST that leaves extra out wipes the repo's version metadata.

On 2026-10-14 a replay of ~385 chacra.ceph.com repos (restoring shaman rows lost to the September chacra.ceph.com purge) posted status=ready without extra. Teuthology reads extra['package_manager_version'] from /api/search, so jobs failed with KeyError: 'package_manager_version'. For example, 30 of 32 failures in yuriw-2026-10-14_18:39:24-upgrade-umbrella-release-distro-default-trial. The affected rows were repaired by hand on 2026-10-20.

Change

  • Only replace extra when the request carries it.
  • A repo with no extra yet (a newly created row) still defaults to {}, so /api/search never returns null for it.

Tests

  • test_update_without_extra_keeps_extra: regression test; fails on main, passes here.
  • test_create_a_repo_without_extra: a new repo created without extra gets {}.
  • test_update_with_extra_replaces_extra: a POST that does send extra still replaces it.

pytest shaman/tests/controllers/test_repos.py shaman/tests/controllers/test_search.py passes on sqlite: 73 tests. flake8 --select=F,E9 is clean. The postgres tox env has not been run.

Not covered

  • Creating a row (or re-creating a deleted one) still stamps modified with the current time. A replayed callback for an old build therefore still makes it the "latest" for its ref. Fixing that would mean honouring the modified that chacra already sends, which changes "latest" ordering, so it's left for a separate change.
  • api/builds/projects.py has the same extra default. url in this handler likewise falls back to "" when it's omitted.

A POST to /api/repos/<project>/ always replaced 'extra' with
request.json.get("extra", {}), so any status update that omitted the
field wiped the repo's version metadata. On 2026-10-14 a replay of
~385 chacra.ceph.com repos (restoring rows lost to a purge) posted
without 'extra'; teuthology reads extra['package_manager_version'] from
/api/search and failed with KeyError: 'package_manager_version' across
an entire upgrade run until the rows were repaired by hand.

Only replace 'extra' when the request carries it. A repo that has no
'extra' yet (a new row) still defaults to {} so clients never see null.

Assisted-by: Claude Opus 5.5
Signed-off-by: David Galloway <[email protected]>
@djgalloway
djgalloway marked this pull request as ready for review October 23, 2026 14:12
@djgalloway
djgalloway requested a review from dmick October 23, 2026 14:12
@djgalloway
djgalloway merged commit 04e77bc into main Oct 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants