Skip to content

fix(import): handle bindings that already exist on re-import - #213

Merged
eniac111 merged 1 commit into
masterfrom
fix/import-existing-bindings
Nov 10, 2026
Merged

eniac111 merged 1 commit into
masterfrom
fix/import-existing-bindings

Conversation

@eniac111

Copy link
Copy Markdown
Member

Importing a bundle a second time failed on every PolicyBinding document with a duplicate key error on (policy_id, group_id): only policies were compared with existing ones, bindings were always inserted. The dry run had the same blind spot and reported "would create".

Existing bindings are now matched by policy and node group and follow the conflict mode:

  • new-version: set the priority from the file when it differs, report "updated"; report "skipped" when it is already the same. The enabled or disabled state is never changed.
  • skip: report "skipped".
  • error: fail during validation, so nothing is written.

The dry run reports the same outcome as the import. This works for bindings that reference the policy by in-file name and by display name on the server.

Also:

  • reject a bundle that binds the same policy to the same node group twice, which hit the same constraint
  • updating a binding through import needs binding:toggle on the group, like the bindings API
  • resync the group when the priority of an enabled binding changes
  • describe the binding behaviour in the user guide

Fixes #209

Importing a bundle a second time failed on every PolicyBinding document
with a duplicate key error on (policy_id, group_id): only policies were
compared with existing ones, bindings were always inserted. The dry run
had the same blind spot and reported "would create".

Existing bindings are now matched by policy and node group and follow
the conflict mode:

- new-version: set the priority from the file when it differs, report
  "updated"; report "skipped" when it is already the same. The enabled
  or disabled state is never changed.
- skip: report "skipped".
- error: fail during validation, so nothing is written.

The dry run reports the same outcome as the import. This works for
bindings that reference the policy by in-file name and by display name
on the server.

Also:

- reject a bundle that binds the same policy to the same node group
  twice, which hit the same constraint
- updating a binding through import needs binding:toggle on the group,
  like the bindings API
- resync the group when the priority of an enabled binding changes
- describe the binding behaviour in the user guide

Fixes #209

Signed-off-by: Blagovest Petrov <blagovest@petrovs.info>
@eniac111
eniac111 merged commit ddd2a23 into master Nov 10, 2026
25 checks passed
@eniac111
eniac111 deleted the fix/import-existing-bindings branch November 10, 2026 08:21
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Import: re-importing a bundle fails on bindings that already exist (duplicate policy_id, group_id)

1 participant