-
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
Remove viper and mapstructure from rpk #5061
Conversation
20db5bc
to
1a9585a
Compare
df1034e
to
a732ee6
Compare
88afb49
to
42ea445
Compare
352163f
to
3cf5944
Compare
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.
Some preliminary comments and questions!
p := props[len(props)-1] | ||
in = fmt.Sprintf("%s: %s", p, value) | ||
} | ||
err = yaml.Unmarshal([]byte(in), i) |
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.
Why doesn't this properly call weak unmarshaling for socket addresses, etc? I think you brought up that setting redpanda.seed_servers is different than setting redpanda
with a value containing seed servers?
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.
It doesn't call weak unmarshaling for any of the one_or_many
weak types, since we created other intermediary types for them:
[]NamedSocketAddress -> NamedSocketAddresses
[]SeedServer -> SeedServers
...
We use the intermediary types in the general config.Config type, not in every field, e.g : https://github.com/redpanda-data/redpanda/blob/dev/src/go/rpk/pkg/config/weak.go#L316L335
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.
I have an idea for how to solve this for the yaml case, but not the json. In the yaml case, when we return, we could have a huge type switch:
case []string => return weakStrings(xyz)
case []NamedSocketAddress => return namedSocketAddresses(xyz)
this only works for yaml because weak decoding is only implemented for yaml
this theoretically could be supported for json in a followup PR if we want,
but I think this should be tracked as a separate issue: allow setting slices with one element in set
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.
Created: #5264
09fd5b4
to
5c61fb4
Compare
8edf532
to
aefda59
Compare
This commit removes viper and mapstructure These are all the required changes to handle the parsing, weak typing and writes to config file. From now on we will print warning to users so they know what needs to be changed in the config file before we deprecate this weak typing. This also include Yaml V3 upgrade, one notable change is the indent in yaml files.
aefda59
to
ed60e65
Compare
Failure in: https://buildkite.com/redpanda/redpanda/builds/11813#0181ad2c-892a-4d2e-a49e-3e5a71f4cc95 Possibly related to: #2406, checking if the same issue or if I should create a new one. |
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.
Awesome
@r-vasquez awesome work! |
In the viper removal PR (redpanda-data#5061) we introduced a bug: rpk redpanda start will load the file and update some unset defaults such as rpk.kafka_api. This breaks backward compatibility for some users so we are correcting it in this commit.
In the viper removal PR (redpanda-data#5061) we introduced a bug: rpk redpanda start will load the file and update some unset defaults such as rpk.kafka_api. This breaks backward compatibility for some users so we are correcting it in this commit.
In the viper removal PR (redpanda-data#5061) we introduced a bug: rpk redpanda start will load the file and update some unset defaults such as rpk.kafka_api. This breaks backward compatibility for some users so we are correcting it in this commit.
Cover letter
This PR removes the dependency of viper and mapstructure for our config file handling. Now we have control over Write and Read operations in our config file.
We introduced in #4894 the Weak Types, which allow us to handle weakly typed parameters.
It also includes the upgrade from Yaml.v2 to Yaml.v3, one of the key major changes in this library is the indentation of 4 instead of 2. So our config files will look different (but valid although)
Fixes #4531, Fixes #4176, Fixes #5202
Also, now rpk prevents the user to change ownership of config files, so with this it:
Fixes #4046, Fixes #3064, Fixes #1919
What is changing
Config File:
Now you will be able to detect if your configuration file contains some weak types that were allowed before but now we want to enforce strict typing. e.g:
will be parsed as a YAML list
As you can see above, the indent is now with 4 spaces instead of 2, this is enforced in the new yaml.v3 package and still valid.
Old code will write redpanda.seed_servers.node_id, this property is no longer needed/supported. We are stripping it out from the config, so:
Will become:
Behavior changes/notes:
When running
params.Load()
method we are doing some backward compatibility changes, one of them is to copyrpk.tls
torpk.kafka_api.tls
andrpk.amin_api.tls
. This is already in place and working for some commands, with this PR will work for ALL commands that load the config file.The old manager created a directory when flag
--config
was passed, we will keep this behavior for now.Also removed an undocumented and unused way of changing config parameters in camelCase using
--format json
in rpk config set.Ducktape Tests:
redpanda.seed_servers
(see above)K8S Configurator:
RPK Go Code:
Release notes