make lock/unlock optional

This commit is contained in:
Chris Lu
2020-04-23 03:50:05 -07:00
parent 57ec7f2ba9
commit bdc337a719
3 changed files with 147 additions and 252 deletions

View File

@@ -18,8 +18,6 @@ Shell
When shell lock,
* lease an admin token (lockTime, token)
* start a goroutine to renew the admin token periodically
For later volume operations, send (lockTime, token) to volume servers for exclusive access
* need to pause renewal a few seconds, to prevent race condition
When shell unlock
* stop the renewal goroutine
@@ -48,13 +46,9 @@ When master receives the lease/renew request from shell
When master receives the release lock request from shell
set the lastLockTime to zero
When master receives the verfication request from volume servers
return secret+lockTime == token && lockTime == lastLockTime
Volume
------
When receives (lockTime, token), ask the master whether this is valid
The volume server does not need to verify.
This makes the lock/unlock optional, similar to what golang code usually does.
*/
@@ -97,11 +91,3 @@ func (ms *MasterServer) ReleaseAdminToken(ctx context.Context, req *master_pb.Re
}
return resp, nil
}
func (ms *MasterServer) VerifyAdminToken(ctx context.Context, req *master_pb.VerifyAdminTokenRequest) (*master_pb.VerifyAdminTokenResponse, error) {
resp := &master_pb.VerifyAdminTokenResponse{}
if ms.isValidToken(time.Unix(0, req.LockTime), req.Token) {
resp.IsValid = true
}
return resp, nil
}