fix(storage-sync): deduplicate cluster/name writes per run#29
Closed
emersonfelipesp wants to merge 3 commits into
Closed
fix(storage-sync): deduplicate cluster/name writes per run#29emersonfelipesp wants to merge 3 commits into
emersonfelipesp wants to merge 3 commits into
Conversation
Avoid duplicate create attempts when the same cluster/storage pair appears\nmultiple times across endpoints or repeated API rows.\n\n- Collect unique payloads keyed by (cluster, storage name) before reconcile\n- Reconcile each key once per run\n- Add regression test for duplicate cluster/storage pairs\n\nThis prevents IntegrityError on unique constraint\n(netbox_proxbox_proxmoxstorage_cluster_name_*_uniq) during full sync.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Stop running Docker publish jobs on pull requests and non-main branches.\n\nChanges:\n- CI docker-images reusable workflow job now runs only for push events on refs/heads/main\n- Removed pull_request trigger from docker-hub-publish.yml\n\nThis prevents Docker Hub publish pipeline from executing on feature/release branches while\nkeeping main-branch publish behavior intact.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fix(storage-sync): deduplicate cluster/name writes per run
emersonfelipesp
added a commit
that referenced
this pull request
Apr 13, 2026
fix(storage-sync): deduplicate cluster/name writes per run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Main is branch-protected (PR required), so this PR carries the direct main fix.\n\n## Why\nStorage sync could attempt duplicate writes for the same in one run, causing unique-constraint failures in NetBox plugin storage rows.\n\n## What\n- deduplicate storage payloads by before reconcile\n- keep reconcile semantics unchanged\n- add regression test to prevent duplicate calls\n\n## Validation\n- All checks passed!\n- Listing 'proxbox_api'...
Listing 'proxbox_api/app'...
Listing 'proxbox_api/custom_objects'...
Listing 'proxbox_api/diode'...
Listing 'proxbox_api/e2e'...
Listing 'proxbox_api/e2e/fixtures'...
Listing 'proxbox_api/enum'...
Listing 'proxbox_api/enum/netbox'...
Listing 'proxbox_api/enum/netbox/dcim'...
Listing 'proxbox_api/enum/netbox/virtualization'...
Listing 'proxbox_api/generated'...
Listing 'proxbox_api/generated/netbox'...
Listing 'proxbox_api/generated/proxmox'...
Listing 'proxbox_api/generated/proxmox/8.3.0'...
Listing 'proxbox_api/generated/proxmox/latest'...
Listing 'proxbox_api/proxmox_codegen'...
Listing 'proxbox_api/proxmox_to_netbox'...
Listing 'proxbox_api/proxmox_to_netbox/mappers'...
Listing 'proxbox_api/proxmox_to_netbox/schemas'...
Listing 'proxbox_api/routes'...
Listing 'proxbox_api/routes/admin'...
Listing 'proxbox_api/routes/dcim'...
Listing 'proxbox_api/routes/extras'...
Listing 'proxbox_api/routes/netbox'...
Listing 'proxbox_api/routes/proxbox'...
Listing 'proxbox_api/routes/proxbox/clusters'...
Listing 'proxbox_api/routes/proxmox'...
Listing 'proxbox_api/routes/virtualization'...
Listing 'proxbox_api/routes/virtualization/virtual_machines'...
Listing 'proxbox_api/schemas'...
Listing 'proxbox_api/schemas/netbox'...
Listing 'proxbox_api/schemas/netbox/dcim'...
Listing 'proxbox_api/schemas/netbox/extras'...
Listing 'proxbox_api/schemas/netbox/virtualization'...
Listing 'proxbox_api/schemas/virtualization'...
Listing 'proxbox_api/services'...
Listing 'proxbox_api/services/sync'...
Compiling 'proxbox_api/services/sync/storages.py'...
Listing 'proxbox_api/session'...
Listing 'proxbox_api/static'...
Listing 'proxbox_api/templates'...
Listing 'proxbox_api/templates/admin'...
Listing 'proxbox_api/utils'...
Listing 'tests'...
Listing 'tests/e2e'...
Compiling 'tests/test_storage_sync.py'...\n- ============================= test session starts ==============================
platform linux -- Python 3.12.13, pytest-9.0.2, pluggy-1.6.0
rootdir: /root/nms/proxbox-api
configfile: pyproject.toml
plugins: cov-7.1.0, xdist-3.8.0, anyio-4.13.0, asyncio-1.3.0
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 27 items
tests/test_storage_sync.py ... [ 11%]
tests/test_api_routes.py ........................ [100%]
=============================== warnings summary ===============================
proxbox_api/generated/proxmox/latest/pydantic_models.py:542
/root/nms/proxbox-api/proxbox_api/generated/proxmox/latest/pydantic_models.py:542: UserWarning: Field name "schema" in "GetClusterAcmeChallengeSchemaResponseItem" shadows an attribute in parent "ProxmoxBaseModel"
class GetClusterAcmeChallengeSchemaResponseItem(ProxmoxBaseModel):
proxbox_api/schemas/virtualization/init.py:9
/root/nms/proxbox-api/proxbox_api/schemas/virtualization/init.py:9: PydanticDeprecatedSince20: Support for class-based
configis deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.12/migration/class VMConfig(BaseModel):
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================== 27 passed, 2 warnings in 0.14s ========================\n