-
Notifications
You must be signed in to change notification settings - Fork 666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GCU] Turning port admin down before some critical port changes #1998
Conversation
2980969
to
bb7d707
Compare
path_addressing) | ||
self.path_addressing = path_addressing | ||
|
||
def identify_admin_up_ports(self, config): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def identify_admin_up_ports(self, config):
Could you try leverage JsonPath, which is a mature query language? For this function, you may query $.PORT.*[?(@.admin_status == 'up')]
.
ref: https://support.smartbear.com/alertsite/docs/monitors/api/endpoint/jsonpath.html
online evaluator
python lib: https://github.com/json-path/JsonPath#path-examples #Pending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a JAVA lib, I think you meant: https://github.com/kennknowles/python-jsonpath-rw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check this reply
In a future PR, I can leverage JsonPath instead the Patterns
. I can add get_values()
to ConfigFilter
class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future PR is good to me. Sorry for wrong library. I did not search for all the python libraries. python-jsonpath-rw seems a good candidate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -670,6 +759,28 @@ def _validate_table(self, table, config): | |||
# the only invalid case is if table exists and is empty | |||
return table not in config or config[table] | |||
|
|||
class PortCriticalMoveValidator: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class PortCriticalMoveValidator:
I believe there will more cases other than port in future. The concept is similar to a lock. When a node is locked, the manipulation of the node subtree is banned.
Can we add a yang model extension to capture this behavior, and apply the extension to port as a first case? #Pending
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea of a locking a node is interesting. My thought was to name it TransitionalValueValidator
later if we need to support more cases, and also move it to YANG. Added that as a TODO in line 390.
# TODO: port-critical fields are hard-coded for now, it should be moved to YANG models # NOTE: PortCritical validation logic can be generalized to be validation for any config that # requires another config to be of a specific value. Call the validator "TransitionalValueValidator" # For the case of port-critical validation the transitional value would be "admin_status=down".
Let me think about the lock idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry took me a bit to think about this, had other work items.
I think the idea of lock is similar to what we have today for the validation. If the validation fails we cannot do the update.
The concept is similar to a lock. When a node is locked, the manipulation of the node subtree is banned
I think this is the same as what we have for validation
if validation of a move that is changing a specific part of the config fails, the move is rejected.
We can also think about the lock in another way, let's think about the dependency between PORT and VLAN_MEMBER table
{
"PORT": {
"Ethernet0": {}
},
"VLAN_MEMBER": {
"Vlan715|Ethernet0": {
"tagging_mode": "untagged"
}
}
}
We cannot delete Ethernet0
unless we delete Vlan715|Ethernet0
. hence the deletion cannot take place and the Ethernet0
deletion is locked. We already have that as a validation check which is FullConfigMoveValidator
We can also think about the lock for the CreateOnly
configs, if a config is CreateOnly
it cannot be modified hence it is modification locked. We have to delete the parent and add it back. Check CreateOnlyMoveValidator
I prefer another Validator
maybed named RequiredTransitionalValueValidator
or something over a lock. I think it will be confusing to have a lock and the validators at the same time. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to handle any config and named RequiredValueValidator
ae0e2d5
to
52266cf
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with minor comment in code comment.
There is a recent build fix on master branch. Could you rebase to latest master or merge it? |
2caa251
to
310b841
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
310b841
to
8b3b0b8
Compare
8b3b0b8
to
0581219
Compare
What I did
Fixes #1930
Issue can be summarized into these 2 case:
admin up
-- do at the endHow I did it
The configs that need the port to be down, we will call them
critical-port
configs.Added a move validator to validate
critical-port
configs, which does the followingcritical-port
configscritical-port
config are still left in the patchAdded a move extender to
critical-port
changes:critical-port
configs left. In other words, do not turn the port back up until allcritical-port
changes are in done.How to verify it
AddRack
unit-test totests/generic_config_updater/files/patch_sorter_test_success.json
Previous command output (if the output of a command-line utility has changed)
Check issue #1930 for old sorting order
New command output (if the output of a command-line utility has changed)
Check
AddRack
unit-test totests/generic_config_updater/files/patch_sorter_test_success.json
for new sorting-order