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

Load Yang model default value to DefaultValueProvider #682

Merged
merged 14 commits into from
Sep 23, 2022

Conversation

liuh-80
Copy link
Contributor

@liuh-80 liuh-80 commented Sep 9, 2022

Why I did it

Support sonic-swss-common read Yang model defaut value.

How I did it

Load Yang model default value to DefaultValueProvider.

How to verify it

Add new UT to cover DefaultValueProvider code.
Pass all UT.

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Load Yang model default value to DefaultValueProvider.

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@@ -20,6 +20,10 @@ parameters:
- name: sonic_slave
type: string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All azure pipeline change is from another PR: #681
That PR need merge first.

@liuh-80
Copy link
Contributor Author

liuh-80 commented Sep 9, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liuh-80
Copy link
Contributor Author

liuh-80 commented Sep 9, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liuh-80 liuh-80 marked this pull request as ready for review September 9, 2022 09:45
@liuh-80 liuh-80 requested a review from qiluo-msft September 9, 2022 09:45
@qiluo-msft
Copy link
Contributor

qiluo-msft commented Sep 10, 2022

#include

You removed the whole content and changed file attribute. Is it intended?


In reply to: 1242820539


In reply to: 1242820539


Refers to: common/dbconnector.cpp:7 in 00935a3. [](commit_id = 00935a3, deletion_comment = True)

~DefaultValueProvider();

// libyang context
struct ly_ctx *m_context = nullptr;
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 11, 2022

Choose a reason for hiding this comment

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

m_context

You are assuming there is only one ly_ctx. Is it always true? Can we relax? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's true, there will only one ly_ctx, it's created by our code and this is a singleton.
Libyang only need 1 context, there is no scenario that we need multiple context.

Copy link
Contributor

Choose a reason for hiding this comment

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

Today the answer is yes. I am think relax the limitation may be future proof.

In future, ApplDB may have separate yang models, structure events may also has separate yang models. And these yang models are independent with each other. So I guess there will be use case that clients may use multiple ly_ctx..

The lazy initialization is still useful since the client of swsscommon may not use yang features at all.

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, now defaultvalue provider is not a singleton, so we can use multiple default value provider to load default value for different DB.

#include "table.h"
#include "json.h"

#if defined(__arm__) || defined(__aarch64__)
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 11, 2022

Choose a reason for hiding this comment

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

aarch64

SONiC will be built on arm platforms. Is it safe to ignore the warning (as error)? #WontFix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

New UT cover the warning code and passed, so I think it's safe.
Also I check this issue online and found there some discussion suggest ignore this warning is safe.

@liuh-80
Copy link
Contributor Author

liuh-80 commented Sep 13, 2022

#include

You removed the whole content and changed file attribute. Is it intended?

Refers to: common/dbconnector.cpp:7 in 00935a3. [](commit_id = 00935a3, deletion_comment = True)

Fixed, this PR not change any content in dbconnector.cpp, I only fix the incorrect file mode issue. seems a github bug.

#if defined(__arm__) || defined(__aarch64__)
#define WARNINGS_NO_CAST_ALIGN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wcast-align\"")
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 13, 2022

Choose a reason for hiding this comment

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

 [](http://example.com/codeflow?start=0&length=5)

Indent 4 spaces? 5 is weird. #Closed

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

@qiluo-msft
Copy link
Contributor

#include

I see non-critical comment change and still file attribute change. If it is intended change, suggest move to a standalone PR. This PR is complex and should be focused.


In reply to: 1242820539


Refers to: common/dbconnector.cpp:7 in 00935a3. [](commit_id = 00935a3, deletion_comment = True)

@liuh-80
Copy link
Contributor Author

liuh-80 commented Sep 14, 2022

#include

I see non-critical comment change and still file attribute change. If it is intended change, suggest move to a standalone PR. This PR is complex and should be focused.

In reply to: 1242820539

Refers to: common/dbconnector.cpp:7 in 00935a3. [](commit_id = 00935a3, deletion_comment = True)

Fixed, reverted change in this file.

@liuh-80
Copy link
Contributor Author

liuh-80 commented Sep 14, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liuh-80
Copy link
Contributor Author

liuh-80 commented Sep 15, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liuh-80
Copy link
Contributor Author

liuh-80 commented Sep 15, 2022

Currently, there still 10 repos need update their azure pipeline to install libyang. 10 PRs already created.
This PR need wait for those PRs finish first.

@liuh-80 liuh-80 merged commit 0657723 into sonic-net:master Sep 23, 2022
@liuh-80 liuh-80 deleted the dev/liuh/yang-provider branch September 23, 2022 05:58
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