Remove "expires" from lock info.
We are not going to handle lock expiration, at least at this time, so remove the Expires fields to avoid any confusion.
This commit is contained in:
parent
91608843a4
commit
a2b5811f50
|
@ -19,16 +19,14 @@ type lockInfo struct {
|
||||||
Path string
|
Path string
|
||||||
// The time the lock was taken
|
// The time the lock was taken
|
||||||
Created time.Time
|
Created time.Time
|
||||||
// The time this lock expires
|
// Extra info passed to State.Lock
|
||||||
Expires time.Time
|
|
||||||
// The lock reason passed to State.Lock
|
|
||||||
Reason string
|
Reason string
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the lock info formatted in an error
|
// return the lock info formatted in an error
|
||||||
func (l *lockInfo) Err() error {
|
func (l *lockInfo) Err() error {
|
||||||
return fmt.Errorf("state file %q locked. created:%s, expires:%s, reason:%s",
|
return fmt.Errorf("state file %q locked. created:%s, reason:%s",
|
||||||
l.Path, l.Created, l.Expires, l.Reason)
|
l.Path, l.Created, l.Reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LocalState manages a state storage that is local to the filesystem.
|
// LocalState manages a state storage that is local to the filesystem.
|
||||||
|
@ -229,7 +227,6 @@ func (s *LocalState) writeLockInfo(reason string) error {
|
||||||
lockInfo := &lockInfo{
|
lockInfo := &lockInfo{
|
||||||
Path: s.Path,
|
Path: s.Path,
|
||||||
Created: time.Now().UTC(),
|
Created: time.Now().UTC(),
|
||||||
Expires: time.Now().Add(time.Hour).UTC(),
|
|
||||||
Reason: reason,
|
Reason: reason,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,6 @@ func (c *S3Client) Lock(reason string) error {
|
||||||
Item: map[string]*dynamodb.AttributeValue{
|
Item: map[string]*dynamodb.AttributeValue{
|
||||||
"LockID": {S: aws.String(stateName)},
|
"LockID": {S: aws.String(stateName)},
|
||||||
"Created": {S: aws.String(time.Now().UTC().Format(time.RFC3339))},
|
"Created": {S: aws.String(time.Now().UTC().Format(time.RFC3339))},
|
||||||
"Expires": {S: aws.String(time.Now().Add(time.Hour).UTC().Format(time.RFC3339))},
|
|
||||||
"Info": {S: aws.String(reason)},
|
"Info": {S: aws.String(reason)},
|
||||||
},
|
},
|
||||||
TableName: aws.String(c.lockTable),
|
TableName: aws.String(c.lockTable),
|
||||||
|
@ -220,7 +219,7 @@ func (c *S3Client) Lock(reason string) error {
|
||||||
Key: map[string]*dynamodb.AttributeValue{
|
Key: map[string]*dynamodb.AttributeValue{
|
||||||
"LockID": {S: aws.String(fmt.Sprintf("%s/%s", c.bucketName, c.keyName))},
|
"LockID": {S: aws.String(fmt.Sprintf("%s/%s", c.bucketName, c.keyName))},
|
||||||
},
|
},
|
||||||
ProjectionExpression: aws.String("LockID, Created, Expires, Info"),
|
ProjectionExpression: aws.String("LockID, Created, Info"),
|
||||||
TableName: aws.String(c.lockTable),
|
TableName: aws.String(c.lockTable),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,19 +228,16 @@ func (c *S3Client) Lock(reason string) error {
|
||||||
return fmt.Errorf("s3 state file %q locked, cfailed to retrive info: %s", stateName, err)
|
return fmt.Errorf("s3 state file %q locked, cfailed to retrive info: %s", stateName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var created, expires, info string
|
var created, info string
|
||||||
if v, ok := resp.Item["Created"]; ok && v.S != nil {
|
if v, ok := resp.Item["Created"]; ok && v.S != nil {
|
||||||
created = *v.S
|
created = *v.S
|
||||||
}
|
}
|
||||||
if v, ok := resp.Item["Expires"]; ok && v.S != nil {
|
|
||||||
expires = *v.S
|
|
||||||
}
|
|
||||||
if v, ok := resp.Item["Info"]; ok && v.S != nil {
|
if v, ok := resp.Item["Info"]; ok && v.S != nil {
|
||||||
info = *v.S
|
info = *v.S
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("state file %q locked. created:%s, expires:%s, reason:%s",
|
return fmt.Errorf("state file %q locked. created:%s, reason:%s",
|
||||||
stateName, created, expires, info)
|
stateName, created, info)
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue