Skip to content

Commit

Permalink
rpk: add nil check for maintenance mode
Browse files Browse the repository at this point in the history
To avoid a segfault, we must check if
b.Maintenance is not nil because a user might try
to decommission a node with an older version that
doesn't have the maintenance mode feature (<v22).
  • Loading branch information
r-vasquez committed Nov 25, 2022
1 parent 42ba14a commit 20cb9e8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/go/rpk/pkg/cli/cmd/redpanda/admin/brokers/brokers.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ leader handles the request.
b, err := cl.Broker(cmd.Context(), broker)
out.MaybeDie(err, "unable to initialize admin client: %v", err)

if b.Maintenance.Draining {
// Old brokers (< v22.1) don't have maintenance mode, so we must
// check if b.Maintenance is not nil.
if b.Maintenance != nil && b.Maintenance.Draining {
out.Die(`Node cannot be decommissioned while it is in maintenance mode.
Take the node out of maintenance mode first by running:
rpk cluster maintenance disable %v`, broker)
Expand Down

0 comments on commit 20cb9e8

Please sign in to comment.