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

rpk: improve handling of incomplete config import #4910

Closed
wants to merge 1 commit into from

Conversation

jcsp
Copy link
Contributor

@jcsp jcsp commented May 24, 2022

Cover letter

Previously this would compare all the existing configuration
values against the new ones, including if the new one was
nil (reset to default), and the old one was the default.

That meant that an import of a minimal file would generate
a huge list of changes, and also a bunch of redundant 'remove'
entries in the API request. Functional, but messy.

Fix this by only comparing with non-default existing properties
when doing an import. The 'edit' path still compares with all
properties.

Fixes #4877

Release notes

Improvements

  • Output from rpk cluster config import is made more succinct if the input file leaves out properties and those properties are already set to the default.

@jcsp jcsp force-pushed the issue-4877 branch 2 times, most recently from dcf1bc4 to bc82251 Compare May 25, 2022 11:33
Previously this would compare all the existing configuration
values against the new ones, including if the new one was
nil (reset to default), and the old one was the default.

That meant that an import of a minimal file would generate
a huge list of changes, and also a bunch of redundant 'remove'
entries in the API request.  Functional, but messy.

Fix this by only comparing with non-default existing properties
when doing an import.  The 'edit' path still compares with all
properties.

Fixes redpanda-data#4877
@jcsp jcsp marked this pull request as ready for review May 25, 2022 21:03
@jcsp jcsp requested review from dotnwat, NyaliaLui, twmb, 0x5d, r-vasquez and a team as code owners May 25, 2022 21:03
Copy link
Member

@nicolaferraro nicolaferraro left a comment

Choose a reason for hiding this comment

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

LGTM 😄

Copy link
Contributor

@twmb twmb left a comment

Choose a reason for hiding this comment

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

I'm a bit confused here -- the PR description refers to redundant remove entries, but the code changes in import primarily affect the upsert path. The remove path continues to read through all old config values, but now the oldValue is coming from non-defaults? And the non-default could not exist because the key wouldn't be changed yet, but we're still removing the key?

@@ -171,7 +171,7 @@ func (*unavailableError) Error() string {
return "unavailable"
}

func (m *mockAdminAPI) Config() (admin.Config, error) {
func (m *mockAdminAPI) Config(_ bool) (admin.Config, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: this can be (bool). Only worth addressing if there are other comments.

@@ -23,9 +23,12 @@ type Config map[string]interface{}

// Config returns a single admin endpoint's configuration. This errors if
// multiple URLs are configured.
func (a *AdminAPI) Config() (Config, error) {
// If include_defaults is true, all properties are returned, including those
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: include_defaults => includeDefaults, also an empty comment line just above this (//) so that it's not a partial comment line into a full comment line

}
}

for k := range oldConfig {
for k := range oldConfigFull {
Copy link
Contributor

Choose a reason for hiding this comment

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

Line 146 uses oldConfig still, which I think given this PR, could not exist if it is a default value?

@mmedenjak mmedenjak added the kind/enhance New feature or request label Aug 24, 2022
@jcsp
Copy link
Contributor Author

jcsp commented Aug 24, 2022

Sorry, this was meant to be a quickie but I didn't have time to follow up + it got stale, I'm going to close it + let #4877 get re-prioritized for an rpk specialized to work on.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants