From 5135d68b5f37e595d19293bd47a1f5728deffe5c Mon Sep 17 00:00:00 2001 From: Sylvia Moss Date: Wed, 2 Mar 2022 15:39:17 +0100 Subject: [PATCH] do not fail for scheduled revocation (#11619) --- internal/registry/service.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/registry/service.go b/internal/registry/service.go index 1382fe492..2685ec6d4 100644 --- a/internal/registry/service.go +++ b/internal/registry/service.go @@ -127,8 +127,9 @@ func (client *Client) GetIteration(ctx context.Context, bucketSlug string, opts } if resp.Payload.Iteration != nil { - if !time.Time(resp.Payload.Iteration.RevokeAt).IsZero() { - // If RevokeAt is not a zero date, it means this iteration is revoked and should not be used + revokeAt := time.Time(resp.Payload.Iteration.RevokeAt) + if !revokeAt.IsZero() && revokeAt.Before(time.Now().UTC()) { + // If RevokeAt is not a zero date and is before NOW, it means this iteration is revoked and should not be used // to build new images. return nil, fmt.Errorf("the iteration %s is revoked and can not be used on Packer builds", resp.Payload.Iteration.ID) @@ -254,8 +255,9 @@ func (client *Client) GetIterationFromChannel( if resp.Payload.Channel != nil { if resp.Payload.Channel.Iteration != nil { - if !time.Time(resp.Payload.Channel.Iteration.RevokeAt).IsZero() { - // If RevokeAt is not a zero date, it means this iteration is revoked and should not be used + revokeAt := time.Time(resp.Payload.Channel.Iteration.RevokeAt) + if !revokeAt.IsZero() && revokeAt.Before(time.Now().UTC()) { + // If RevokeAt is not a zero date and is before NOW, it means this iteration is revoked and should not be used // to build new images. return nil, fmt.Errorf("the iteration associated with the channel %s is revoked and can not be used on Packer builds", channelName)