CASSSIDECAR-429: Add RFC 6902-inspired JSON Patch support to ConfigurationManager#369
Open
pauloricardomg wants to merge 1 commit into
Open
CASSSIDECAR-429: Add RFC 6902-inspired JSON Patch support to ConfigurationManager#369pauloricardomg wants to merge 1 commit into
pauloricardomg wants to merge 1 commit into
Conversation
…ationManager Implement patch operations using RFC 6902-inspired semantics: paths reference the effective configuration structure but mutations target the overlay. Supported operations: add, remove, replace, test. Key behaviors: - Paths use JSON Pointer syntax for both top-level and nested cassandraYaml keys - Nested path mutations copy the entire top-level key from effective config into the overlay (copy-siblings strategy), ensuring the overlay is self-contained at top-level key granularity - test operations assert against effective config without mutating - replace fails if path is absent from effective config (typo protection) - remove fails if path only exists in base template (not in overlay) - All operations validated atomically before any mutations are applied - JVM option key format and conflicting boolean option validation - Nested paths into array-valued keys are rejected gracefully
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.
Summary
Implements patch operations for the Configuration Manager using RFC 6902-inspired semantics. Paths reference the effective configuration structure (base template + overlay merged) but mutations target the overlay only. Supported operations:
add,remove,replace,test.moveandcopyare intentionally excluded as they introduce ambiguous semantics in the two-tier configuration model.Configuration Model
The configuration uses a two-tier model:
cassandra.yamlprovided by the operator, read-only via this API.ConfigurationProvider.Patch operations target paths in the effective config (what the client sees from GET) but only mutate the overlay. The base template is never modified by this API.
Overview
Patch Operations
addremovereplacetestCopy-Siblings Strategy (nested paths)
When a patch targets a nested path within a top-level
cassandraYamlkey, the entire top-level key value is copied from the effective config into the overlay before applying the leaf change. This ensures the overlay is always self-contained at the top-level key granularity, preventing orphan fragments if the base template later removes the parent structure.Example:
Template:
{"memtable": {"configurations": {"trie": {"class_name": "TrieMemtable", "max_shard_count": 4}, "skiplist": {"class_name": "SkipListMemtable"}}}}Patch:
replace /configuration/cassandraYaml/memtable/configurations/trie/max_shard_countwith value8Resulting overlay (entire
memtablekey stored, not just the leaf):{"memtable": {"configurations": {"trie": {"class_name": "TrieMemtable", "max_shard_count": 8}, "skiplist": {"class_name": "SkipListMemtable"}}}}The trade-off is that sibling fields are "pinned" in the overlay. If the base template later modifies
skiplist, the overlay's copy takes precedence. Operators canremovethe sibling path from the overlay to re-sync with the template.Main Classes
ConfigurationPatchOperationOpenum (ADD, REMOVE, REPLACE, TEST) + path + valueConfigurationPatchValidatorConfigurationPatchApplierConfigurationPatchExceptionConfigurationConflictExceptionConfigurationManager.patchConfigurationValidation Flow
ConfigurationPatchValidator): path prefix, segment parsing, value presence, duplicate mutation pathsConfigurationManager): caller'sexpectedHashvs current effective config hashConfigurationPatchApplierphase 1): per-op checks against effective config and overlayConfigurationPatchApplierphase 2): only if all preconditions passAdditional Validations
-D,-X, or-XX:-XX:+Fooand-XX:-Foocannot coexist (remove first, then add)extraJvmOptspaths must be flat: no nested segments allowedTest Overview
ConfigurationPatchValidatorTestConfigurationPatchApplierTestConfigurationManagerTest