Pushing the same 200-line NETCONF change to one router with :candidate and one with only :writable-running, how must the plan differ, and why?
answer
- where the edits are live
- when YANG constraints are checked
- one RPC versus many
- checkpoint before touching running
basics
~20 sOn the :candidate router you stage the change in pieces, validate, and commit it in one step. On the running-only router every <edit-config> is live and must leave running valid, so send the change as one edit after checkpointing running.
solid answer
~40 sStart from each router's `<hello>`. With `:candidate`, the 200 lines can go into the candidate over several `<edit-config>` calls because YANG defers constraint checks on the candidate until `<validate>` or `<commit>` (RFC 7950 Section 8.3.3); you validate, then one `<commit>` sets running, and if the device cannot commit everything running stays unchanged. With only `:writable-running`, each `<edit-config>` is applied as it arrives and constraints are enforced at the end of each one, so a split change exposes live intermediate states and can fail midway with part of it applied. There you checkpoint running first, send the change as a single `<edit-config>` ordered so the result is valid, and keep the checkpoint ready to restore. On both, test before saving to startup.
go deeper
Recall that a candidate lets you stage and commit, while a writable running datastore applies each edit straight away.
Explain how the two capabilities are advertised and why commit does not exist without :candidate.
Demonstrate the plan for each router: constraint timing, one edit versus many, checkpoint and restore on running, validate and commit on the candidate, and testing before saving.
Discuss how a change-automation platform should handle a fleet with mixed datastore support, including whether to refuse devices that lack a candidate for large changes.
## Read the capabilities first Every plan starts from the server's `<hello>`. The two routers in this scenario advertise: - Router A: `urn:ietf:params:netconf:capability:candidate:1.0` (and possibly `:validate:1.1`, `:startup:1.0`). - Router B: `urn:ietf:params:netconf:capability:writable-running:1.0` and no `:candidate`. On router B, `<commit>` and `<discard-changes>` do not exist: RFC 6241 says that without `:candidate` the `<commit>` operation is not available. A script written for router A fails on router B as soon as it names the candidate, and a script that simply retargets the same edits at running inherits every risk described below. ## Why the same 200 lines behave differently The difference comes from **when YANG constraints are enforced**. RFC 7950 Section 8.3.3 says that when the datastore is running or startup, constraints must be enforced at the end of each `<edit-config>` or `<copy-config>`; when it is the candidate, enforcement is delayed until `<commit>` or `<validate>`. | Concern | Router A: candidate | Router B: writable running only | |---|---|---| | When an edit becomes live | only at `<commit>` | as soon as each `<edit-config>` succeeds | | When constraints are checked | at `<validate>` or `<commit>` | at the end of every `<edit-config>` | | Splitting the change into many RPCs | harmless | exposes each intermediate state on the live network | | Failure partway through | running unchanged; fix the candidate | earlier edits already applied | | Abandoning the change | `<discard-changes>` | restore a saved copy of running | Suppose the change creates an interface and then adds routes and policy that reference it. On router A the reference may be staged before the interface exists, because nothing is checked until the end. On router B, an `<edit-config>` whose YANG reference (a `leafref`, for example) points at an interface that does not exist yet fails, and an `<edit-config>` that creates the interface goes live before its policy does. ## The plan for the candidate router 1. Confirm `:candidate`, and note `:validate` and `:startup`. 2. Send `<discard-changes/>` so the candidate starts equal to running, and guard the candidate against other writers for the duration. 3. Stage the change in as many `<edit-config>` calls with target `<candidate/>` as is convenient. 4. Send `<validate>` with `<candidate/>` as the source if `:validate` is advertised, and fix any `<rpc-error>`. 5. Send `<commit/>`. RFC 6241 says that if the device cannot commit all of the changes, running must remain unchanged. 6. Test, then `<copy-config>` running to startup if the device has a distinct startup. ## The plan for the running-only router 1. **Checkpoint running.** RFC 6241 Appendix E uses `<copy-config>` from running to a URL target, which needs the `:url` capability; otherwise read running with `<get-config>` and keep it client-side. 2. **Check before writing** where the server allows it. With `:validate`, `<validate>` accepts an inline `<config>` holding a complete configuration, so the client can submit the full intended configuration for checking; `<edit-config>` also has its own test option. 3. **Send the change as one `<edit-config>`**, ordered so the result is valid, so the constraints are checked once against the finished configuration and the network never runs on a half-applied version. 4. **Decide the error behaviour**: how `<edit-config>` reacts to a failure partway through is set by its error option, and the all-or-nothing choice needs its own capability. 5. Test, then save to startup, or restore the checkpoint if the tests fail. A commit that reverts by itself if the operator loses access is a candidate-side feature, so router B has no such safety net and the checkpoint is the rollback plan. ## The judgment call The candidate gives a **staging area and a single switch-over point**; writable running gives neither, so the client has to supply them itself: - **one RPC instead of twenty**, so the network never runs on a partial change; - **a checkpoint instead of `<discard-changes>`**, because there is no scratch copy to throw away; - **validation before writing**, using `<validate>` on a complete inline configuration or the edit's own test option, because the server checks running only as each edit lands; - **an external test before any save**, the same on both routers. Routers that advertise **both** capabilities let a client choose either path. Mixing them across tools on one device is how a direct write and a candidate commit end up racing, so automation should pick one path per device and stick to it. For a fleet, the capability list is the input that decides which plan a change runs, and a change pipeline that cannot tell the two kinds of router apart will eventually run the candidate plan against a running-only device.
- Why not split the change into twenty small <edit-config> calls on the running-only router?Each call is applied to the live device as it succeeds and must leave running valid on its own. Twenty calls mean nineteen intermediate configurations the network actually runs on, an ordering problem for every cross-reference, and a failure in call fourteen that leaves thirteen applied. One `<edit-config>` is checked once, on the finished result.
- Can a NETCONF client check a change on a router without a candidate before applying it?Partly. If the server advertises `:validate`, `<validate>` accepts an inline `<config>` containing a complete configuration, so the client can submit its full intended configuration for checking. `<edit-config>` also offers a test option. Neither proves the change will behave correctly once applied; that still needs testing on the device.
- What should automation do with a router that advertises both :candidate and :writable-running?Pick one path for that device. Both are legal, but if one tool writes running directly while another stages in the candidate, the candidate can be stale relative to running and the two tools race. Standardising on the candidate keeps the staging area and single commit.
saying these in an interview costs you the question
- Every NETCONF device has a candidate, so one script fits all routers.
- On running, constraints are checked only once the whole change is sent.
- Splitting the change into many small edit-configs makes running safer.
- A <commit> applies the queued edits on a running-only router.
- Without a candidate, a change cannot be checked before it is applied.