Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1906100: use child context to verify payload signature on forced update #493

Merged
merged 1 commit into from Jan 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion pkg/cvo/updatepayload.go
Expand Up @@ -9,6 +9,7 @@ import (
"path/filepath"
"sort"
"strings"
"time"

"github.com/pkg/errors"

Expand Down Expand Up @@ -88,7 +89,22 @@ func (r *payloadRetriever) RetrievePayload(ctx context.Context, update configv1.
if index := strings.LastIndex(update.Image, "@"); index != -1 {
releaseDigest = update.Image[index+1:]
}
if err := r.verifier.Verify(ctx, releaseDigest); err != nil {
verifyCtx := ctx

// if 'force' specified, ensure call to verify payload signature times out well before parent context
// 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(4).Infof("Forced update so reducing payload signature verifcation timeout to %s", timeout)
var cancel context.CancelFunc
verifyCtx, cancel = context.WithTimeout(ctx, timeout)
defer cancel()
}

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 Down