Repository navigation
Fix: enable DHCP feature using SetBuilder - #646
Conversation
Signed-off-by: Adam Trizuljak <adam.trizuljak@sap.com>
Signed-off-by: Adam Trizuljak <adam.trizuljak@sap.com>
EnsureSystemSettings enabled the dhcp feature with a merge-mode client.Patch and wrote the server-id-override-disable value in a separate Patch. On a device where the dhcp feature was off, the override write was rejected with "DHCP feature is not enabled". Build the settings into a single SetBuilder and apply them through Provider.Do, matching EnsureDHCPRelay. Do splits the feature activation into its own Set RPC executed before the dependent write, so a device with the feature disabled succeeds on the first reconcile. Idempotency is preserved: subsequent reconciles produce no Set. Signed-off-by: Adam Trizuljak <adam.trizuljak@sap.com>
This will support an extend - migrate - contract migration strategy We perform logical OR between the old and new field to preserve intent from any old version of the System resource Fix GNMI test files Signed-off-by: Adam Trizuljak <adam.trizuljak@sap.com>
EnsureSystemSettings patched relayInformationOptionServerIdOverride DisableEnabled on every reconcile, even as 0 when the dhcp feature was off. That leaf lives under the dhcp feature tree, so writing it on a feature-disabled device is rejected with "DHCP feature is not enabled". The fake gNMI test server does not enforce the feature gate, so system.txtar passed while asserting that bad write. Read the current feature state and realize the leaf per case: - override requested: set 1 and enable the feature if needed - override off but feature enabled (e.g. by DHCPRelay, or a true->false flip): patch 0, leaving the feature untouched - override off and feature disabled: write nothing This also fixes the true->false flip, which previously left the leaf stuck at 1. Update system.txtar to expect no dhcp-items in the base case. Signed-off-by: Adam Trizuljak <adam.trizuljak@sap.com>
631b4cf to
f2bdab6
Compare
|
Updated behavior according to @felix-kaestner 's review comments. Clean state: Deployed the % kubectl get system leaf1 -oyaml
apiVersion: nx.cisco.networking.metal.ironcore.dev/v1alpha1
kind: System
# ...
spec:
deviceRef:
name: leaf1
dhcp:
relayServerIdOverrideDisable: false
# ...
% gnmic -a 127.0.0.1 --port 9339 -u *** -p *** --skip-verify get -e json --values-only --path 'System/fm-items/dhcp-items' --path 'System/dhcp-items/inst-items/relayInformationOptionServerIdOverrideDisableEnabled'
[
null,
null
]Deploying the % gnmic -a 127.0.0.1 --port 9339 -u *** -p *** --skip-verify get -e json --values-only --path 'System/fm-items/dhcp-items' --path 'System/dhcp-items/inst-items/relayInformationOptionServerIdOverrideDisableEnabled'
[
{
"adminSt": "enabled",
"maxInstance": 1,
"operSt": "enabled"
},
1
]Deploying the % gnmic -a 127.0.0.1 --port 9339 -u *** -p *** --skip-verify get -e json --values-only --path 'System/fm-items/dhcp-items' --path 'System/dhcp-items/inst-items/relayInformationOptionServerIdOverrideDisableEnabled'
[
{
"adminSt": "enabled",
"maxInstance": 1,
"operSt": "enabled"
},
0
]After manually disabling the DHCP feature, the % gnmic -a 127.0.0.1 --port 9339 -u *** -p *** --skip-verify set --update-path "System/fm-items/dhcp-items" --update-value '{"adminSt":"disabled"}'
# ...
% gnmic -a 127.0.0.1 --port 9339 -u *** -p *** --skip-verify get -e json --values-only --path 'System/fm-items/dhcp-items' --path 'System/dhcp-items/inst-items/relayInformationOptionServerIdOverrideDisableEnabled'
[
{
"adminSt": "disabled",
"maxInstance": 1,
"operSt": "disabled"
},
null
]
# After deploying the `System` sample with `spec.dhcp.relayServerIdOverrideDisable: true`:
% gnmic -a 127.0.0.1 --port 9339 -u *** -p *** --skip-verify get -e json --values-only --path 'System/fm-items/dhcp-items' --path 'System/dhcp-items/inst-items/relayInformationOptionServerIdOverrideDisableEnabled'
[
{
"adminSt": "enabled",
"maxInstance": 1,
"operSt": "enabled"
},
1
] |
Merging this branch changes the coverage (4 decrease, 2 increase)
Coverage detailsCompared to commit 3ec995a (run #39222396545)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files:
|
What
relayServerIdOverrideDisableis enabledSystem.RelayServerIDOverrideDisableintoDHCPsub-structDHCPRelayServerIDOverrideDisabledefinition fromDHCPRelayintoSystemReason
EnsureSystemSettings enabled the dhcp feature with a merge-mode
client.Patch and wrote the server-id-override-disable value in a
separate Patch. On a device where the dhcp feature was off, the
override write was rejected with "DHCP feature is not enabled".
Build the settings into a single SetBuilder and apply them through
Provider.Do, matching EnsureDHCPRelay. Do splits the feature
activation into its own Set RPC executed before the dependent write,
so a device with the feature disabled succeeds on the first
reconcile. Idempotency is preserved: subsequent reconciles produce
no Set.
Testing
I reproduced the state where the error occurred using the Cisco N9K-C9300v image in Containerlab - DHCP feature is enabled,
relayInformationOptionServerIdOverrideDisableis not enabledDeploying the
Systemsample withspec.dhcp.relayServerIdOverrideDisable: truenow reconciles without problems. DHCP feature stays enabled andrelayInformationOptionServerIdOverrideDisableis correctly set to 1.It also works if DHCP feature and
spec.dhcp.relayServerIdOverrideDisableare both disabled: