Skip to content
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

Merged
merged 11 commits into from
Feb 18, 2022

Conversation

ghooo
Copy link
Contributor

@ghooo ghooo commented Jan 5, 2022

What I did

Fixes #1930

Issue can be summarized into these 2 case:

  • A patch can contain an operation to turn port admin up -- do at the end
  • A patch that modifies config that needs the port to be down -- start by bringing the port down then do the update then bring it back up

How 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 following

    • If a port is up, make sure the move does not make changes to related critical-port configs
    • If the move is turning a port up, make sure there is no critical-port config are still left in the patch
  • Added a move extender to critical-port changes:

    • If a port is up, bring down if there are critical-port changes
    • If the move is turning a port up, flip it to down if there are still critical-port configs left. In other words, do not turn the port back up until all critical-port changes are in done.

How to verify it

  • Added AddRack unit-test to tests/generic_config_updater/files/patch_sorter_test_success.json
  • Other unit-tests

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 to tests/generic_config_updater/files/patch_sorter_test_success.json for new sorting-order

@ghooo ghooo force-pushed the dev/mghoneim/port_crit branch 3 times, most recently from 2980969 to bb7d707 Compare January 10, 2022 23:27
@sonic-net sonic-net deleted a comment from lgtm-com bot Jan 10, 2022
@sonic-net sonic-net deleted a comment from lgtm-com bot Jan 10, 2022
@ghooo ghooo marked this pull request as ready for review January 10, 2022 23:38
@ghooo ghooo requested a review from renukamanavalan January 10, 2022 23:41
@ghooo ghooo changed the title [GCU] Turning port-down before some critical port changes [GCU] Turning port admin down before some critical port changes Jan 11, 2022
path_addressing)
self.path_addressing = path_addressing

def identify_admin_up_ports(self, config):
Copy link
Contributor

@qiluo-msft qiluo-msft Jan 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

identify_admin_up_ports

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

Copy link
Contributor Author

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

Copy link
Contributor Author

@ghooo ghooo Jan 12, 2022

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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:
Copy link
Contributor

@qiluo-msft qiluo-msft Jan 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PortCriticalMoveValidator

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

@ghooo ghooo Jan 18, 2022

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?

Copy link
Contributor Author

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

@ghooo ghooo force-pushed the dev/mghoneim/port_crit branch from ae0e2d5 to 52266cf Compare January 25, 2022 00:28
@lgtm-com

This comment has been minimized.

qiluo-msft
qiluo-msft previously approved these changes Jan 25, 2022
Copy link
Contributor

@qiluo-msft qiluo-msft left a 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.

@qiluo-msft
Copy link
Contributor

There is a recent build fix on master branch. Could you rebase to latest master or merge it?

qiluo-msft
qiluo-msft previously approved these changes Jan 28, 2022
@ghooo
Copy link
Contributor Author

ghooo commented Feb 14, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ghooo ghooo force-pushed the dev/mghoneim/port_crit branch from 8b3b0b8 to 0581219 Compare February 17, 2022 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generic_patch: AddRack: Port should be turned as admin up as last change
5 participants