Repository navigation
Probe/yang compliant choice encoding (Targeting PR #168) - #173
Open
vinpatel24 wants to merge 3 commits into
Open
vinpatel24 wants to merge 3 commits into
vinpatel24 wants to merge 3 commits into
Conversation
Issue Juniper#168 proposes dropping the build-time --yang-compliant flag and having the generic provider normalise choices at runtime, always writing the paired form (<choice-ident>exact</choice-ident><choice-value/>) instead of the native form (<exact/>). That rule is only safe if every platform and release accepts a paired write and means the same thing by it as by the native form. The original evidence was one vMX-class device at 26.2R1.7. This probe checks the claim on any device: whether the yang-compliant knob is supported, whether each form is accepted, whether the two produce an identical candidate diff, what encoding comes back on read, and whether a delete then needs the full compound key. Running it on a physical MX240 (21.1R1.11), a vMX (23.2R2.21) and an MX960 (25.2R1.9) showed paired writes accepted with the knob off on all three, and native and paired producing byte-identical configuration for route-filter exact, prefix-length-range, orlonger with a trailing action, community add and martians. With the knob on, reads return the paired form and a delete naming only the address is rejected. SRX and PTX are still untested, which is what this tool is for. Nothing is committed by default: each case is loaded into a locked candidate and discarded, and a device whose candidate already holds uncommitted changes is skipped. The knob stage is opt-in and uses commit confirmed so the device reverts itself even if the probe dies. Credentials are supplied at runtime from an inventory file, an environment variable or a prompt; devices.json is gitignored.
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.
Refs #168, not Closes #168
Summary
Adds
tools/choice-probe/, a NETCONF probe that validates the core assumptionbehind #168 against real devices. No provider or generator code is changed —
this is validation tooling plus the evidence it produced.
Refs #168
Why
#168 proposes dropping the build-time
jtaf-provider --yang-compliantflag andinstead having the generic provider normalise YANG choices at runtime: accept
either encoding on read, and always write the paired form
(
<choice-ident>exact</choice-ident><choice-value/>) instead of the native form(
<exact/>).That rule is only safe if every platform and release accepts a paired write and
means the same thing by it. The original proposal was tested on a single
vMX-class device at 26.2R1.7, by hand, never through
terraform apply. The mainrisk raised in review was release-to-release drift: if paired writes were a newer
capability, the rule would break on older software.
This PR exists to settle that question with data.
Evidence gathered
The assumption holds, on considerably older software than originally tested —
including physical hardware at 21.1R1.11, roughly five years older than 26.2R1.7.
The
yang-compliantknob itself also exists well before 26.2.Crucially, the probe does not stop at "the device accepted it". A device can
accept XML and silently produce different or no configuration. For each case it
loads the native form, captures the resulting candidate diff, loads the paired
form, and compares. Both forms produced byte-identical configuration on all
three releases, for:
route-filter ... exactroute-filter ... prefix-length-range /24-/24route-filter ... orlonger+ trailingrejectroute-filter ... upto /24then community add <name>martians ... orlonger allowWith the knob on (tested on vMX 23.2R2.21):
syntax error, expecting <choice-ident>That reproduces the original 26.2 findings on 23.2, so the behaviour is not
release-specific.
Safety model
By default the probe commits nothing. Each case is loaded into a locked
candidate, inspected, then discarded, and it refuses any device whose candidate
already holds uncommitted changes.
The knob-on stage is opt-in behind
--commit-knob, because the knob only takeseffect for NETCONF sessions started after a commit. It uses
commit confirmedso the device reverts itself even if the script is killed, then reverts
explicitly and verifies. All devices used were confirmed afterwards: knob off,
no
JTAF-CHOICE-PROBEpolicy in the committed config, clean candidate.Credentials are supplied at runtime via a gitignored
devices.json, theJTAF_PROBE_PASSWORDenvironment variable, or an interactive prompt. No secretsare committed.
Still open
Family coverage. Every result above is MX-family. No SRX, PTX, QFX or EX was
reachable from the test environment. Since
route-filter,martiansandcommunityare routing-policy constructs, SRX and PTX are the platforms mostworth confirming before the rule is treated as universal.
tools/choice-probe/NITA-PROMPT.mdis a ready-to-run brief for exactly that.Knob-on breadth. The knob-on path was exercised on one vMX only.
No end-to-end Terraform run. Read-side behaviour was observed via the patch
engine and NETCONF directly, not through
terraform apply.Not yet implemented — handoff notes
The proposal itself is not implemented in this PR. Anyone picking it up
should know these four things, each verified against current
master:The runtime adapter does not exist.
ConfigToValue/ValueToConfiginterraform_provider/generic/convert.gofilter device XML through the schema,so a flattened build silently drops paired fields and a
--yang-compliantbuild silently drops native case elements.
device.config()(
generic/device.go) applies this filtering before diffing.The compiled schema discards what the adapter needs.
schemaRecordinterraform_provider/patch/schema.gokeeps name/kind/key/flags only — not thechoice enum/case→value mapping required to convert
<exact/>intochoice-ident=exact.State migration is a trap.
UpgradeResourceState(generic/server.go)decodes with
IgnoreUndefinedAttributes, so existingchoice_ident/choice_valuestate from a--yang-compliantbuild issilently dropped rather than converted. This needs explicit migration.
Native same-prefix entries share an identity. In the native form,
route-filter 0/0 exactandroute-filter 0/0 longerboth reduce to anaddress-only key in
keyPredicates(patch/leafmap.go). The compound-keypath handles this correctly only once the entry is already in paired form,
so normalisation must happen before diffing.
Trailing siblings (
accept,reject,allow,community-name) must remainindependent attributes — they are not cases of the choice, and the YANG enums
list ~50 values that never appear as a
choice-ident.Running it