-
Notifications
You must be signed in to change notification settings - Fork 563
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
rpk: sample config to include empty structs #5503
Conversation
@@ -45,10 +45,10 @@ redpanda: | |||
developer_mode: true | |||
|
|||
# Enable Pandaproxy | |||
pandaproxy: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the {}
are now required, does that mean that we still have a backwards compatibility issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat.
Old versions are already converted to using {}
through old rpk. The only problem will be if somebody uses an old redpanda.yaml that has never been touched by rpk, with the new rpk.
src/go/rpk/pkg/config/params_test.go
Outdated
name: "read/write sample redpanda.yaml", | ||
inCfg: `organization: "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we actually change this to a specific dedicated test case that loads the conf/redpanda.yaml
? That will ensure we catch drift if the default redpanda.yaml changes -- modifying that file will require fixing this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to read from redpanda/conf/redpanda.yaml
Sample config file had empty properties: pandaproxy and schema_registry; rpk strips them out due to the omitempty struct tag. In the past viper assumed the presence of a property was enough to include it in the file, that didn't respect the omitempty tag.
36fea34
to
7551561
Compare
Awesome, ty! |
It was my impression that an empty tag is valid yaml. The I wonder if the change in behaviour now requires changes to other examples and documentation? |
Per the yaml spec, https://yaml.org/spec/1.2-old/spec.html#id2805071 a blank tag is The main thing we're trying to address is to not add configuration when invoking rpk commands that change the redpanda.yaml file. Previously, if you set a random field, then the pandaproxy and schema_registry would always be added even if you explicitly disabled them previously (by removing the fields entirely). We fixed that, which then showed our default sample configuration was incorrect. This was never noticed because of the old behavior that always added the defaults back. This new PR ensures the defaults are correct. |
That was the intended behaviour, that is the current behaviour. Everything has a useful default. We can argue whether it was implemented incorrectly. I'm just pointing out the change in behaviour, and that it might require changes elsewhere. |
That sounds as if redpanda has a custom yaml decoder that is hooking into the decoding process. How can a program know if Using, type Foo struct {
Field *string
} how can a program know after deserialiation whether Requiring We can look into whether docs needs an update as a part of this. |
All pages mentioning https://docs.redpanda.com/docs/reference/node-configuration-sample/ <- has full specification of pandaproxy All pages referencing https://docs.redpanda.com/docs/21.11/deployment/kubernetes-additional-config/ <- has additional configuration knob |
Cover letter
Sample config file had empty properties:
pandaproxy
andschema_registry
; rpk strips themout due to the omitempty struct tag.
In the past viper assumed the presence of a
property was enough to include it in the file,
that didn't respect the omitempty tag.
Fixes #5494
Release notes
pandaproxy
andschema_registry
, and rpk had a bug that always added those sections by default. rpk will no longer add those sections no matter what, but the yaml file also now includes the sections properly by default. Using a new rpk on an old default yaml will no longer add the missingpandaproxy
andschema_registry
sections.