Skip to content

Commit 687686e

Browse files
committed
pkg/cvo/updatepayload.go: use child context to retrieve payload
1 parent 1e51a0e commit 687686e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

pkg/cvo/updatepayload.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"path/filepath"
1010
"sort"
1111
"strings"
12+
"time"
1213

1314
"github.com/pkg/errors"
1415

@@ -88,7 +89,22 @@ func (r *payloadRetriever) RetrievePayload(ctx context.Context, update configv1.
8889
if index := strings.LastIndex(update.Image, "@"); index != -1 {
8990
releaseDigest = update.Image[index+1:]
9091
}
91-
if err := r.verifier.Verify(ctx, releaseDigest); err != nil {
92+
verifyCtx := ctx
93+
94+
// if 'force' specified, ensure call to verify payload signature times out well before parent context
95+
// to allow time to perform forced update
96+
if update.Force {
97+
timeout := time.Minute * 2
98+
if deadline, deadlineSet := ctx.Deadline(); deadlineSet {
99+
timeout = time.Until(deadline) / 2
100+
}
101+
klog.V(4).Infof("Forced update so reducing payload signature verifcation timeout to %s", timeout)
102+
var cancel context.CancelFunc
103+
verifyCtx, cancel = context.WithTimeout(ctx, timeout)
104+
defer cancel()
105+
}
106+
107+
if err := r.verifier.Verify(verifyCtx, releaseDigest); err != nil {
92108
vErr := &payload.UpdateError{
93109
Reason: "ImageVerificationFailed",
94110
Message: fmt.Sprintf("The update cannot be verified: %v", err),

0 commit comments

Comments
 (0)