Skip to content

[multi-asic] Refine [override config table] for corner cases#2918

Merged
wenyiz2021 merged 16 commits intosonic-net:masterfrom
wenyiz2021:override-config-table
Jul 20, 2023
Merged

[multi-asic] Refine [override config table] for corner cases#2918
wenyiz2021 merged 16 commits intosonic-net:masterfrom
wenyiz2021:override-config-table

Conversation

@wenyiz2021
Copy link
Contributor

@wenyiz2021 wenyiz2021 commented Jul 19, 2023

sudo config override-config-table can be used in 2 flows:

  1. from ndm process
  2. used by user from device to quickly change config partially/fully

in the 2nd case, user can input wrong format config, e.g. not accommodate for ndm standard. we should abort CLI in this case.
another example is user tries to override with empty config, in this case nothing will be overridden.

fixes: #2916

MSFT work item: 24339857

What I did

handle the corner cases in CLI

How I did it

How to verify it

  1. empty golden config:
admin@str3-8800-lc2-1:/etc/sonic$ sudo config override-config-table golden_config_db.json
Removing configDB overriden table first ...
Overriding input config to configDB ...
Overriding completed. No service is restarted.
Removing configDB overriden table first ...
Overriding input config to configDB ...
Overriding completed. No service is restarted.
Removing configDB overriden table first ...
Overriding input config to configDB ...
Overriding completed. No service is restarted.

command will pass, nothing is overwritten from output of sonic-cfggen --print-data -d

  1. config input is wrong format
{
    "NEW_FEATURE_TABLE": {
        "entry": {
            "field": "value",
            "state": "disabled"
        }
    }
}
admin@str3-8800-lc2-1:/etc/sonic$ sudo config override-config-table golden_config_db.json
Wrong config format! 'localhost' not found in host config! cannot override.. abort

command will abort

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

Running command: config override-config-table /etc/sonic/golden_config_db.json
Traceback (most recent call last):
  File "/usr/local/bin/config", line 8, in <module>
    sys.exit(config())
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/config/main.py", line 1821, in override_config_table
    ns_config_input = config_input["localhost"]
KeyError: 'localhost'

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

@wenyiz2021 wenyiz2021 requested a review from wen587 July 19, 2023 22:57
@wenyiz2021 wenyiz2021 requested a review from wen587 July 20, 2023 20:55
@wenyiz2021 wenyiz2021 merged commit 6716bcf into sonic-net:master Jul 20, 2023
@wenyiz2021 wenyiz2021 changed the title Refine [override config table] for corner cases [multi-asic] Refine [override config table] for corner cases Jul 20, 2023
rajkumar38 pushed a commit to rajkumar38/sonic-utilities that referenced this pull request Jul 25, 2023
…et#2918)

Handle corner case for multi-asics:
1. when golden config file is empty for multi-asic case
2. when config format is incorrect for multi-asics, e.g. localhost or namespace is missing in golden config db
@StormLiangMS
Copy link
Contributor

@wenyiz2021 do we have ADO for this? Looks like an enhancement other than bug fix?

@wenyiz2021
Copy link
Contributor Author

wenyiz2021 commented Aug 7, 2023

@wenyiz2021 do we have ADO for this? Looks like an enhancement other than bug fix?

hi @StormLiangMS, without this it was failing https://github.com/sonic-net/sonic-mgmt/blob/ffac1463a768c3dee0f2894c6c67834f2387d5df/tests/override_config_table/test_override_config_table.py#L201 so it should be bug fix.

ADO number: 24339857

but I also made test_override_config_table.py to skip for now, we need NDM to push new config changes for multi-asic.

@gechiang
Copy link
Contributor

gechiang commented Aug 9, 2023

@StormLiangMS , @yxieca , This is a bug fix that needs to be backported to 202205, 202211 and 202305.
We are seeing this issue being exposed recently under 202205. Appreciate if you can cherry-pick this PR to the above requested branches.
Thanks!

yxieca pushed a commit that referenced this pull request Aug 10, 2023
Handle corner case for multi-asics:
1. when golden config file is empty for multi-asic case
2. when config format is incorrect for multi-asics, e.g. localhost or namespace is missing in golden config db
StormLiangMS pushed a commit that referenced this pull request Aug 14, 2023
Handle corner case for multi-asics:
1. when golden config file is empty for multi-asic case
2. when config format is incorrect for multi-asics, e.g. localhost or namespace is missing in golden config db
pdhruv-marvell pushed a commit to pdhruv-marvell/sonic-utilities that referenced this pull request Aug 23, 2023
…et#2918)

Handle corner case for multi-asics:
1. when golden config file is empty for multi-asic case
2. when config format is incorrect for multi-asics, e.g. localhost or namespace is missing in golden config db
@wenyiz2021 wenyiz2021 deleted the override-config-table branch May 21, 2024 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[chassis] [MA] [override-config-table] CLI fail for multi-asic duts

5 participants