Conversation
…m Zabbix (OpensourceICTSolutions#141) Zabbix >= 5.4 no longer returns tls_psk_identity from proxy.get, so the previous fallback to '' wiped the identity on every re-sync and the subsequent save() failed full_clean() for proxies using PSK encryption. Keep the NetBox value unless Zabbix actually returns one, matching the existing write-only handling of tls_psk.
…fails ZabbixProxy.save() runs full_clean(), so recording a failed sync on an object that is itself invalid raised a second ValidationError and the message was never written. Fall back to a direct queryset update so the outcome is always persisted. Happy path is unchanged.
This branch has not been deployed
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.
Fixes #141
Problem
Re-syncing a proxy that uses PSK encryption fails with:
Zabbix >= 5.4 does not return
tls_psk_identityfromproxy.get(it is write-only, the same astls_psk).ProxySync.sync_from_zabbix()fell back to''when the key was missing, wiping the identity that had just been pushed to Zabbix. The subsequentsave()then failedfull_clean()becausetls_acceptstill contained the PSK flag.This also broke host sync for any host behind a PSK proxy, because
SyncHostJob.sync_host()syncs the proxy first and the proxy sync raised before the host was reached.Changes
nbxsync/utils/sync/proxysync.py:tls_psk_identitynow keeps the NetBox value unless Zabbix actually returns one, matching the existing write-only handling oftls_psk.nbxsync/models/sync_info.py:update_sync_info()now falls back to a direct queryset update ifsave()raisesValidationError.ZabbixProxy.save()runsfull_clean(), so when the sync failed because the object was invalid, theexceptbranch's call toupdate_sync_info()re-ranfull_clean()and raised again. The job died in the RQ failed registry andlast_sync_messagestayed at "Never synced", which is why the failure in #141 was invisible in the UI. The happy path is unchanged.Tests
test_sync_from_zabbix_keeps_tls_psk_identity_when_not_returned: a payload withouttls_psk_identityleaves the existing identity untouched.test_update_sync_info_persists_when_object_fails_validation:update_sync_info(success=False, message='x')persists the message on aZabbixProxywhosefull_clean()fails.Both new tests fail on
mainand pass with this branch. The two affected test modules (25 tests) pass against a NetBox install running Django 6.0.