mirror of https://github.com/minio/minio.git
tier: Add force param to force tiering removal (#20355)
Currently, it is not possible to remove a tier if it is not accessible or contains some data, add a force flag to make the removal successful in that case.
This commit is contained in:
parent
398ffb1136
commit
e47d787adb
|
@ -198,12 +198,14 @@ func (api adminAPIHandlers) RemoveTierHandler(w http.ResponseWriter, r *http.Req
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
tier := vars["tier"]
|
tier := vars["tier"]
|
||||||
|
force := r.Form.Get("force") == "true"
|
||||||
|
|
||||||
if err := globalTierConfigMgr.Reload(ctx, objAPI); err != nil {
|
if err := globalTierConfigMgr.Reload(ctx, objAPI); err != nil {
|
||||||
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||||
return
|
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)
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
12
cmd/tier.go
12
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.
|
// 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)
|
d, err := config.getDriver(ctx, tier)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, errTierNotFound) {
|
if errors.Is(err, errTierNotFound) {
|
||||||
|
@ -256,10 +256,12 @@ func (config *TierConfigMgr) Remove(ctx context.Context, tier string) error {
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if inuse, err := d.InUse(ctx); err != nil {
|
if !force {
|
||||||
return err
|
if inuse, err := d.InUse(ctx); err != nil {
|
||||||
} else if inuse {
|
return err
|
||||||
return errTierBackendNotEmpty
|
} else if inuse {
|
||||||
|
return errTierBackendNotEmpty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
config.Lock()
|
config.Lock()
|
||||||
delete(config.Tiers, tier)
|
delete(config.Tiers, tier)
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -197,7 +197,7 @@ require (
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||||
github.com/minio/colorjson v1.0.8 // indirect
|
github.com/minio/colorjson v1.0.8 // indirect
|
||||||
github.com/minio/filepath v1.0.0 // 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/md5-simd v1.1.2 // indirect
|
||||||
github.com/minio/pkg/v2 v2.0.19 // indirect
|
github.com/minio/pkg/v2 v2.0.19 // indirect
|
||||||
github.com/minio/websocket v1.6.0 // indirect
|
github.com/minio/websocket v1.6.0 // indirect
|
||||||
|
|
4
go.sum
4
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/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 h1:O4w7L3vTxhORqTeyegFdbuO4kKVbAUarJfcmsDXQMTs=
|
||||||
github.com/minio/madmin-go/v3 v3.0.66/go.mod h1:IFAwr0XMrdsLovxAdCcuq/eoL4nRuMVQQv0iubJANQw=
|
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-20240909075310-04c5116c9bdf h1:Cn1gRAcNMK9G+eVODrOxuGdVcbWbjrN26B94nfVU4Xk=
|
||||||
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/go.mod h1:Hh9MpphHGwUDB4BAUbWMF8BMfk3/6IzXcrHumrXTr0I=
|
||||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
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/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=
|
github.com/minio/minio-go/v6 v6.0.46/go.mod h1:qD0lajrGW49lKZLtXKtCB4X/qkMf0a5tBvN2PaZg7Gg=
|
||||||
|
|
Loading…
Reference in New Issue