forked from redpanda-data/redpanda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rpk: supports triggering on-demand balancer
- Loading branch information
Showing
4 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright 2024 Redpanda Data, Inc. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.md | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0 | ||
|
||
package partitions | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/adminapi" | ||
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/config" | ||
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/out" | ||
"github.com/spf13/afero" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func newTriggerBalnacerCommand(fs afero.Fs, p *config.Params) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "balance", | ||
Short: "Triggers on-demand partition balancer", | ||
Long: `Triggers on-demand partition balancer. | ||
This command allows you to trigger on-demand partition balancer. | ||
With Redpanda Community Edition, partition count on each broker | ||
easily becomes uneven, which leads to data skew. In order to | ||
distribute partitions across brokers, user can run this command | ||
to trigger on-demand partition balancer. | ||
With Redpanda Enterprise Edition, even though Continuous Data Balancing | ||
monitors broker and rack availability, as well as disk usage, to avoid | ||
topic hotspots, there're still some edge cases where it can't handle well, | ||
i.e. a node becoming unavailable for a prolonged time and joining the | ||
cluster back thereafter. In such cases, user needs to run this command | ||
to trigger partition balancer manually. | ||
After you run this command, monitor the balancer progress using: | ||
rpk cluster partitions balancer-status | ||
To see more detailed movement status, monitor the progress using: | ||
rpk cluster partitions move-status | ||
`, | ||
|
||
Args: cobra.ExactArgs(0), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
f := p.Formatter | ||
if h, ok := f.Help([]string{}); ok { | ||
out.Exit(h) | ||
} | ||
|
||
p, err := p.LoadVirtualProfile(fs) | ||
out.MaybeDie(err, "rpk unable to load config: %v", err) | ||
config.CheckExitCloudAdmin(p) | ||
|
||
cl, err := adminapi.NewClient(fs, p) | ||
out.MaybeDie(err, "unable to initialize admin client: %v", err) | ||
|
||
err = cl.TriggerBalancer(cmd.Context()) | ||
out.MaybeDie(err, "failed to invoke ondemand partition balancer: %v", err) | ||
|
||
fmt.Println("Successfully triggered on demand partition balancer.\n\nPlease find the progress with 'rpk cluster partitions balancer-status'.") | ||
}, | ||
} | ||
p.InstallFormatFlag(cmd) | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters