mirror of
https://github.com/minio/minio.git
synced 2025-11-09 05:34:56 -05:00
fix: expire locks only on participating lockers (#11335)
additionally also add a new ForceUnlock API, to allow forcibly unlocking locks if possible.
This commit is contained in:
@@ -119,6 +119,11 @@ func (rpcClient *ReconnectRPCClient) Expired(ctx context.Context, args LockArgs)
|
||||
return expired, err
|
||||
}
|
||||
|
||||
func (rpcClient *ReconnectRPCClient) ForceUnlock(ctx context.Context, args LockArgs) (reply bool, err error) {
|
||||
err = rpcClient.Call("Dsync.ForceUnlock", &args, &reply)
|
||||
return reply, err
|
||||
}
|
||||
|
||||
func (rpcClient *ReconnectRPCClient) String() string {
|
||||
return "http://" + rpcClient.addr + "/" + rpcClient.endpoint
|
||||
}
|
||||
|
||||
@@ -63,6 +63,11 @@ type NetLocker interface {
|
||||
// Expired returns if current lock args has expired.
|
||||
Expired(ctx context.Context, args LockArgs) (bool, error)
|
||||
|
||||
// Unlock (read/write) forcefully for given LockArgs. It should return
|
||||
// * a boolean to indicate success/failure of the operation
|
||||
// * an error on failure of unlock request operation.
|
||||
ForceUnlock(ctx context.Context, args LockArgs) (bool, error)
|
||||
|
||||
// Returns underlying endpoint of this lock client instance.
|
||||
String() string
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ const (
|
||||
StorageInfoAdminAction = "admin:StorageInfo"
|
||||
// DataUsageInfoAdminAction - allow listing data usage info
|
||||
DataUsageInfoAdminAction = "admin:DataUsageInfo"
|
||||
// ForceUnlockAdminAction - allow force unlocking locks
|
||||
ForceUnlockAdminAction = "admin:ForceUnlock"
|
||||
// TopLocksAdminAction - allow listing top locks
|
||||
TopLocksAdminAction = "admin:TopLocksInfo"
|
||||
// ProfilingAdminAction - allow profiling
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -63,6 +64,30 @@ type TopLockOpts struct {
|
||||
Stale bool
|
||||
}
|
||||
|
||||
// ForceUnlock force unlocks input paths...
|
||||
func (adm *AdminClient) ForceUnlock(ctx context.Context, paths ...string) error {
|
||||
// Execute POST on /minio/admin/v3/force-unlock
|
||||
queryVals := make(url.Values)
|
||||
queryVals.Set("paths", strings.Join(paths, ","))
|
||||
resp, err := adm.executeMethod(ctx,
|
||||
http.MethodPost,
|
||||
requestData{
|
||||
relPath: adminAPIPrefix + "/force-unlock",
|
||||
queryValues: queryVals,
|
||||
},
|
||||
)
|
||||
defer closeResponse(resp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return httpRespToErrorResponse(resp)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// TopLocksWithOpts - returns the count number of oldest locks currently active on the server.
|
||||
// additionally we can also enable `stale` to get stale locks currently present on server.
|
||||
func (adm *AdminClient) TopLocksWithOpts(ctx context.Context, opts TopLockOpts) (LockEntries, error) {
|
||||
|
||||
Reference in New Issue
Block a user