|
|
|
|
@ -100,14 +100,23 @@ func (c *httpClient) Lock(info *statemgr.LockInfo) (string, error) {
|
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
body, err := ioutil.ReadAll(resp.Body)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", fmt.Errorf("HTTP remote state already locked, failed to read body")
|
|
|
|
|
return "", &statemgr.LockError{
|
|
|
|
|
Info: info,
|
|
|
|
|
Err: fmt.Errorf("HTTP remote state already locked, failed to read body"),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
existing := statemgr.LockInfo{}
|
|
|
|
|
err = json.Unmarshal(body, &existing)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", fmt.Errorf("HTTP remote state already locked, failed to unmarshal body")
|
|
|
|
|
return "", &statemgr.LockError{
|
|
|
|
|
Info: info,
|
|
|
|
|
Err: fmt.Errorf("HTTP remote state already locked, failed to unmarshal body"),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "", &statemgr.LockError{
|
|
|
|
|
Info: info,
|
|
|
|
|
Err: fmt.Errorf("HTTP remote state already locked: ID=%s", existing.ID),
|
|
|
|
|
}
|
|
|
|
|
return "", fmt.Errorf("HTTP remote state already locked: ID=%s", existing.ID)
|
|
|
|
|
default:
|
|
|
|
|
return "", fmt.Errorf("Unexpected HTTP response code %d", resp.StatusCode)
|
|
|
|
|
}
|
|
|
|
|
|