mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
Added clear subcommand for control lock (#3013)
Added clear subcommand for control lock with following options:
```
3. Clear lock named 'bucket/object' (exact match).
$ minio control lock clear http://localhost:9000/bucket/object
4. Clear all locks with names that start with 'bucket/prefix' (wildcard match).
$ minio control lock --recursive clear http://localhost:9000/bucket/prefix
5. Clear all locks older than 10minutes.
$ minio control lock --older-than=10m clear http://localhost:9000/
6. Clear all locks with names that start with 'bucket/a' and that are older than 1hour.
$ minio control lock --recursive --older-than=1h clear http://localhost:9000/bucket/a
```
This commit is contained in:
@@ -99,7 +99,7 @@ func getSystemLockState() (SystemLockState, error) {
|
||||
func (c *controlAPIHandlers) remoteLockInfoCall(args *GenericArgs, replies []SystemLockState) error {
|
||||
var wg sync.WaitGroup
|
||||
var errs = make([]error, len(c.RemoteControls))
|
||||
// Send remote call to all neighboring peers to restart minio servers.
|
||||
// Send remote call to all neighboring peers fetch control lock info.
|
||||
for index, clnt := range c.RemoteControls {
|
||||
wg.Add(1)
|
||||
go func(index int, client *AuthRPCClient) {
|
||||
@@ -133,7 +133,7 @@ func (c *controlAPIHandlers) RemoteLockInfo(args *GenericArgs, reply *SystemLock
|
||||
return nil
|
||||
}
|
||||
|
||||
// LockInfo - RPC control handler for `minio control lock`. Returns the info of the locks held in the cluster.
|
||||
// LockInfo - RPC control handler for `minio control lock list`. Returns the info of the locks held in the cluster.
|
||||
func (c *controlAPIHandlers) LockInfo(args *GenericArgs, reply *map[string]SystemLockState) error {
|
||||
if !isRPCTokenValid(args.Token) {
|
||||
return errInvalidToken
|
||||
@@ -167,3 +167,20 @@ func (c *controlAPIHandlers) LockInfo(args *GenericArgs, reply *map[string]Syste
|
||||
// Success.
|
||||
return nil
|
||||
}
|
||||
|
||||
// LockClearArgs - arguments for LockClear handler
|
||||
type LockClearArgs struct {
|
||||
GenericArgs
|
||||
Bucket string
|
||||
Object string
|
||||
}
|
||||
|
||||
// LockClear - RPC control handler for `minio control lock clear`.
|
||||
func (c *controlAPIHandlers) LockClear(args *LockClearArgs, reply *GenericReply) error {
|
||||
if !isRPCTokenValid(args.Token) {
|
||||
return errInvalidToken
|
||||
}
|
||||
nsMutex.ForceUnlock(args.Bucket, args.Object)
|
||||
*reply = GenericReply{}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user