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

[config][generic-update] Implement ChangeApplier for ConfigDb format #1763

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

qiluo-msft
Copy link
Contributor

What I did

Implement ChangeApplier for ConfigDb format

design doc: https://github.com/Azure/SONiC/blob/master/doc/config-generic-update-rollback/Json_Change_Application_Design.md#312-change-applier

How I did it

How to verify it

TODO: manual test on DUT

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

@qiluo-msft qiluo-msft requested a review from ghooo August 16, 2021 10:27
@@ -18,9 +21,94 @@ def release_lock(self):
pass

class ChangeApplier:
Copy link
Contributor

@ghooo ghooo Sep 3, 2021

Choose a reason for hiding this comment

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

maybe move it to a new file? #Closed

Copy link
Contributor Author

@qiluo-msft qiluo-msft Sep 8, 2021

Choose a reason for hiding this comment

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

will move in later iteration.

rc = self.exec_command(restart_comand)
if rc != 0:
raise GenericConfigUpdaterError(f"Restart command failed: {restart_comand}, rc={rc}")
rc = self.exec_command(validate_command)
Copy link
Contributor

@ghooo ghooo Sep 3, 2021

Choose a reason for hiding this comment

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

Validate commands do not need to be associated with restart commands, i.e. we should be able to verify the services that absorb the changes automatically. #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

self.config_db.set_entry(parts[0], parts[1], entry)

def apply(self, change: JsonChange):
patch = change.patch
Copy link
Contributor

Choose a reason for hiding this comment

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

Using the patch within the change is ok, but it is limiting and is a little different than the design document. Using patch will forces specific order of execution on the ChangeApplier while in fact there is no ordering. This causes problems like multiple restarts which is solved by the lazy restart.

JsonChange on the other hand can be used to just getting the target config, and then the diff. The diff is per table, so we can handle table by table alphabetically.

JsonChange only provides one function which is apply (notice the second step in the diagram) GenerateTargetConfig. I think patch access should be reduced i.e. to be preceded by _

rc = self.exec_command(restart_comand)
if rc != 0:
raise GenericConfigUpdaterError(f"Restart command failed: {restart_comand}, rc={rc}")
rc = self.exec_command(validate_command)
Copy link
Contributor

Choose a reason for hiding this comment

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

Validate commands expect ConfigDb before and after the update, from design doc:

validate-commands - Multiple CLI commands used to validate the service has absorbed the change successfully. The validate commands can expect the config before and after the update to passed to the CLI commands for detailed validation if needed.

This was requested by linkedin team

Copy link
Contributor

Choose a reason for hiding this comment

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

We discussed this with LinkedIn: Zhenggen Xu zxu@linkedin.com; Praveen Chaudhary pchaudhary@linkedin.com on 3/15, from the notes:

image

Specifically when they delete a port they not only verify it was deleted from ConfigDb, but also from AsicDB. Check code here.

So in order to support their request, we are passing to the validation function what commands were deleted/added. I just made it a little bit generic and passed the whole configDb before and after the update. The validate script itself can do diffing to identify these commands that were changed, or they can loop over the PORTs and check which was deleted.

Signed-off-by: Qi Luo <qiluo-msft@users.noreply.github.com>
@lgtm-com
Copy link

lgtm-com bot commented Sep 15, 2021

This pull request introduces 4 alerts when merging 727685d into f76f672 - view on LGTM.com

new alerts:

  • 4 for Unused import

@qiluo-msft qiluo-msft marked this pull request as ready for review September 16, 2021 14:58
@qiluo-msft qiluo-msft marked this pull request as draft October 21, 2021 07:16
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.

2 participants