mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Add support for tier-remove and tier-verify (#14382)
* Add tier remove support only if it's empty * Add support for tier verify
This commit is contained in:
committed by
GitHub
parent
9d7648f02f
commit
27f64dd9a4
30
cmd/tier.go
30
cmd/tier.go
@@ -40,6 +40,7 @@ var (
|
||||
errTierInsufficientCreds = errors.New("insufficient tier credentials supplied")
|
||||
errTierBackendInUse = errors.New("remote tier backend already in use")
|
||||
errTierTypeUnsupported = errors.New("unsupported tier type")
|
||||
errTierBackendNotEmpty = errors.New("remote tier not empty")
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -116,6 +117,35 @@ func (config *TierConfigMgr) Add(ctx context.Context, tier madmin.TierConfig) er
|
||||
return nil
|
||||
}
|
||||
|
||||
// Remove removes tier if it is empty.
|
||||
func (config *TierConfigMgr) Remove(ctx context.Context, tier string) error {
|
||||
d, err := config.getDriver(tier)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if inuse, err := d.InUse(ctx); err != nil {
|
||||
return err
|
||||
} else if inuse {
|
||||
return errTierBackendNotEmpty
|
||||
} else {
|
||||
config.Lock()
|
||||
delete(config.Tiers, tier)
|
||||
delete(config.drivercache, tier)
|
||||
config.Unlock()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Verify verifies if tier's config is valid by performing all supported
|
||||
// operations on the corresponding warmbackend.
|
||||
func (config *TierConfigMgr) Verify(ctx context.Context, tier string) error {
|
||||
d, err := config.getDriver(tier)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return checkWarmBackend(ctx, d)
|
||||
}
|
||||
|
||||
// Empty returns if tier targets are empty
|
||||
func (config *TierConfigMgr) Empty() bool {
|
||||
return len(config.ListTiers()) == 0
|
||||
|
||||
Reference in New Issue
Block a user