Skip to content

Commit

Permalink
fix: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gene-redpanda committed Oct 14, 2024
1 parent 24f2bcc commit df79928
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 30 deletions.
4 changes: 3 additions & 1 deletion src/go/rpk/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ linters:
- staticcheck
- typecheck
- unused
- lll
# Disabled by default
- asciicheck
- bidichk
Expand Down Expand Up @@ -47,7 +48,8 @@ linters-settings:
# We do not want to enforce every usage of fmt.Errorf to use %w.
errorlint:
errorf: false

lll:
line-length: 80
# If we want to opt out of a lint, we require an explanation.
nolintlint:
allow-unused: false
Expand Down
9 changes: 3 additions & 6 deletions src/go/rpk/pkg/cli/cluster/storage/cancel-mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@ func newMountCancel(fs afero.Fs, p *config.Params) *cobra.Command {
Use: "cancel-mount [MIGRATION ID]",
Aliases: []string{"cancel-unmount"},
Short: "Cancels a mount/unmount operation on a topic.",
Long: `Cancels a mount/unmount operation on a topic.
The operation is identified by the migration ID which is emitted when a mount
or unmount...
operation is executed. You can also get the migration ID by listing the
mount/unmount operations using 'rpk cluster storage list-mount'`,
Long: `Cancels a mount/unmount operation on a topic. Use the migration ID
that is emitted when the mount or unmount operation is executed.
You can also get the migration ID by listing the mount/unmount operations.`,
Example: `
Cancel a mount/unmount operation
rpk cluster storage cancel-mount 123
Expand Down
7 changes: 4 additions & 3 deletions src/go/rpk/pkg/cli/cluster/storage/list-mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func newMountList(fs afero.Fs, p *config.Params) *cobra.Command {
Use: "list-mount",
Short: "List mount/unmount operations",
Aliases: []string{"list-unmount"},
Long: `List mount/unmount operations on a topic to the Redpanda Cluster from Tiered Storage.
Long: `List mount/unmount operations on a topic to the Redpanda cluster from Tiered Storage.
You can also filter the list by state using the --filter flag. The possible states are:
- planned
Expand All @@ -47,12 +47,13 @@ Use filter to list only migrations in a specific state
`,
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, _ []string) {
pf, err := p.LoadVirtualProfile(fs)
out.MaybeDie(err, "rpk unable to load config: %v", err)
f := p.Formatter
if h, ok := f.Help([]migrationState{}); ok {
out.Exit(h)
}

pf, err := p.LoadVirtualProfile(fs)
out.MaybeDie(err, "rpk unable to load config: %v", err)
config.CheckExitCloudAdmin(pf)
adm, err := adminapi.NewClient(cmd.Context(), fs, pf)
out.MaybeDie(err, "unable to initialize admin client: %v", err)
Expand Down
11 changes: 5 additions & 6 deletions src/go/rpk/pkg/cli/cluster/storage/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ func newMountCommand(fs afero.Fs, p *config.Params) *cobra.Command {

cmd := &cobra.Command{
Use: "mount [TOPIC]",
Short: "Mount a topic to the Redpanda Cluster from Tiered Storage",
Long: `Mount a topic from Tiered Storage to the Redpanda cluster.
Short: "Mount a topic",
Long: `Mount a topic to the Redpanda cluster from Tiered Storage .
This command mounts a topic in the Redpanda Cluster using log segments stored
in Tiered Storage.
This command mounts a topic in the Redpanda cluster using log segments stored
in Tiered Storage. The topic may be optionally renamed with the --to flag.
Requirements:
- Tiered storage must be enabled.
- The topic must have a minimum of three partitions.
- Tiered Storage must be enabled.
- Log segments for the topic must be available in Tiered Storage.
- A topic with the same name must not already exist in the cluster.`,
Example: `
Expand Down
10 changes: 5 additions & 5 deletions src/go/rpk/pkg/cli/cluster/storage/status-mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ import (
func newMountStatus(fs afero.Fs, p *config.Params) *cobra.Command {
cmd := &cobra.Command{
Use: "status-mount [MIGRATION ID]",
Short: "Status of a mount/unmount operation on a topic to the Redpanda Cluster from Tiered Storage",
Long: `Status of a mount/unmount operation on a topic to the Redpanda Cluster from Tiered Storage.`,
Short: "Status of mount/unmount operation",
Long: "Status of mount/unmount operation on topic to Redpanda cluster from Tiered Storage",
Aliases: []string{"status-unmount"},
Example: `
Status for a mount/unmount operation
rpk cluster storage status-mount 123
`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, from []string) {
pf, err := p.LoadVirtualProfile(fs)
out.MaybeDie(err, "rpk unable to load config: %v", err)
f := p.Formatter
if h, ok := f.Help(migrationState{}); ok {
out.Exit(h)
}
pf, err := p.LoadVirtualProfile(fs)
out.MaybeDie(err, "rpk unable to load config: %v", err)

config.CheckExitCloudAdmin(pf)
adm, err := adminapi.NewClient(cmd.Context(), fs, pf)
Expand All @@ -67,7 +67,7 @@ Status for a mount/unmount operation
func printDetailedStatusMount(f config.OutFormatter, d migrationState, w io.Writer) {
if isText, _, t, err := f.Format(d); !isText {
out.MaybeDie(err, "unable to print in the requested format %q: %v", f.Kind, err)
fmt.Fprintf(w, "%s\n", t)
fmt.Fprintln(w, t)
return
}
tw := out.NewTableTo(os.Stdout, "ID", "State", "Migration", "Topics")
Expand Down
13 changes: 4 additions & 9 deletions src/go/rpk/pkg/cli/cluster/storage/unmount.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
package storage

import (
"context"
"fmt"
"os"

Expand All @@ -25,7 +24,7 @@ import (
func newUnmountCommand(fs afero.Fs, p *config.Params) *cobra.Command {
cmd := &cobra.Command{
Use: "unmount [TOPIC]",
Short: "Unmount a topic from the Redpanda Cluster",
Short: "Unmount a topic from the Redpanda cluster",
Long: `Unmount a topic from the Redpanda cluster and secure it in Tiered
Storage.
Expand All @@ -34,11 +33,6 @@ This command performs an operation that:
2. Flushes data to Tiered Storage
3. Removes the topic from the cluster
The unmount process ensures data safety and cluster integrity. Every
acknowledged message before the initiation of unmount is guaranteed to be
persisted in Tiered Storage, subject to Redpanda's existing data safety
guarantees.
Key Points:
- During unmounting, any attempted writes or reads will receive an
UNKNOWN_TOPIC_OR_PARTITION error.
Expand All @@ -47,7 +41,8 @@ Key Points:
- After unmounting, the topic can be remounted to this cluster or a different
cluster if the log segments are moved to that cluster's Tiered Storage.
`,
Example: `Unmount topic 'my-topic' from the cluster in the 'my-namespace'
Example: `
Unmount topic 'my-topic' from the cluster in the 'my-namespace'
rpk cluster storage unmount my-namespace/my-topic
`,
Args: cobra.ExactArgs(1),
Expand All @@ -63,7 +58,7 @@ Key Points:
out.Die("topic is required")
}

mg, err := adm.UnmountTopics(context.Background(), rpadmin.UnmountConfiguration{Topics: []rpadmin.NamespacedTopic{{Namespace: string2pointer(n), Topic: t}}})
mg, err := adm.UnmountTopics(cmd.Context(), rpadmin.UnmountConfiguration{Topics: []rpadmin.NamespacedTopic{{Namespace: string2pointer(n), Topic: t}}})
out.MaybeDie(err, "unable to unmount topic: %v", err)
fmt.Fprintf(os.Stdout, "migration ID: %d\n", mg.ID)
},
Expand Down

0 comments on commit df79928

Please sign in to comment.