Skip to content

Commit 6813e3f

Browse files
secex: guard GPG encryption of Ignition config with mutex
Running secex tests with `--parallel=auto` complains: ``` $ cosa kola run --qemu-secex --tag secex --qemu-secex-hostkey hostkey.crt --parallel=auto === RUN ext.config.shared.secex.ensure === RUN ext.config.shared.secex.reboot 2024-11-01T17:28:29Z kola: retryloop: failed to bring up machines: encrypting /var/tmp/mantle-qemu2551463228/ignition_crypted.1734631171: exit status 2 ``` Use mutex for `gpg --encrypt` to avoid this issue.
1 parent d72b3ee commit 6813e3f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mantle/platform/qemu.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"path/filepath"
4141
"strconv"
4242
"strings"
43+
"sync"
4344
"syscall"
4445
"time"
4546

@@ -758,11 +759,20 @@ func (builder *QemuBuilder) SetSecureExecution(gpgkey string, hostkey string, co
758759
return nil
759760
}
760761

762+
// When running kola secex tests with '--parallel=auto', this function fails with:
763+
//
764+
// kola: retryloop: failed to bring up machines: encrypting ignition_crypted.1234: exit status 2
765+
//
766+
// Use mutex to protect `gpg --encrypt`
767+
var gpgMutex sync.Mutex
768+
761769
func (builder *QemuBuilder) encryptIgnitionConfig() error {
762770
crypted, err := builder.TempFile("ignition_crypted.*")
763771
if err != nil {
764772
return fmt.Errorf("creating crypted config: %v", err)
765773
}
774+
gpgMutex.Lock()
775+
defer gpgMutex.Unlock()
766776
c := exec.Command("gpg", "--recipient-file", builder.ignitionPubKey, "--yes", "--output", crypted.Name(), "--armor", "--encrypt", builder.ConfigFile)
767777
if err := c.Run(); err != nil {
768778
return fmt.Errorf("encrypting %s: %v", crypted.Name(), err)

0 commit comments

Comments
 (0)