diff --git a/cmd/tier-handlers.go b/cmd/tier-handlers.go index 3b794fc8b..8c8148749 100644 --- a/cmd/tier-handlers.go +++ b/cmd/tier-handlers.go @@ -198,12 +198,14 @@ func (api adminAPIHandlers) RemoveTierHandler(w http.ResponseWriter, r *http.Req vars := mux.Vars(r) tier := vars["tier"] + force := r.Form.Get("force") == "true" + if err := globalTierConfigMgr.Reload(ctx, objAPI); err != nil { writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL) return } - if err := globalTierConfigMgr.Remove(ctx, tier); err != nil { + if err := globalTierConfigMgr.Remove(ctx, tier, force); err != nil { writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL) return } diff --git a/cmd/tier.go b/cmd/tier.go index e7fd93d40..953a8d100 100644 --- a/cmd/tier.go +++ b/cmd/tier.go @@ -248,7 +248,7 @@ func (config *TierConfigMgr) Add(ctx context.Context, tier madmin.TierConfig, ig } // Remove removes tier if it is empty. -func (config *TierConfigMgr) Remove(ctx context.Context, tier string) error { +func (config *TierConfigMgr) Remove(ctx context.Context, tier string, force bool) error { d, err := config.getDriver(ctx, tier) if err != nil { if errors.Is(err, errTierNotFound) { @@ -256,10 +256,12 @@ func (config *TierConfigMgr) Remove(ctx context.Context, tier string) error { } return err } - if inuse, err := d.InUse(ctx); err != nil { - return err - } else if inuse { - return errTierBackendNotEmpty + if !force { + if inuse, err := d.InUse(ctx); err != nil { + return err + } else if inuse { + return errTierBackendNotEmpty + } } config.Lock() delete(config.Tiers, tier) diff --git a/go.mod b/go.mod index 9342ae9dc..32e33191f 100644 --- a/go.mod +++ b/go.mod @@ -197,7 +197,7 @@ require ( github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/minio/colorjson v1.0.8 // indirect github.com/minio/filepath v1.0.0 // indirect - github.com/minio/mc v0.0.0-20240826104958-a55d9a8d17da // indirect + github.com/minio/mc v0.0.0-20240909075310-04c5116c9bdf // indirect github.com/minio/md5-simd v1.1.2 // indirect github.com/minio/pkg/v2 v2.0.19 // indirect github.com/minio/websocket v1.6.0 // indirect diff --git a/go.sum b/go.sum index ecc0ef87b..7dc1a77bb 100644 --- a/go.sum +++ b/go.sum @@ -428,8 +428,8 @@ github.com/minio/kms-go/kms v0.4.0 h1:cLPZceEp+05xHotVBaeFJrgL7JcXM4lBy6PU0idkE7 github.com/minio/kms-go/kms v0.4.0/go.mod h1:q12CehiIy2qgBnDKq6Q7wmPi2PHSyRVug5DKp0HAVeE= github.com/minio/madmin-go/v3 v3.0.66 h1:O4w7L3vTxhORqTeyegFdbuO4kKVbAUarJfcmsDXQMTs= github.com/minio/madmin-go/v3 v3.0.66/go.mod h1:IFAwr0XMrdsLovxAdCcuq/eoL4nRuMVQQv0iubJANQw= -github.com/minio/mc v0.0.0-20240826104958-a55d9a8d17da h1:/JNoAwFPhCG0hUkc9k/wUlzMUO7tA9WLIoWgqQjYph4= -github.com/minio/mc v0.0.0-20240826104958-a55d9a8d17da/go.mod h1:g/LyYpzVUVY+ZxfIDtzigg+L3NjAn88EBsLAkFvo+M0= +github.com/minio/mc v0.0.0-20240909075310-04c5116c9bdf h1:Cn1gRAcNMK9G+eVODrOxuGdVcbWbjrN26B94nfVU4Xk= +github.com/minio/mc v0.0.0-20240909075310-04c5116c9bdf/go.mod h1:Hh9MpphHGwUDB4BAUbWMF8BMfk3/6IzXcrHumrXTr0I= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= github.com/minio/minio-go/v6 v6.0.46/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=