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

Add Multi ASIC support for apply-patch #3219

Closed
wants to merge 0 commits into from
Closed

Add Multi ASIC support for apply-patch #3219

wants to merge 0 commits into from

Conversation

xincunli-sonic
Copy link
Contributor

@xincunli-sonic xincunli-sonic commented Mar 16, 2024

What I did

Add Multi-ASIC GCU support apply-patch.

How I did it

  1. Categorize configuration as JSON patch format per ASIC.
  2. Apply patch per ASIC, including localhost.

How to verify it

admin@str3-7800-lc3-1:~/gcu$ cat jsonpatch.json 
[
    {
        "op": "add",
        "path": "/asic0/PORTCHANNEL/PortChannel108/admin_status",
        "value": "down"
    },
    {
        "op": "replace",
        "path": "/localhost/BGP_DEVICE_GLOBAL/STATE/tsa_enabled",
        "value": "true"
    },
    {
        "op": "replace",
        "path": "/asic0/BGP_DEVICE_GLOBAL/STATE/tsa_enabled",
        "value": "true"
    },
    {
        "op": "replace",
        "path": "/asic1/BGP_DEVICE_GLOBAL/STATE/tsa_enabled",
        "value": "true"
    }
]
admin@str3-7800-lc3-1:~/gcu$ sudo config apply-patch jsonpatch.json 
Patch: [{"op": "add", "path": "/asic0/PORTCHANNEL/PortChannel108/admin_status", "value": "down"}, {"op": "replace", "path": "/localhost/BGP_DEVICE_GLOBAL/STATE/tsa_enabled", "value": "true"}, {"op": "replace", "path": "/asic0/BGP_DEVICE_GLOBAL/STATE/tsa_enabled", "value": "true"}, {"op": "replace", "path": "/asic1/BGP_DEVICE_GLOBAL/STATE/tsa_enabled", "value": "true"}]
('asic0', [{'op': 'add', 'path': '/PORTCHANNEL/PortChannel108/admin_status', 'value': 'down'}, {'op': 'replace', 'path': '/BGP_DEVICE_GLOBAL/STATE/tsa_enabled', 'value': 'true'}])
NameSpace: asic0
generic_update_factory: <generic_config_updater.generic_updater.GenericUpdateFactory object at 0x7f61ae2a18e0>
generic_update_factory: <generic_config_updater.generic_updater.GenericUpdateFactory object at 0x7f61ae2a18e0>
Patch Applier: asic0: Patch application starting.
Patch Applier: asic0: Patch: [{"op": "add", "path": "/PORTCHANNEL/PortChannel108/admin_status", "value": "down"}, {"op": "replace", "path": "/BGP_DEVICE_GLOBAL/STATE/tsa_enabled", "value": "true"}]
Patch Applier: Getting current config db.
Patch Applier: Simulating the target full config after applying the patch.
Patch Applier: Validating all JsonPatch operations are permitted on the specified fields
Patch Applier: Validating target config does not have empty tables, since they do not show up in ConfigDb.
Patch Applier: Sorting patch updates.
<class 'generic_config_updater.patch_sorter.StrictPatchSorter'>
Patch Applier: The patch was sorted into 0 changes.
Patch Applier: Applying 0 changes in order.
Patch Applier: Verifying patch updates are reflected on ConfigDB.
Patch Applier: Patch application completed.
('localhost', [{'op': 'replace', 'path': '/BGP_DEVICE_GLOBAL/STATE/tsa_enabled', 'value': 'true'}])
NameSpace: 
generic_update_factory: <generic_config_updater.generic_updater.GenericUpdateFactory object at 0x7f61b1b547c0>
generic_update_factory: <generic_config_updater.generic_updater.GenericUpdateFactory object at 0x7f61b1b547c0>
Patch Applier: : Patch application starting.
Patch Applier: : Patch: [{"op": "replace", "path": "/BGP_DEVICE_GLOBAL/STATE/tsa_enabled", "value": "true"}]
Patch Applier: Getting current config db.
Patch Applier: Simulating the target full config after applying the patch.
Patch Applier: Validating all JsonPatch operations are permitted on the specified fields
Patch Applier: Validating target config does not have empty tables, since they do not show up in ConfigDb.
Patch Applier: Sorting patch updates.
<class 'generic_config_updater.patch_sorter.StrictPatchSorter'>
Patch Applier: The patch was sorted into 0 changes.
Patch Applier: Applying 0 changes in order.
Patch Applier: Verifying patch updates are reflected on ConfigDB.
Patch Applier: Patch application completed.
('asic1', [{'op': 'replace', 'path': '/BGP_DEVICE_GLOBAL/STATE/tsa_enabled', 'value': 'true'}])
NameSpace: asic1
generic_update_factory: <generic_config_updater.generic_updater.GenericUpdateFactory object at 0x7f61b1b547c0>
generic_update_factory: <generic_config_updater.generic_updater.GenericUpdateFactory object at 0x7f61b1b547c0>
Patch Applier: asic1: Patch application starting.
Patch Applier: asic1: Patch: [{"op": "replace", "path": "/BGP_DEVICE_GLOBAL/STATE/tsa_enabled", "value": "true"}]
Patch Applier: Getting current config db.
Patch Applier: Simulating the target full config after applying the patch.
Patch Applier: Validating all JsonPatch operations are permitted on the specified fields
Patch Applier: Validating target config does not have empty tables, since they do not show up in ConfigDb.
Patch Applier: Sorting patch updates.
<class 'generic_config_updater.patch_sorter.StrictPatchSorter'>
Patch Applier: The patch was sorted into 0 changes.
Patch Applier: Applying 0 changes in order.
Patch Applier: Verifying patch updates are reflected on ConfigDB.
Patch Applier: Patch application completed.
Patch applied successfully.

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)

config/main.py Outdated
print("Patch: {}".format(patch))
# Iterate over each change in the JSON Patch
for change in patch:
asic_id, modified_path = extract_asic_id(change["path"])
Copy link

@VladimirKuk VladimirKuk Mar 18, 2024

Choose a reason for hiding this comment

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

What happens if "path" not in change? #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.

According to RFC: https://www.rfc-editor.org/rfc/rfc6902#section-4, operation objects MUST have exactly one "path" member.

config/main.py Outdated
ctx.fail('Invalid IP address')
db = ValidatedConfigDBConnector(ctx.obj['db'])
db = ValidatedConfigDBConnector(ctx.obj['db'])
Copy link

@VladimirKuk VladimirKuk Mar 18, 2024

Choose a reason for hiding this comment

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

What happens if "db" not in ctx.obj? #Resolved

@xincunli-sonic xincunli-sonic marked this pull request as ready for review March 18, 2024 23:38
@wen587
Copy link
Contributor

wen587 commented Mar 19, 2024

Do we support HLD #### 3.2.3.5 Checkpoints and Rollbacks in this PR? Or you want to propose another PR?

@xincunli-sonic
Copy link
Contributor Author

Do we support HLD #### 3.2.3.5 Checkpoints and Rollbacks in this PR? Or you want to propose another PR?

Yes, it will be in another further pr to address the HLD mentioned checkpoint and rollback part.

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.

3 participants