diff --git a/go.mod b/go.mod index 71c5fdb0..f8911cf6 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/crc-org/macadam go 1.21 require ( - github.com/containers/podman/v5 v5.1.1 + github.com/containers/podman/v5 v5.1.2 github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 // indirect @@ -34,7 +34,7 @@ require ( github.com/containerd/typeurl/v2 v2.1.1 // indirect github.com/containers/buildah v1.36.0 // indirect github.com/containers/gvisor-tap-vsock v0.7.4-0.20240408151405-d744d71db363 // indirect - github.com/containers/image/v5 v5.31.0 // indirect + github.com/containers/image/v5 v5.31.1 // indirect github.com/containers/libhvee v0.7.1 // indirect github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect github.com/containers/ocicrypt v1.1.10 // indirect diff --git a/go.sum b/go.sum index 9534c605..038f0068 100644 --- a/go.sum +++ b/go.sum @@ -71,16 +71,16 @@ github.com/containers/common v0.59.1 h1:7VkmJN3YvD0jLFwaUjLHSRJ98JLffydiyOJjYr0d github.com/containers/common v0.59.1/go.mod h1:53VicJCZ2AD0O+Br7VVoyrS7viXF4YmwlTIocWUT8XE= github.com/containers/gvisor-tap-vsock v0.7.4-0.20240408151405-d744d71db363 h1:EqWMZeFa08y2c1GniaFkfjlO5AjegoG2foWo6NlDfUY= github.com/containers/gvisor-tap-vsock v0.7.4-0.20240408151405-d744d71db363/go.mod h1:KN4qqZfwVBzvqlN1Ytbhf84sOzftw+R8YL9bixQlr2Y= -github.com/containers/image/v5 v5.31.0 h1:eDFVlz5XaYICxe9dXpf23htEKvyosgkl62mJlIATXE4= -github.com/containers/image/v5 v5.31.0/go.mod h1:5QfOqSackPkSbF7Qxc1DnVNnPJKQ+KWLkfEfDpK590Q= +github.com/containers/image/v5 v5.31.1 h1:3x9soI6Biml/GiDLpkSmKrkRSwVGctxu/vONpoUdklA= +github.com/containers/image/v5 v5.31.1/go.mod h1:5QfOqSackPkSbF7Qxc1DnVNnPJKQ+KWLkfEfDpK590Q= github.com/containers/libhvee v0.7.1 h1:dWGF5GLq9DZvXo3P8aDp3cNieL5eCaSell4UmeA/jY4= github.com/containers/libhvee v0.7.1/go.mod h1:fRKB3AyIqHMvq6xaeYhTpckM2cdoq0oecolyoiuLP7M= github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 h1:Qzk5C6cYglewc+UyGf6lc8Mj2UaPTHy/iF2De0/77CA= github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY= github.com/containers/ocicrypt v1.1.10 h1:r7UR6o8+lyhkEywetubUUgcKFjOWOaWz8cEBrCPX0ic= github.com/containers/ocicrypt v1.1.10/go.mod h1:YfzSSr06PTHQwSTUKqDSjish9BeW1E4HUmreluQcMd8= -github.com/containers/podman/v5 v5.1.1 h1:Rm0BdJ2gyvf0atynwHsBdHX7NVmnHSAZnyQM6bMLDww= -github.com/containers/podman/v5 v5.1.1/go.mod h1:AAzQ0cVMH8XymapWXCPbxBXah/oEn47dlT6hY4zFwtk= +github.com/containers/podman/v5 v5.1.2 h1:m/X0AfY64ud5EC8Hhy4jP1HfQ2G9LOcBnprOR13uyPk= +github.com/containers/podman/v5 v5.1.2/go.mod h1:HVlVjQbmFAFHRS9r8adDDuLmPS2uXCAeh2tibhV3lK0= github.com/containers/psgo v1.9.0 h1:eJ74jzSaCHnWt26OlKZROSyUyRcGDf+gYBdXnxrMW4g= github.com/containers/psgo v1.9.0/go.mod h1:0YoluUm43Mz2UnBIh1P+6V6NWcbpTL5uRtXyOcH0B5A= github.com/containers/storage v1.54.0 h1:xwYAlf6n9OnIlURQLLg3FYHbO74fQ/2W2N6EtQEUM4I= diff --git a/vendor/github.com/containers/image/v5/docker/docker_image.go b/vendor/github.com/containers/image/v5/docker/docker_image.go index 4c80bb2b..9741afc3 100644 --- a/vendor/github.com/containers/image/v5/docker/docker_image.go +++ b/vendor/github.com/containers/image/v5/docker/docker_image.go @@ -14,6 +14,7 @@ import ( "github.com/containers/image/v5/manifest" "github.com/containers/image/v5/types" "github.com/opencontainers/go-digest" + "github.com/sirupsen/logrus" ) // Image is a Docker-specific implementation of types.ImageCloser with a few extra methods @@ -90,6 +91,14 @@ func GetRepositoryTags(ctx context.Context, sys *types.SystemContext, ref types. } for _, tag := range tagsHolder.Tags { if _, err := reference.WithTag(dr.ref, tag); err != nil { // Ensure the tag does not contain unexpected values + // Per https://github.com/containers/skopeo/issues/2346 , unknown versions of JFrog Artifactory, + // contrary to the tag format specified in + // https://github.com/opencontainers/distribution-spec/blob/8a871c8234977df058f1a14e299fe0a673853da2/spec.md?plain=1#L160 , + // include digests in the list. + if _, err := digest.Parse(tag); err == nil { + logrus.Debugf("Ignoring invalid tag %q matching a digest format", tag) + continue + } return nil, fmt.Errorf("registry returned invalid tag %q: %w", tag, err) } tags = append(tags, tag) diff --git a/vendor/github.com/containers/image/v5/version/version.go b/vendor/github.com/containers/image/v5/version/version.go index 0b5c3bd7..9e033815 100644 --- a/vendor/github.com/containers/image/v5/version/version.go +++ b/vendor/github.com/containers/image/v5/version/version.go @@ -8,7 +8,7 @@ const ( // VersionMinor is for functionality in a backwards-compatible manner VersionMinor = 31 // VersionPatch is for backwards-compatible bug fixes - VersionPatch = 0 + VersionPatch = 1 // VersionDev indicates development branch. Releases will be empty string. VersionDev = "" diff --git a/vendor/github.com/containers/podman/v5/pkg/machine/apple/apple.go b/vendor/github.com/containers/podman/v5/pkg/machine/apple/apple.go index 93201407..6d796683 100644 --- a/vendor/github.com/containers/podman/v5/pkg/machine/apple/apple.go +++ b/vendor/github.com/containers/podman/v5/pkg/machine/apple/apple.go @@ -71,18 +71,7 @@ func GenerateSystemDFilesForVirtiofsMounts(mounts []machine.VirtIoFs) ([]ignitio unitFiles := make([]ignition.Unit, 0, len(mounts)) for _, mnt := range mounts { - // Here we are looping the mounts and for each mount, we are adding two unit files - // for virtiofs. One unit file is the mount itself and the second is to automount it - // on boot. - autoMountUnit := parser.NewUnitFile() - autoMountUnit.Add("Automount", "Where", "%s") - autoMountUnit.Add("Install", "WantedBy", "multi-user.target") - autoMountUnit.Add("Unit", "Description", "Mount virtiofs volume %s") - autoMountUnitFile, err := autoMountUnit.ToString() - if err != nil { - return nil, err - } - + // Create mount unit for each mount mountUnit := parser.NewUnitFile() mountUnit.Add("Mount", "What", "%s") mountUnit.Add("Mount", "Where", "%s") @@ -94,49 +83,57 @@ func GenerateSystemDFilesForVirtiofsMounts(mounts []machine.VirtIoFs) ([]ignitio return nil, err } - virtiofsAutomount := ignition.Unit{ - Enabled: ignition.BoolToPtr(true), - Name: fmt.Sprintf("%s.automount", parser.PathEscape(mnt.Target)), - Contents: ignition.StrToPtr(fmt.Sprintf(autoMountUnitFile, mnt.Tag, mnt.Target)), - } virtiofsMount := ignition.Unit{ Enabled: ignition.BoolToPtr(true), Name: fmt.Sprintf("%s.mount", parser.PathEscape(mnt.Target)), Contents: ignition.StrToPtr(fmt.Sprintf(mountUnitFile, mnt.Tag, mnt.Target)), } - // This "unit" simulates something like systemctl enable virtiofs-mount-prepare@ - enablePrep := ignition.Unit{ - Enabled: ignition.BoolToPtr(true), - Name: fmt.Sprintf("virtiofs-mount-prepare@%s.service", parser.PathEscape(mnt.Target)), - } - - unitFiles = append(unitFiles, virtiofsAutomount, virtiofsMount, enablePrep) + unitFiles = append(unitFiles, virtiofsMount) } - // mount prep is a way to workaround the FCOS limitation of creating directories + // This is a way to workaround the FCOS limitation of creating directories // at the rootfs / and then mounting to them. - mountPrep := parser.NewUnitFile() - mountPrep.Add("Unit", "Description", "Allow virtios to mount to /") - mountPrep.Add("Unit", "DefaultDependencies", "no") - mountPrep.Add("Unit", "ConditionPathExists", "!%f") - - mountPrep.Add("Service", "Type", "oneshot") - mountPrep.Add("Service", "ExecStartPre", "chattr -i /") - mountPrep.Add("Service", "ExecStart", "mkdir -p '%f'") - mountPrep.Add("Service", "ExecStopPost", "chattr +i /") - - mountPrep.Add("Install", "WantedBy", "remote-fs.target") - mountPrepFile, err := mountPrep.ToString() + immutableRootOff := parser.NewUnitFile() + immutableRootOff.Add("Unit", "Description", "Allow systemd to create mount points on /") + immutableRootOff.Add("Unit", "DefaultDependencies", "no") + + immutableRootOff.Add("Service", "Type", "oneshot") + immutableRootOff.Add("Service", "ExecStart", "chattr -i /") + + immutableRootOff.Add("Install", "WantedBy", "remote-fs-pre.target") + immutableRootOffFile, err := immutableRootOff.ToString() + if err != nil { + return nil, err + } + + immutableRootOffUnit := ignition.Unit{ + Contents: ignition.StrToPtr(immutableRootOffFile), + Name: "immutable-root-off.service", + Enabled: ignition.BoolToPtr(true), + } + unitFiles = append(unitFiles, immutableRootOffUnit) + + immutableRootOn := parser.NewUnitFile() + immutableRootOn.Add("Unit", "Description", "Set / back to immutable after mounts are done") + immutableRootOn.Add("Unit", "DefaultDependencies", "no") + immutableRootOn.Add("Unit", "After", "remote-fs.target") + + immutableRootOn.Add("Service", "Type", "oneshot") + immutableRootOn.Add("Service", "ExecStart", "chattr +i /") + + immutableRootOn.Add("Install", "WantedBy", "remote-fs.target") + immutableRootOnFile, err := immutableRootOn.ToString() if err != nil { return nil, err } - virtioFSChattr := ignition.Unit{ - Contents: ignition.StrToPtr(mountPrepFile), - Name: "virtiofs-mount-prepare@.service", + immutableRootOnUnit := ignition.Unit{ + Contents: ignition.StrToPtr(immutableRootOnFile), + Name: "immutable-root-on.service", + Enabled: ignition.BoolToPtr(true), } - unitFiles = append(unitFiles, virtioFSChattr) + unitFiles = append(unitFiles, immutableRootOnUnit) return unitFiles, nil } diff --git a/vendor/github.com/containers/podman/v5/pkg/machine/apple/vfkit/helper.go b/vendor/github.com/containers/podman/v5/pkg/machine/apple/vfkit/helper.go index 07b1566f..f971129b 100644 --- a/vendor/github.com/containers/podman/v5/pkg/machine/apple/vfkit/helper.go +++ b/vendor/github.com/containers/podman/v5/pkg/machine/apple/vfkit/helper.go @@ -6,7 +6,6 @@ import ( "bytes" "encoding/json" "errors" - "fmt" "io" "net/http" "time" @@ -89,33 +88,28 @@ func (vf *Helper) stateChange(newState rest.StateChange) error { } func (vf *Helper) Stop(force, wait bool) error { - waitDuration := time.Millisecond * 10 - // TODO Add ability to wait until stopped + state := rest.Stop if force { - if err := vf.stateChange(rest.HardStop); err != nil { - return err - } - } else { - if err := vf.stateChange(rest.Stop); err != nil { - return err - } + state = rest.HardStop + } + if err := vf.stateChange(state); err != nil { + return err } if !wait { return nil } - waitErr := fmt.Errorf("failed waiting for vm to stop") - // Backoff to wait on the machine shutdown - for i := 0; i < 11; i++ { + waitDuration := time.Millisecond * 500 + // Wait up to 90s then hard force off + for i := 0; i < 180; i++ { _, err := vf.getRawState() if err != nil || errors.Is(err, unix.ECONNREFUSED) { - waitErr = nil - break + return nil } - waitDuration *= 2 - logrus.Debugf("backoff wait time: %s", waitDuration.String()) time.Sleep(waitDuration) } - return waitErr + logrus.Warn("Failed to gracefully stop machine, performing hard stop") + // we waited long enough do a hard stop + return vf.stateChange(rest.HardStop) } // Helper describes the use of vfkit: cmdline and endpoint diff --git a/vendor/github.com/containers/podman/v5/pkg/machine/wsl/machine.go b/vendor/github.com/containers/podman/v5/pkg/machine/wsl/machine.go index 20afee2d..38c1a912 100644 --- a/vendor/github.com/containers/podman/v5/pkg/machine/wsl/machine.go +++ b/vendor/github.com/containers/podman/v5/pkg/machine/wsl/machine.go @@ -4,6 +4,7 @@ package wsl import ( "bufio" + "bytes" "errors" "fmt" "io" @@ -550,7 +551,10 @@ func runCmdPassThrough(name string, arg ...string) error { cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - return cmd.Run() + if err := cmd.Run(); err != nil { + return fmt.Errorf("command %s %v failed: %w", name, arg, err) + } + return nil } func runCmdPassThroughTee(out io.Writer, name string, arg ...string) error { @@ -562,7 +566,10 @@ func runCmdPassThroughTee(out io.Writer, name string, arg ...string) error { cmd.Stdin = os.Stdin cmd.Stdout = io.MultiWriter(os.Stdout, out) cmd.Stderr = io.MultiWriter(os.Stderr, out) - return cmd.Run() + if err := cmd.Run(); err != nil { + return fmt.Errorf("command %s %v failed: %w", name, arg, err) + } + return nil } func pipeCmdPassThrough(name string, input string, arg ...string) error { @@ -571,7 +578,10 @@ func pipeCmdPassThrough(name string, input string, arg ...string) error { cmd.Stdin = strings.NewReader(input) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - return cmd.Run() + if err := cmd.Run(); err != nil { + return fmt.Errorf("command %s %v failed: %w", name, arg, err) + } + return nil } func setupWslProxyEnv() (hasProxy bool) { @@ -638,8 +648,10 @@ func getAllWSLDistros(running bool) (map[string]struct{}, error) { if err != nil { return nil, err } + stderr := &bytes.Buffer{} + cmd.Stderr = stderr if err = cmd.Start(); err != nil { - return nil, err + return nil, fmt.Errorf("failed to start command %s %v: %w", cmd.Path, args, err) } all := make(map[string]struct{}) @@ -651,7 +663,10 @@ func getAllWSLDistros(running bool) (map[string]struct{}, error) { } } - _ = cmd.Wait() + err = cmd.Wait() + if err != nil { + return nil, fmt.Errorf("command %s %v failed: %w (%s)", cmd.Path, args, err, strings.TrimSpace(stderr.String())) + } return all, nil } @@ -663,6 +678,8 @@ func isSystemdRunning(dist string) (bool, error) { if err != nil { return false, err } + stderr := &bytes.Buffer{} + cmd.Stderr = stderr if err = cmd.Start(); err != nil { return false, err } @@ -676,19 +693,30 @@ func isSystemdRunning(dist string) (bool, error) { } } - _ = cmd.Wait() + err = cmd.Wait() + if err != nil { + return false, fmt.Errorf("command %s %v failed: %w (%s)", cmd.Path, cmd.Args, err, strings.TrimSpace(stderr.String())) + } return result, nil } func terminateDist(dist string) error { cmd := exec.Command(wutil.FindWSL(), "--terminate", dist) - return cmd.Run() + out, err := cmd.CombinedOutput() + if err != nil { + return fmt.Errorf("command %s %v failed: %w (%s)", cmd.Path, cmd.Args, err, strings.TrimSpace(string(out))) + } + return nil } func unregisterDist(dist string) error { cmd := exec.Command(wutil.FindWSL(), "--unregister", dist) - return cmd.Run() + out, err := cmd.CombinedOutput() + if err != nil { + return fmt.Errorf("command %s %v failed: %w (%s)", cmd.Path, cmd.Args, err, strings.TrimSpace(string(out))) + } + return nil } func isRunning(name string) (bool, error) { @@ -736,6 +764,8 @@ func getCPUs(name string) (uint64, error) { if err != nil { return 0, err } + stderr := &bytes.Buffer{} + cmd.Stderr = stderr if err = cmd.Start(); err != nil { return 0, err } @@ -744,7 +774,10 @@ func getCPUs(name string) (uint64, error) { for scanner.Scan() { result = scanner.Text() } - _ = cmd.Wait() + err = cmd.Wait() + if err != nil { + return 0, fmt.Errorf("command %s %v failed: %w (%s)", cmd.Path, cmd.Args, err, strings.TrimSpace(strings.TrimSpace(stderr.String()))) + } ret, err := strconv.Atoi(result) return uint64(ret), err @@ -761,6 +794,8 @@ func getMem(name string) (strongunits.MiB, error) { if err != nil { return 0, err } + stderr := &bytes.Buffer{} + cmd.Stderr = stderr if err = cmd.Start(); err != nil { return 0, err } @@ -783,7 +818,10 @@ func getMem(name string) (strongunits.MiB, error) { break } } - _ = cmd.Wait() + err = cmd.Wait() + if err != nil { + return 0, fmt.Errorf("command %s %v failed: %w (%s)", cmd.Path, cmd.Args, err, strings.TrimSpace(stderr.String())) + } return strongunits.MiB(total - available), err } diff --git a/vendor/github.com/containers/podman/v5/pkg/machine/wsl/stubber.go b/vendor/github.com/containers/podman/v5/pkg/machine/wsl/stubber.go index 433f05ee..3a79f095 100644 --- a/vendor/github.com/containers/podman/v5/pkg/machine/wsl/stubber.go +++ b/vendor/github.com/containers/podman/v5/pkg/machine/wsl/stubber.go @@ -3,6 +3,7 @@ package wsl import ( + "bytes" "errors" "fmt" "os" @@ -110,7 +111,7 @@ func (w WSLStubber) Remove(mc *vmconfigs.MachineConfig) ([]string, func() error, // of the vm wslRemoveFunc := func() error { if err := runCmdPassThrough(wutil.FindWSL(), "--unregister", env.WithPodmanPrefix(mc.Name)); err != nil { - logrus.Error(err) + return err } return nil } @@ -251,17 +252,21 @@ func (w WSLStubber) StopVM(mc *vmconfigs.MachineConfig, hardStop bool) error { cmd := exec.Command(wutil.FindWSL(), "-u", "root", "-d", dist, "sh") cmd.Stdin = strings.NewReader(waitTerm) + out := &bytes.Buffer{} + cmd.Stderr = out + cmd.Stdout = out + if err = cmd.Start(); err != nil { return fmt.Errorf("executing wait command: %w", err) } exitCmd := exec.Command(wutil.FindWSL(), "-u", "root", "-d", dist, "/usr/local/bin/enterns", "systemctl", "exit", "0") if err = exitCmd.Run(); err != nil { - return fmt.Errorf("stopping sysd: %w", err) + return fmt.Errorf("stopping systemd: %w", err) } if err = cmd.Wait(); err != nil { - return err + logrus.Warnf("Failed to wait for systemd to exit: (%s)", strings.TrimSpace(out.String())) } return terminateDist(dist) diff --git a/vendor/github.com/containers/podman/v5/pkg/machine/wsl/wutil/wutil.go b/vendor/github.com/containers/podman/v5/pkg/machine/wsl/wutil/wutil.go index 3f613ab0..bc07ffa2 100644 --- a/vendor/github.com/containers/podman/v5/pkg/machine/wsl/wutil/wutil.go +++ b/vendor/github.com/containers/podman/v5/pkg/machine/wsl/wutil/wutil.go @@ -4,6 +4,7 @@ package wutil import ( "bufio" + "fmt" "io" "os" "os/exec" @@ -74,7 +75,10 @@ func SilentExec(command string, args ...string) error { cmd.SysProcAttr = &syscall.SysProcAttr{CreationFlags: 0x08000000} cmd.Stdout = nil cmd.Stderr = nil - return cmd.Run() + if err := cmd.Run(); err != nil { + return fmt.Errorf("command %s %v failed: %w", command, args, err) + } + return nil } func SilentExecCmd(command string, args ...string) *exec.Cmd { diff --git a/vendor/github.com/containers/podman/v5/version/rawversion/version.go b/vendor/github.com/containers/podman/v5/version/rawversion/version.go index 9152f480..860e5bec 100644 --- a/vendor/github.com/containers/podman/v5/version/rawversion/version.go +++ b/vendor/github.com/containers/podman/v5/version/rawversion/version.go @@ -7,4 +7,4 @@ package rawversion // // NOTE: remember to bump the version at the top of the top-level README.md // file when this is bumped. -const RawVersion = "5.1.1" +const RawVersion = "5.1.2" diff --git a/vendor/modules.txt b/vendor/modules.txt index 24bbf8a2..8e54ca06 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -169,7 +169,7 @@ github.com/containers/common/version # github.com/containers/gvisor-tap-vsock v0.7.4-0.20240408151405-d744d71db363 ## explicit; go 1.20 github.com/containers/gvisor-tap-vsock/pkg/types -# github.com/containers/image/v5 v5.31.0 +# github.com/containers/image/v5 v5.31.1 ## explicit; go 1.21 github.com/containers/image/v5/copy github.com/containers/image/v5/directory @@ -260,7 +260,7 @@ github.com/containers/ocicrypt/keywrap/pkcs7 github.com/containers/ocicrypt/spec github.com/containers/ocicrypt/utils github.com/containers/ocicrypt/utils/keyprovider -# github.com/containers/podman/v5 v5.1.1 +# github.com/containers/podman/v5 v5.1.2 ## explicit; go 1.21 github.com/containers/podman/v5/libpod/define github.com/containers/podman/v5/pkg/errorhandling