Skip to content

Commit

Permalink
tier: Add hidden --force to remove tiering command (#5031)
Browse files Browse the repository at this point in the history
To ensure that the server can remove an internal tier configuration
when the tiering is unreachable or other corner cases where it is not
possible for the server to determine if the tier contains some data
or fully empty.
  • Loading branch information
vadmeste authored Sep 6, 2024
1 parent 25ea063 commit 3092b6b
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions cmd/ilm-tier-remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,31 @@ package cmd

import (
"github.com/minio/cli"
"github.com/minio/madmin-go/v3"
"github.com/minio/mc/pkg/probe"
)

var adminTierRmFlags = []cli.Flag{
cli.BoolFlag{
Name: "force",
Usage: "forcefully remove the specified tier",
Hidden: true,
},
cli.BoolFlag{
Name: "dangerous",
Usage: "additional flag to be required in addition to force flag",
Hidden: true,
},
}

var adminTierRmCmd = cli.Command{
Name: "remove",
ShortName: "rm",
Usage: "remove an empty remote tier",
Action: mainAdminTierRm,
OnUsageError: onUsageError,
Before: setGlobalsFromContext,
Flags: globalFlags,
Flags: append(globalFlags, adminTierRmFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
Expand Down Expand Up @@ -65,11 +79,15 @@ func mainAdminTierRm(ctx *cli.Context) error {
fatalIf(errInvalidArgument(), "Tier name can't be empty")
}

if ctx.Bool("force") && !ctx.Bool("dangerous") {
fatalIf(errInvalidArgument(), "This operation results in an irreversible disconnection from the specified remote tier. If you are really sure, retry this command with ‘--force’ and ‘--dangerous’ flags.")
}

// Create a new MinIO Admin Client
client, cerr := newAdminClient(aliasedURL)
fatalIf(cerr, "Unable to initialize admin connection.")

e := client.RemoveTier(globalContext, tierName)
e := client.RemoveTierV2(globalContext, tierName, madmin.RemoveTierOpts{Force: ctx.Bool("force")})
fatalIf(probe.NewError(e).Trace(args...), "Unable to remove remote tier target")

printMsg(&tierMessage{
Expand Down

0 comments on commit 3092b6b

Please sign in to comment.