diff --git a/cmd/ctr/commands/leases/leases.go b/cmd/ctr/commands/leases/leases.go index 2e07b9f82..d0b107dbf 100644 --- a/cmd/ctr/commands/leases/leases.go +++ b/cmd/ctr/commands/leases/leases.go @@ -113,7 +113,7 @@ var createCommand = cli.Command{ cli.DurationFlag{ Name: "expires, x", Usage: "expiration of lease (0 value will not expire)", - Value: 24 * 3600 * time.Second, + Value: 24 * time.Hour, }, }, Action: func(context *cli.Context) error { diff --git a/lease.go b/lease.go index 8b7357d47..d46b79d9f 100644 --- a/lease.go +++ b/lease.go @@ -34,7 +34,7 @@ func (c *Client) WithLease(ctx context.Context) (context.Context, func(context.C ls := c.LeasesService() - l, err := ls.Create(ctx, leases.WithRandomID(), leases.WithExpiration(24*3600*time.Second)) + l, err := ls.Create(ctx, leases.WithRandomID(), leases.WithExpiration(24*time.Hour)) if err != nil { return nil, nil, err } diff --git a/metadata/content.go b/metadata/content.go index 5835bc37d..7293f1bfa 100644 --- a/metadata/content.go +++ b/metadata/content.go @@ -420,12 +420,12 @@ func (cs *contentStore) Writer(ctx context.Context, opts ...content.WriterOpt) ( } if !leased { // Add timestamp to allow aborting once stale - // When lease is set the ingest shoudl be aborted + // When lease is set the ingest should be aborted // after lease it belonged to is deleted. // Expiration can be configurable in the future to // give more control to the daemon, however leases // already give users more control of expiration. - expireAt := time.Now().UTC().Add(24 * 3600 * time.Second) + expireAt := time.Now().UTC().Add(24 * time.Hour) if err := writeExpireAt(expireAt, bkt); err != nil { return err } diff --git a/metadata/gc_test.go b/metadata/gc_test.go index 5dd41bea1..8505ac77c 100644 --- a/metadata/gc_test.go +++ b/metadata/gc_test.go @@ -55,7 +55,7 @@ func TestGCRoots(t *testing.T) { addContent("ns2", dgst(9), nil), addIngest("ns1", "ingest-1", "", nil), // will be seen as expired addIngest("ns1", "ingest-2", "", timeIn(0)), // expired - addIngest("ns1", "ingest-3", "", timeIn(3600*time.Second)), + addIngest("ns1", "ingest-3", "", timeIn(time.Hour)), addIngest("ns2", "ingest-4", "", nil), addIngest("ns2", "ingest-5", dgst(8), nil), addIngest("ns2", "ingest-6", "", nil), // added to expired lease @@ -73,7 +73,7 @@ func TestGCRoots(t *testing.T) { addLeaseSnapshot("ns2", "l2", "overlay", "sn6"), addLeaseContent("ns2", "l1", dgst(4)), addLeaseContent("ns2", "l2", dgst(5)), - addLease("ns2", "l3", labelmap(string(labelGCExpire), time.Now().Add(3600*time.Second).Format(time.RFC3339))), + addLease("ns2", "l3", labelmap(string(labelGCExpire), time.Now().Add(time.Hour).Format(time.RFC3339))), addLeaseContent("ns2", "l3", dgst(6)), addLeaseSnapshot("ns2", "l3", "overlay", "sn7"), addLeaseIngest("ns2", "l3", "ingest-4"), @@ -156,7 +156,7 @@ func TestGCRemove(t *testing.T) { addSnapshot("ns1", "overlay", "sn3", "", labelmap(string(labelGCRoot), "always")), addSnapshot("ns1", "overlay", "sn4", "", nil), addSnapshot("ns2", "overlay", "sn1", "", nil), - addLease("ns1", "l1", labelmap(string(labelGCExpire), time.Now().Add(3600*time.Second).Format(time.RFC3339))), + addLease("ns1", "l1", labelmap(string(labelGCExpire), time.Now().Add(time.Hour).Format(time.RFC3339))), addLease("ns2", "l2", labelmap(string(labelGCExpire), time.Now().Format(time.RFC3339))), }