From a2b5811f50731f58a1766cbfcb4ceb7d094fe85d Mon Sep 17 00:00:00 2001 From: James Bardin Date: Fri, 3 Feb 2017 14:47:08 -0500 Subject: [PATCH] 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. --- state/local.go | 9 +++------ state/remote/s3.go | 12 ++++-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/state/local.go b/state/local.go index 01d696442..e1129ebbe 100644 --- a/state/local.go +++ b/state/local.go @@ -19,16 +19,14 @@ type lockInfo struct { Path string // The time the lock was taken Created time.Time - // The time this lock expires - Expires time.Time - // The lock reason passed to State.Lock + // Extra info passed to State.Lock Reason string } // return the lock info formatted in an error func (l *lockInfo) Err() error { - return fmt.Errorf("state file %q locked. created:%s, expires:%s, reason:%s", - l.Path, l.Created, l.Expires, l.Reason) + return fmt.Errorf("state file %q locked. created:%s, reason:%s", + l.Path, l.Created, l.Reason) } // LocalState manages a state storage that is local to the filesystem. @@ -229,7 +227,6 @@ func (s *LocalState) writeLockInfo(reason string) error { lockInfo := &lockInfo{ Path: s.Path, Created: time.Now().UTC(), - Expires: time.Now().Add(time.Hour).UTC(), Reason: reason, } diff --git a/state/remote/s3.go b/state/remote/s3.go index 772737e11..367335865 100644 --- a/state/remote/s3.go +++ b/state/remote/s3.go @@ -207,7 +207,6 @@ func (c *S3Client) Lock(reason string) error { Item: map[string]*dynamodb.AttributeValue{ "LockID": {S: aws.String(stateName)}, "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)}, }, TableName: aws.String(c.lockTable), @@ -220,7 +219,7 @@ func (c *S3Client) Lock(reason string) error { Key: map[string]*dynamodb.AttributeValue{ "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), } @@ -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) } - var created, expires, info string + var created, info string if v, ok := resp.Item["Created"]; ok && v.S != nil { 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 { info = *v.S } - return fmt.Errorf("state file %q locked. created:%s, expires:%s, reason:%s", - stateName, created, expires, info) + return fmt.Errorf("state file %q locked. created:%s, reason:%s", + stateName, created, info) } return nil