Skip to content

Allow more control over gnmi set request marshalling#157

Merged
dplore merged 3 commits intoopenconfig:mainfrom
felix-kaestner:main
Sep 24, 2025
Merged

Allow more control over gnmi set request marshalling#157
dplore merged 3 commits intoopenconfig:mainfrom
felix-kaestner:main

Conversation

@felix-kaestner
Copy link
Copy Markdown
Contributor

This patch extends the current behavior to populate the gnmi set request in order to allow more control over the request payload.

  1. A new WithAppendModuleName option is added that allows to toggle the procedure of adding the YANG module name to the respective fields, which is redundant for systems that will automatically infer the module name via other means.
  2. The WithEncoding option is respected when set to json encoding. Previously the typed value was marshalled by default as json_ietf, while certain platform such as Cisco NX-OS only support json enconding and therefore expect all request to be encoded as such. With this option, it's now possible to encode request to json if desired.

All changes mentioned above do not alter the current behavior. They simply allow for more flexibility when used explicitly by providing the respective options.

@google-cla
Copy link
Copy Markdown

google-cla bot commented Jul 6, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

This patch extends the current behavior to populate the gnmi set request
in order to allow more control over the request payload.

1. A new `WithAppendModuleName` option is added that allows to toggle
   the procedure of adding the YANG module name to the respective
   fields, which is redundant for systems that will automatically infer
   the module name via other means.
2. The `WithEncoding` option is respected when set to json encoding.
   Previously the typed value was marshalled by default as json_ietf,
   while certain platform such as Cisco NX-OS only support json
   enconding and therefore expect all request to be encoded as such.
   With this option, it's now possible to encode request to json if
   desired.

All changes mentioned above do not alter the current behavior. They
simply allow for more flexibility when used explicitly by providing
the respective options.
@coveralls
Copy link
Copy Markdown

coveralls commented Jul 9, 2025

Pull Request Test Coverage Report for Build 17956202556

Details

  • 16 of 18 (88.89%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 5.235%

Changes Missing Coverage Covered Lines Changed/Added Lines %
ygnmi/gnmi.go 10 12 83.33%
Totals Coverage Status
Change from base Build 17854504668: 0.03%
Covered Lines: 2313
Relevant Lines: 44184

💛 - Coveralls

Copy link
Copy Markdown
Member

@robshakir robshakir left a comment

Choose a reason for hiding this comment

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

Thanks for the change. Generally, LGTM -- added a couple of comments.

Can we add a test to validate these two new options in this package please?

@felix-kaestner
Copy link
Copy Markdown
Contributor Author

Can we add a test to validate these two new options in this package please?

Added some in 68dcb70. :)

@felix-kaestner
Copy link
Copy Markdown
Contributor Author

@robshakir I addressed your feedback, would you be able to have another look at this?

Copy link
Copy Markdown
Member

@robshakir robshakir left a comment

Choose a reason for hiding this comment

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

thanks for the changes, apologies for the delay re-reviewing.

@robshakir
Copy link
Copy Markdown
Member

/gcbrun

@eoswald
Copy link
Copy Markdown

eoswald commented Sep 3, 2025

Hey @felix-kaestner , thanks for doing this! My only nit is WithAppendModuleName sort of implies that the default behavior is to not append/prepend the module name (even if it does require a bool arg). Before I saw your PR I took a crack at it and decided to go for WithoutAppendModuleName() (no arg) while keeping the default to be true so it wouldn't be a breaking change. Anyways, no strong opinions. Just happy to see this option become available soon!

@felix-kaestner
Copy link
Copy Markdown
Contributor Author

Hey @felix-kaestner , thanks for doing this! My only nit is WithAppendModuleName sort of implies that the default behavior is to not append/prepend the module name (even if it does require a bool arg). Before I saw your PR I took a crack at it and decided to go for WithoutAppendModuleName() (no arg) while keeping the default to be true so it wouldn't be a breaking change. Anyways, no strong opinions. Just happy to see this option become available soon!

@eoswald Valid point.

@robshakir what are your feelings?

@eoswald
Copy link
Copy Markdown

eoswald commented Sep 12, 2025

@robshakir Can we get another /gcbrun on this? I think it's stuck. Also any strong feelings on the discussion?

@dplore
Copy link
Copy Markdown
Member

dplore commented Sep 12, 2025

/gcbrun

@dplore dplore closed this Sep 12, 2025
@dplore dplore reopened this Sep 12, 2025
@dplore
Copy link
Copy Markdown
Member

dplore commented Sep 12, 2025

I'm not sure why the checks are stuck. @bstoll for any insight?

@dplore dplore self-assigned this Sep 16, 2025
@dplore dplore moved this to last-call in OC Operator Review Sep 16, 2025
@dplore
Copy link
Copy Markdown
Member

dplore commented Sep 16, 2025

I'll merge this today after all checks pass

@eoswald
Copy link
Copy Markdown

eoswald commented Sep 16, 2025

@dplore @robshakir I created this PR to Felix's fork to generate the new test files and make the code generation work from macOS. I also added some documentation. Let me know what you think: felix-kaestner#1

@robshakir
Copy link
Copy Markdown
Member

@dplore Please do not merge this directly. I would like to review the code.

@dplore
Copy link
Copy Markdown
Member

dplore commented Sep 17, 2025

@dplore Please do not merge this directly. I would like to review the code.

Got it. I saw your earlier approval #157 (review) so I thought your review was complete.

@robshakir
Copy link
Copy Markdown
Member

@dplore Please do not merge this directly. I would like to review the code.

Got it. I saw your earlier approval #157 (review) so I thought your review was complete.

ACK, thanks -- the question above about backwards compatibility was what I wanted to respond to -- I missed it in my original review :-) Thanks.

@robshakir
Copy link
Copy Markdown
Member

Hey @felix-kaestner , thanks for doing this! My only nit is WithAppendModuleName sort of implies that the default behavior is to not append/prepend the module name (even if it does require a bool arg). Before I saw your PR I took a crack at it and decided to go for WithoutAppendModuleName() (no arg) while keeping the default to be true so it wouldn't be a breaking change. Anyways, no strong opinions. Just happy to see this option become available soon!

@eoswald Valid point.

@robshakir what are your feelings?

I'd like to keep backwards compatibility, I'd missed that this would result in a change (and it seems like the tests didn't catch this either).

It looks like the docstring is a bit inconsistent here (WithAppendModuleName being unspecified = it is appended, which sounds counter to what the argument is -- maybe this should be SkipModuleNames or something similar given the logic will be reversed?).

@felix-kaestner Are you OK to make this change please?

@dplore
Copy link
Copy Markdown
Member

dplore commented Sep 23, 2025

@felix-kaestner please let us know if you can make the changes @robshakir has suggested. If not, perhaps @eoswald could take it up?

@felix-kaestner
Copy link
Copy Markdown
Contributor Author

@felix-kaestner please let us know if you can make the changes @robshakir has suggested. If not, perhaps @eoswald could take it up?

Hey @dplore, sorry for the delayed response, I was quite busy the last couple of days. I just updated the PR with the suggested changes, renaming WithAppendModuleName to WithSkipModuleNames and clarifying that this is a opt-out of the default behavior. :)

I'd like to keep backwards compatibility, I'd missed that this would result in a change (and it seems like the tests didn't catch this either).

@robshakir The changes do not alter the default behavior, thus keeping backwards compatibility. It's just an additional option the allows to opt-out of prepending the YANG module name to fields.

Copy link
Copy Markdown
Member

@robshakir robshakir left a comment

Choose a reason for hiding this comment

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

Thank you for the changes and clarifications - much appreciated. Merging this code. Thanks very much for the contribution!

@dplore dplore merged commit 646562b into openconfig:main Sep 24, 2025
7 checks passed
felix-kaestner added a commit to ironcore-dev/network-operator that referenced this pull request Sep 25, 2025
As openconfig/ygnmi#157 got merged, we no longer
have use our fork for making adjustments to the marshalling performed by
ygnmi but can now use the latest upstream version instead.
felix-kaestner added a commit to ironcore-dev/network-operator that referenced this pull request Sep 25, 2025
As openconfig/ygnmi#157 got merged, we no longer
have use our fork for making adjustments to the marshalling performed by
ygnmi but can now use the latest upstream version instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants