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 profile: more #11296

Merged
merged 21 commits into from
Jun 11, 2023
Merged

rpk profile: more #11296

merged 21 commits into from
Jun 11, 2023

Conversation

twmb
Copy link
Contributor

@twmb twmb commented Jun 8, 2023

This PRs adds some missing features of rpk profile:

  • Adds rpk profile clear: let the user clear the current profile. (Useful to under prod cluster profiles)
  • Enable creating a profile from another file that contains a profile (rpk profile create --from-profile)
  • Adds rpk profile prompt command: It let's user configure a custom bash prompt via rpk for a specific profile.
  • Adds a new flag --stable to rpk topic describe to only print the stable column if the flag is used.
  • Fix: allow rpk to be used without setting $HOME
  • Revert the -v change to default to DEBUG level instead of INFO.
  • Hide non -X flags by default.
    • This means users won't see the help text for any of the non -X flags (brokers, api-urls, admin-api-tls, etc...)
  • Adds Defaults to rpk.yaml: Global configuration knobs to be used across different profiles.
    • Adds new rpk profile {edit,print,set}-default to modify these configs properties.
  • Adds a new flag: --profile that let users pick profiles while running a single rpk command.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.1.x
  • v22.3.x
  • v22.2.x

Release Notes

  • none

@r-vasquez
Copy link
Contributor

Force-push change: ducktape test modification for the --from-simple -> --from-redpanda

@r-vasquez r-vasquez force-pushed the rpk-profile-more branch 2 times, most recently from 04cd087 to 2759ae4 Compare June 8, 2023 22:31
r-vasquez
r-vasquez previously approved these changes Jun 8, 2023
Copy link
Contributor

@r-vasquez r-vasquez left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +1060 to 1081
func (c *Config) ensureBrokerAddrs() {
{
dst := &c.redpandaYaml
if len(dst.Rpk.KafkaAPI.Brokers) == 0 {
dst.Rpk.KafkaAPI.Brokers = []string{net.JoinHostPort("127.0.0.1", strconv.Itoa(DefaultKafkaPort))}
}
if len(dst.Rpk.AdminAPI.Addresses) == 0 {
dst.Rpk.AdminAPI.Addresses = []string{net.JoinHostPort("127.0.0.1", strconv.Itoa(DefaultAdminPort))}
}
}
{
dst := c.rpkYaml.Profile(c.rpkYaml.CurrentProfile) // must exist by this function
if len(dst.KafkaAPI.Brokers) == 0 {
dst.KafkaAPI.Brokers = []string{net.JoinHostPort("127.0.0.1", strconv.Itoa(DefaultKafkaPort))}
}
if len(dst.AdminAPI.Addresses) == 0 {
dst.AdminAPI.Addresses = []string{net.JoinHostPort("127.0.0.1", strconv.Itoa(DefaultAdminPort))}
}
}
}

// We merge redpanda.yaml's rpk section back into rpk.yaml's profile. This
Copy link
Contributor

Choose a reason for hiding this comment

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

does this do what i think it does? i dont have to add the broker address at the end of brokers anymore? because if so... 🥂

gene-redpanda
gene-redpanda previously approved these changes Jun 9, 2023
Copy link
Contributor

@gene-redpanda gene-redpanda 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 overall, I like the idea of clarifying and improving the experience of profiles.

twmb added 14 commits June 9, 2023 15:41
Exits without additional formatting, if the input string is already
formatted.
This might belong in rpk profile prompt; it's a bit niche.
* clear unsets any current profile
* current prints the current profile name
This allows cloning profiles or easily transferring a profile between
laptops.
This allows putting `$(rpk profile prompt)` in your PS1
This finally allows for modifying settings of rpk itself. This will be
wired through in a future commit.
…stable

The stable column is different from the HWM in two cases:
1, and far more common: Records were produced between the HWM and LSO.
2, less common: Transactions are being used.

We always requested the stable offset after HWM, so frequently, the
stable offset would look higher than the HWM (which is wrong!), and it
would actually be equal behind the scenes but only look different due to
time. Hiding it by default is less confusing, and requesting the stable
offsets second rather than third prevents stable appearing higher.
If $HOME is unset, we will not load nor write an rpk.yaml. Trying to
write will fail, but loading will just use defaults or just use values
from redpanda.yaml or env or flags.
-v=info by default was confusing and as it turns out, when you want
logs, you almost always want debug logs (for now). We can switch back
later if need be.
twmb and others added 7 commits June 9, 2023 15:41
* We always want to show all defaults -- showing everything makes it
  easier for the user to know what is possible for modify
* We always want to show the profile name since it is always useful
This will let user pick an specific profile while
running any command. Useful when you want to run
the same across multiple profiles.
@twmb
Copy link
Contributor Author

twmb commented Jun 11, 2023

Failures are #11182 and #8217 and #11044

@twmb twmb merged commit 46592a2 into redpanda-data:dev Jun 11, 2023
@twmb twmb deleted the rpk-profile-more branch June 11, 2023 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants