Skip to content

fix(BA-7857): write a registry's allowed projects in the update's transaction - #14562

Draft
jopemachine wants to merge 2 commits into
mainfrom
fix/BA-7857-allowed-groups-after-update
Draft

fix(BA-7857): write a registry's allowed projects in the update's transaction#14562
jopemachine wants to merge 2 commits into
mainfrom
fix/BA-7857-allowed-groups-after-update

Conversation

@jopemachine

@jopemachine jopemachine commented Sep 11, 2026

Copy link
Copy Markdown
Member

Found while writing the container registry scenarios (#14519).

Summary

  • admin_update wrote the allowed-project links through the rbac relation calls before it updated the registry row, each in a transaction of its own. An update refused after that left the links changed, so a caller told its call had failed had had half of it applied.
  • The links now ride with the update: UpdateContainerRegistryAction carries what to allow and stop allowing, and the repository writes the row and the links on one session, so a refusal rolls back both.

Why this needed no new plumbing

ContainerRegistryRepository already takes a RelationOpsProvider, and V2RelationWriteOps already extends the general write ops. One write_ops() can do update_data and create_relations / purge_relations together, which is what modify_registry now does.

How to see the old behaviour

Send one update that changes the allowed projects and sets a URL with no host. Before: the links are written, the update is refused with InvalidContainerRegistryURL, the links stay changed. After: nothing changes.

What is not touched

  • apply_allowed_groups stays as it was, for the create path and its four other callers, where the link change is the whole of what the call does.
  • The relation permission gate does not apply on this path any more, and nothing is lost by that: it only refuses a caller who is not a superadmin, and the update itself is behind the superadmin role, so no caller reaches one check without the other.
  • Removing is still refused only when none of the named pairs was linked, and adding a pair that is already linked is still not an error. Both answers moved with the code rather than changing.

Resolves BA-7857

🤖 Generated with Claude Code

https://claude.ai/code/session_013TYyokzEfpr9AF2NnHtyXB

@github-actions github-actions Bot added size:S 10~30 LoC comp:manager Related to Manager component labels Sep 11, 2026
jopemachine added a commit that referenced this pull request Sep 11, 2026
jopemachine and others added 2 commits September 11, 2026 14:48
…nsaction

`admin_update` wrote the allowed-project links through the rbac relation calls
before it updated the registry row, each in a transaction of its own. An update
refused after that — a URL with no host, a harbor registry left without a
project, an id that holds nothing — left the links changed, so a caller told its
call had failed had had half of it applied.

The links now ride with the update. `UpdateContainerRegistryAction` carries what
to allow and stop allowing, and the repository writes the row and the links on
one session, so a refusal rolls back both.

`ContainerRegistryRepository` already held the relation ops provider and
`V2RelationWriteOps` already extends the general write ops, so this needed no new
session plumbing. `apply_allowed_groups` stays for the create path and its other
callers, where it is the whole of what the call does.

The relation permission gate is not lost on this path: it only ever refuses a
caller who is not a superadmin, and the update itself is behind the superadmin
role, so no caller reaches one check without the other.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013TYyokzEfpr9AF2NnHtyXB
@jopemachine
jopemachine force-pushed the fix/BA-7857-allowed-groups-after-update branch from a98e6e0 to 9da3bc2 Compare September 11, 2026 05:48
@jopemachine jopemachine changed the title fix(BA-7857): apply a registry's allowed projects after the update is accepted fix(BA-7857): write a registry's allowed projects in the update's transaction Sep 11, 2026
@github-actions github-actions Bot added size:L 100~500 LoC and removed size:S 10~30 LoC labels Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:manager Related to Manager component size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant