[sonic-package-manager] Fix YANG validation failure on upgrade when feature has constraints in YANG model on FEATURE table#2933
Merged
bingwang-ms merged 2 commits intosonic-net:masterfrom Nov 20, 2023
Conversation
…eature has constraints in YANG model on FEATURE table
In case feature's YANG model has a constraint on FEATURE table:
```
must "current() = \"disabled\" or /feature:sonic-feature/feature:FEATURE/feature:FEATURE_LIST[feature:name=\"Y\"]/feature:state = \"enabled\"" {
error-message "X can only be set when is Y enabled";
}
```
it will fail to upgrade due to transient disablement of the feature by
the upgrade process.
The upgrade process looks like this:
1. Disable feature via FEATURE table and wait for container to go down.
2. Remove all configuration files generated for this feature.
3. Create new configuration files for new docker image.
4. Merge new init_cfg from the new docker image and perform YANG
validation.
5. Enable feature via FEATURE table.
6. Remove old docker image.
Since there is a transient enable/disable of the feature and YANG
validation in the middle having the above constrains in YANG model would
lead to an upgrade failure.
I attempt to fix this by executing systemctl commands directly without
the modification of the FEATURE table.
Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
Collaborator
|
@qiluo-msft could you help to review or assign someone? |
Collaborator
|
@stepanblyschak please handle the easyCLA |
Contributor
Author
|
@liat-grozovik I don't know what is needed from my side to handle EasyCLA. It looks like it hanged. @liat-grozovik @volodymyrsamotiy @qiluo-msft Could you please help? |
Collaborator
|
@stepanblyschak can you close and reopen? maybe it can help. |
Collaborator
|
@qiluo-msft @volodymyrsamotiy please review |
Contributor
|
/easycla |
qiluo-msft
reviewed
Sep 10, 2023
sonic_package_manager/manager.py
Outdated
| for npu in range(self.num_npus): | ||
| run_command(['systemctl', action, f'{name}@{npu}']) | ||
|
|
||
| def _enable_feature(self, package: Package, block: bool = True): |
Contributor
Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
Contributor
Author
|
/azpw run |
Collaborator
|
/AzurePipelines run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
@qiluo-msft any further comment or this can be approved and merge? |
Contributor
Author
|
@liat-grozovik This change is needed for 2205, 2211 and 2305 |
Collaborator
|
@lguohan the urgency is to get this on master and 202305. can you please assign someone? |
ganglyu
approved these changes
Nov 14, 2023
nmoray
pushed a commit
to nmoray/sonic-utilities
that referenced
this pull request
Jun 25, 2025
…eature has constraints in YANG model on FEATURE table (sonic-net#2933) * [sonic-package-manager] Fix YANG validation failure on upgrade when feature has constraints in YANG model on FEATURE table Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In case feature's YANG model has a constraint on FEATURE table:
it will fail to upgrade due to transient disablement of the feature by the upgrade process.
The upgrade process looks like this:
Since there is a transient enable/disable of the feature and YANG validation in the middle having the above constrains in YANG model would lead to an upgrade failure.
What I did
I fixed an issue that leads to upgrade failure for some extensions.
How I did it
Replaces setting FEATURE state with systemctl commands.
How to verify it
Given the above example, verify that the upgrade process passes 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)