Repository navigation
Conversation
When spec.antiAffinityGroup was unset, ApplyNamespace deleted the namespace's anti-affinity group on every reconcile. Pulsar implements that delete as a write to the namespace's local policies, and on a namespace without local policies yet (no topic created) the broker answers 500 (MetadataStoreException$NotFoundException), so a freshly created PulsarNamespace never becomes Ready. Read the current group first and write only on a difference, as streamnative#421 did for the bookie affinity group. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Motivation
When
spec.antiAffinityGroupis unset,ApplyNamespacedeletes the namespace's anti-affinity group on every reconcile:Pulsar implements that delete as a read-modify-write of the namespace's local policies. A namespace has no local policies until one of its bundles is first loaded (a topic is created or looked up), so on a freshly created namespace the broker answers 500, not 404:
The 500 isn't tolerated,
ApplyNamespacefails, and a newPulsarNamespacethat doesn't use anti-affinity never becomesReady. Anything waiting on it never proceeds either, for examplePulsarTopics applied in a later Argo CD sync wave. Its topics would have created the local policies, so the namespace never recovers. Reproduced on Pulsar 4.0.8 standalone with v0.21.2.This is the same blind-write pattern #421 fixed for
bookieAffinityGroup, applied to the neighbouring anti-affinity setting.Modifications
applyNamespaceAntiAffinityGroupreads the current group first and writes only when it differs from the spec:getNamespaceAntiAffinityGroupdecodes Pulsar's answer: 204 with no body when no group is set, otherwise the group as a JSON string. A 404 is treated as "no group". Any other read failure is returned rather than mistaken for "unset".Verifying this change
This change added tests and can be verified as follows:
pkg/admin/anti_affinity_group_test.go, an httptest table test in the style ofbookie_affinity_group_test.go. The fake broker returns 500 on DELETE when the namespace has no local policies, as Pulsar does. It covers each row above plus a read failure (403) that must surface. Removing the "unset and none → nothing" guard makes the two "unset stays unset" cases fail with the 500.PulsarNamespacewith no anti-affinity group and then itsPulsarTopics:antiAffinity, with no DELETEs.Ready, and the broker'sGET .../antiAffinityreflects the spec each time ("g-a","g-c", then 204).Documentation
no-need-docBehaviour of the existing field is unchanged apart from not failing; no API or CRD change.