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

secex: guard GPG encryption of Ignition config with mutex #3924

Merged
merged 1 commit into from
Nov 4, 2024
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
10 changes: 10 additions & 0 deletions mantle/platform/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"path/filepath"
"strconv"
"strings"
"sync"
"syscall"
"time"

Expand Down Expand Up @@ -758,11 +759,20 @@ func (builder *QemuBuilder) SetSecureExecution(gpgkey string, hostkey string, co
return nil
}

// When running kola secex tests with '--parallel=auto', this function fails with:
//
// kola: retryloop: failed to bring up machines: encrypting ignition_crypted.1234: exit status 2
//
// Use mutex to protect `gpg --encrypt`
var gpgMutex sync.Mutex

func (builder *QemuBuilder) encryptIgnitionConfig() error {
crypted, err := builder.TempFile("ignition_crypted.*")
if err != nil {
return fmt.Errorf("creating crypted config: %v", err)
}
gpgMutex.Lock()
defer gpgMutex.Unlock()
c := exec.Command("gpg", "--recipient-file", builder.ignitionPubKey, "--yes", "--output", crypted.Name(), "--armor", "--encrypt", builder.ConfigFile)
if err := c.Run(); err != nil {
return fmt.Errorf("encrypting %s: %v", crypted.Name(), err)
Expand Down
Loading