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

sonic-mgmt-common: port to libyang3 #157

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bradh352
Copy link

@bradh352 bradh352 commented Feb 19, 2025

SONiC Libyang3 upgrade Tracking PR: sonic-net/sonic-buildimage#21679

This PR depends on the other PRs mentioned in the above tracking PR.

The API changes between libyang1 and libyang3 are drastic.

The cvl test cases are currently passing all tests.

This depends on libyang3's devel branch plus this rejected patch:

Or the libyang3 package built via sonic-buildimage which is based on v3.7.8 + all the necessary patches, part of sonic-net/sonic-buildimage#21679

@mssonicbld
Copy link

/azp run

@bradh352 bradh352 marked this pull request as draft February 19, 2025 15:18
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bradh352
Copy link
Author

@dutta-partha probably going to need your help on this as you are the original author. I've got the port to libyang3 compiling at least, but I'm not entirely sure how to test it or debug it. I'm sure there are issues here.

@ganglyu I've seen you make some commits here too, maybe you can help?

I think out of all the libyang3 porting this is the one that is the most complex and that I know the least about.

@ganglyu
Copy link
Contributor

ganglyu commented Feb 19, 2025

@bradh352
This pipeline downloads libyang*.deb from the sonic-buildimage.vs master pipeline artifacts. However, since your changes have not been merged into the master branch, the libyang*3.*.deb file is not available.

    - task: DownloadPipelineArtifact@2
      inputs:
        source: specific
        project: build
        pipeline: 142
        artifact: sonic-buildimage.vs
        runVersion: 'latestFromBranch'
        runBranch: 'refs/heads/$(BUILD_BRANCH)'
        patterns: |
            target/debs/bookworm/libyang*.deb
            target/python-wheels/bookworm/sonic_yang_models*.whl
      displayName: "Download sonic buildimage"

@ganglyu
Copy link
Contributor

ganglyu commented Feb 19, 2025

You can follow the pipeline to setup your environment and run unit test.
https://github.com/sonic-net/sonic-mgmt-common/blob/master/azure-pipelines.yml

@bradh352
Copy link
Author

@ganglyu

@bradh352 This pipeline downloads libyang*.deb from the sonic-buildimage.vs master pipeline artifacts. However, since your changes have not been merged into the master branch, the libyang_3._.deb file is not available.

Right, I'm aware of that. This PR is expected to fail in the SONiC CI system (azure pipelines) until the dependent PRs are merged.

I was hoping someone more familiar with sonic-mgmt-common could help with testing and validation of this particular PR. Its by far the most complex port to libyang3 out of all the various sub-projects.

@ganglyu
Copy link
Contributor

ganglyu commented Feb 20, 2025

@sachinholla would you please help?

@bradh352 bradh352 force-pushed the bradh352/libyang3 branch from e933aa2 to ef91050 Compare March 3, 2025 23:48
@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bradh352 bradh352 force-pushed the bradh352/libyang3 branch from 02ce756 to 4a72c1f Compare March 4, 2025 00:09
@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bradh352 bradh352 force-pushed the bradh352/libyang3 branch from 4a72c1f to 3fad970 Compare March 4, 2025 00:11
@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bradh352 bradh352 force-pushed the bradh352/libyang3 branch from 3fad970 to 36e287b Compare March 4, 2025 00:13
@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bradh352 bradh352 force-pushed the bradh352/libyang3 branch from 36e287b to 10f9078 Compare March 4, 2025 00:15
@mssonicbld
Copy link

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@bradh352 bradh352 marked this pull request as ready for review March 4, 2025 00:18
Copy link
Contributor

@sachinholla sachinholla left a comment

Choose a reason for hiding this comment

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

Hi @bradh352, all tests are passing on my development vm too.. Changes look good to me. Will ask cvl maintainers to take a look.

Seeing a few compiler warnings though:

In file included from _cgo_export.c:4:
util.go: In function ‘customLogCb’:
util.go:30:65: warning: passing argument 3 of ‘customLogCallback’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
util.go:26:62: note: expected ‘char *’ but argument is of type ‘const char *’
# github.com/Azure/sonic-mgmt-common/cvl/internal/util
../cvl/internal/util/util.go: In function ‘customLogCb’:
../cvl/internal/util/util.go:30:72: warning: passing argument 3 of ‘customLogCallback’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   30 |         customLogCallback(level, (char*)msg, (char*)data_path?data_path:schema_path);
      |                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
../cvl/internal/util/util.go:26:62: note: expected ‘char *’ but argument is of type ‘const char *’
   26 | extern void customLogCallback(LY_LOG_LEVEL, char* msg, char* path);
      |                                                        ~~~~~~^~~~

@bradh352
Copy link
Author

bradh352 commented Mar 4, 2025

Hi @bradh352, all tests are passing on my development vm too.. Changes look good to me. Will ask cvl maintainers to take a look.

Seeing a few compiler warnings though:

In file included from _cgo_export.c:4:
util.go: In function ‘customLogCb’:
util.go:30:65: warning: passing argument 3 of ‘customLogCallback’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
util.go:26:62: note: expected ‘char *’ but argument is of type ‘const char *’
# github.com/Azure/sonic-mgmt-common/cvl/internal/util
../cvl/internal/util/util.go: In function ‘customLogCb’:
../cvl/internal/util/util.go:30:72: warning: passing argument 3 of ‘customLogCallback’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   30 |         customLogCallback(level, (char*)msg, (char*)data_path?data_path:schema_path);
      |                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
../cvl/internal/util/util.go:26:62: note: expected ‘char *’ but argument is of type ‘const char *’
   26 | extern void customLogCallback(LY_LOG_LEVEL, char* msg, char* path);
      |                                                        ~~~~~~^~~~

These warnings are from the original code and not something newly introduced. Its due to the Golang<->C (cgo) stuff, where Go doesn't know about the const qualifier in C. If you really want me to address it I can probably look into it, here's a reference to the issue:
https://stackoverflow.com/questions/32938558/cgo-cant-find-way-to-use-callbacks-with-const-char-argument

@bradh352
Copy link
Author

bradh352 commented Mar 6, 2025

@sachinholla any other comments on this review? If not, could you approve it?

@faraazbrcm
Copy link
Contributor

faraazbrcm commented Mar 6, 2025

@bradh352 Code changes look good to me.
I wanted to ensure SET/GET going fine using gNMI and RESTCONF interfaces. I will run some some tests next week and update you.

@bradh352
Copy link
Author

bradh352 commented Mar 6, 2025

let me know if you need an image to test and for what platform. I've got a tree with all 17 PRs in this series that I test with here: https://github.com/bradh352/sonic-buildimage/commits/bradh352/libyang3/

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.

5 participants