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: print license expiration warning #5491

Merged
merged 1 commit into from
Jul 22, 2022

Conversation

r-vasquez
Copy link
Contributor

@r-vasquez r-vasquez commented Jul 15, 2022

Cover letter

Adding an alert in rpk for:

  • License is about to expire when expires < 30 for --format text (default)

Adding an additional field to license info when the license is expired:

  • license_expired for json format, License Expired for text.
rpk cluster license info --api-urls '0.0.0.0:9645' 
LICENSE INFORMATION
===================
Organization:      redpanda-testing
Type:              enterprise
Expires:           36479 days
Version:           0
License Expired:   true
rpk cluster license info --api-urls '0.0.0.0:9645' --format json
{
  "format_version": 0,
  "org": "redpanda-testing",
  "type": "enterprise",
  "expires": 36479,
  "license_expired": true
}

Release notes

  • none

@r-vasquez r-vasquez marked this pull request as ready for review July 15, 2022 22:41
@r-vasquez r-vasquez requested review from twmb and 0x5d as code owners July 15, 2022 22:41
@mmedenjak mmedenjak added the kind/enhance New feature or request label Jul 18, 2022
Comment on lines +73 to +79
if p.Expires < 30 && p.Expires >= 0 {
fmt.Fprintln(os.Stderr, "warning: your license will expire soon")
return
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a bit odd to have these conditionals so far away from each other (one check for < 0 above, another check here). I think these should both be in one place above, or both be here (and don't emit any warning on expired for json, instead exit 1)

Copy link
Contributor Author

@r-vasquez r-vasquez Jul 21, 2022

Choose a reason for hiding this comment

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

I did it this way because I wanted to print a warning for "license expiring soon" only in --format plain. With your feedback I'll move this to:

1. If --format json exit 1 if the license is expired and NO warning text.
2. if --format plain exit 1 if the license is expired and print warning.
2a. if --format plain exit 0 and print a warning for "license expiring soon"
check update below

Sending alert in plain format when the license is
about to expire and adding field when license is
expired.
@r-vasquez
Copy link
Contributor Author

Update:

  • Now adding a field "license_expired" for --format json when the license is expired.
  • Adding field License Expired for --format plain when the license is expired.
  • Removed warning in json format

@r-vasquez r-vasquez requested a review from twmb July 21, 2022 17:58
@r-vasquez
Copy link
Contributor Author

Debug-clang-amd64 ducktape failure: #4772

@twmb twmb merged commit 78365c8 into redpanda-data:dev Jul 22, 2022
@r-vasquez r-vasquez deleted the license-expire-warning branch July 22, 2022 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rpk kind/enhance New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants