mirror of
https://github.com/hashicorp/terraform.git
synced 2026-02-18 18:29:44 -05:00
backend/http: Return existing lock info from backend on conflict (#38144)
* Return existing lock info from http state backend on conflict * Remove info from LockError if failed to read or unmarshal * Add change to .changes
This commit is contained in:
parent
d92915a29a
commit
5e4cfd42fa
2 changed files with 6 additions and 5 deletions
3
.changes/v1.15/BUG FIXES-20260210-113930.yaml
Normal file
3
.changes/v1.15/BUG FIXES-20260210-113930.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
kind: BUG FIXES
|
||||
body: 'backend: Return conflicting lock info from HTTP backend instead of the lock that failed to be taken'
|
||||
time: 2026-02-10T11:39:30.00000-08:00
|
||||
|
|
@ -105,20 +105,18 @@ func (c *httpClient) Lock(info *statemgr.LockInfo) (string, error) {
|
|||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", &statemgr.LockError{
|
||||
Info: info,
|
||||
Err: fmt.Errorf("HTTP remote state already locked, failed to read body"),
|
||||
Err: fmt.Errorf("HTTP remote state already locked, failed to read body"),
|
||||
}
|
||||
}
|
||||
existing := statemgr.LockInfo{}
|
||||
err = json.Unmarshal(body, &existing)
|
||||
if err != nil {
|
||||
return "", &statemgr.LockError{
|
||||
Info: info,
|
||||
Err: fmt.Errorf("HTTP remote state already locked, failed to unmarshal body"),
|
||||
Err: fmt.Errorf("HTTP remote state already locked, failed to unmarshal body"),
|
||||
}
|
||||
}
|
||||
return "", &statemgr.LockError{
|
||||
Info: info,
|
||||
Info: &existing,
|
||||
Err: fmt.Errorf("HTTP remote state already locked: ID=%s", existing.ID),
|
||||
}
|
||||
default:
|
||||
|
|
|
|||
Loading…
Reference in a new issue