Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions pkg/cvo/updatepayload.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,22 @@ func (r *payloadRetriever) RetrievePayload(ctx context.Context, update configv1.
if index := strings.LastIndex(update.Image, "@"); index != -1 {
releaseDigest = update.Image[index+1:]
}
verifyCtx := ctx

// if 'force' specified, ensure call to verify payload signature times out well before parent context
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment looks exactly like what I blindly suggested to Trevor :)

// to allow time to perform forced update
if update.Force {
timeout := time.Minute * 2
if deadline, deadlineSet := ctx.Deadline(); deadlineSet {
timeout = time.Until(deadline) / 2
}
klog.V(2).Infof("Forced update so reducing payload signature verification timeout to %s", timeout)
var cancel context.CancelFunc
verifyCtx, cancel = context.WithTimeout(ctx, timeout)
defer cancel()
}

// set up a new context with reasonable timeout for signature and payload retrieval
retrieveCtx, cancel := context.WithTimeout(ctx, time.Minute*4)
defer cancel()

if err := r.verifier.Verify(retrieveCtx, releaseDigest); err != nil {
if err := r.verifier.Verify(verifyCtx, releaseDigest); err != nil {
vErr := &payload.UpdateError{
Reason: "ImageVerificationFailed",
Message: fmt.Sprintf("The update cannot be verified: %v", err),
Expand All @@ -112,7 +122,7 @@ func (r *payloadRetriever) RetrievePayload(ctx context.Context, update configv1.

// download the payload to the directory
var err error
info.Directory, err = r.targetUpdatePayloadDir(retrieveCtx, update)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is bugged. It couples the lookup timeout to the payload retrieval timeout, causing guaranteed failures when verifies timeout. This prevents force from working without signatures. Before reintroducing, you should write a test.

info.Directory, err = r.targetUpdatePayloadDir(ctx, update)
if err != nil {
return PayloadInfo{}, &payload.UpdateError{
Reason: "UpdatePayloadRetrievalFailed",
Expand Down