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

hive: add support for map[string]string flags #25643

Merged
merged 3 commits into from May 31, 2023

Conversation

giorio94
Copy link
Member

Reporting the description of the main commit for convenience:

Introduce a decoding hook to convert from a string to the corresponding
map[string]string representation when the target configuration entry is
of the corresponding type. It reuses the same logic already adopted
today outside of hive, assuming initially that the string is json
encoded, and falling back to the KV format in case of errors. This
allows to have a config struct contain map[string]string options,
registering the corresponding flag through flags.StringToString.
hive: add support for map[string]string flags

@giorio94 giorio94 added release-note/misc This PR makes changes that have no direct user impact. sig/agent Cilium agent related. area/modularization labels May 24, 2023
@giorio94 giorio94 requested review from a team as code owners May 24, 2023 11:25
@giorio94 giorio94 requested a review from mhofstetter May 24, 2023 11:25
@giorio94
Copy link
Member Author

/test

Copy link
Member

@mhofstetter mhofstetter left a comment

Choose a reason for hiding this comment

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

thanks! just left some small optimizations inline.

due to an upcoming change in the ownership of the hive packages i propose an additional pair of eyes from sig-foundations / @joamaki (#24976)

pkg/command/map_string.go Outdated Show resolved Hide resolved
pkg/command/map_string.go Show resolved Hide resolved
pkg/hive/cell/config.go Outdated Show resolved Hide resolved
@mhofstetter mhofstetter requested a review from joamaki May 24, 2023 12:59
Copy link
Contributor

@joamaki joamaki left a comment

Choose a reason for hiding this comment

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

Looks good, nothing to add on top of @mhofstetter's comments.

Copy link
Member

@mhofstetter mhofstetter left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for the changes!

@giorio94 giorio94 requested a review from a team as a code owner May 25, 2023 07:36
@giorio94
Copy link
Member Author

Upon further testing, I noticed that I mistakenly used viper.Set rather than flags.Set in the newly introduced test. The latter is the one actually executed when setting a flag through the CLI, and it does not support decoding maps from JSON format. I've updated the tests and the documentation accordingly. @mhofstetter PTAL

@giorio94 giorio94 requested a review from mhofstetter May 25, 2023 07:39
@giorio94
Copy link
Member Author

/test

@giorio94
Copy link
Member Author

ConformanceKind and ConformanceIngress seem to have failed due to #25664. Manually rerunning.

Copy link
Member

@bimmlerd bimmlerd left a comment

Choose a reason for hiding this comment

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

LGTM - just out of curiosity, what do we need this for?

@giorio94
Copy link
Member Author

LGTM - just out of curiosity, what do we need this for?

It will be initially used to register the kvstore-opt flag in #25554. I've extracted these commits in a separated PR since they have a more general scope.

Copy link
Contributor

@zacharysarah zacharysarah left a comment

Choose a reason for hiding this comment

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

@giorio94 Good work! ✨ One nit, otherwise LGTM. Approving with the understanding that changes are required prior to merge.

Documentation/contributing/development/hive.rst Outdated Show resolved Hide resolved
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label May 31, 2023
@giorio94 giorio94 removed the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label May 31, 2023
@giorio94
Copy link
Member Author

/test

This commit adapts the logic which logs the registered flags to
correctly output the value of flags of type StringMap. It was
previously not working since vp.GetStringSlice returned an empty
slice for such type of flags.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Introduce a decoding hook to convert from a string to the corresponding
map[string]string representation when the target configuration entry is
of the corresponding type. It reuses the same logic already adopted
today outside of hive, assuming initially that the string is json
encoded, and falling back to the KV format in case of errors. This
allows to have a config struct contain map[string]string options,
registering the corresponding flag through flags.StringToString.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Extend the "Guide to the Hive" documentation page, and in particular the
Config section with an example concerning the registration of flags
representing complex types (that is slices and maps), along with a
comment explaining how parsing is performed.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
@giorio94
Copy link
Member Author

Rebased onto main to pick the last changes and allow the Cilium Runtime checks to run successfully.

@giorio94
Copy link
Member Author

giorio94 commented May 31, 2023

/test

Job 'Cilium-PR-K8s-1.25-kernel-4.19' failed:

Click to show.

Test Name

K8sDatapathServicesTest Checks E/W loadbalancing (ClusterIP, NodePort from inside cluster, etc) Tests NodePort inside cluster (kube-proxy) with IPSec and externalTrafficPolicy=Local

Failure Output

FAIL: Request from k8s1 to service tftp://[fd04::12]:30311/hello failed

Jenkins URL: https://jenkins.cilium.io/job/Cilium-PR-K8s-1.25-kernel-4.19/267/

If it is a flake and a GitHub issue doesn't already exist to track it, comment /mlh new-flake Cilium-PR-K8s-1.25-kernel-4.19 so I can create one.

Then please upload the Jenkins artifacts to that issue.

@giorio94
Copy link
Member Author

giorio94 commented May 31, 2023

/mlh new-flake Cilium-PR-K8s-1.25-kernel-4.19

👍 created #25785

@giorio94
Copy link
Member Author

/test-1.25-4.19

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label May 31, 2023
@julianwiedmann julianwiedmann merged commit d137d83 into cilium:main May 31, 2023
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/modularization ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact. sig/agent Cilium agent related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants