diff --git a/cmd/urunc/run.go b/cmd/urunc/run.go index 345f5728..cf114c49 100644 --- a/cmd/urunc/run.go +++ b/cmd/urunc/run.go @@ -16,7 +16,6 @@ package main import ( "context" - "fmt" "os" "github.com/sirupsen/logrus" @@ -75,6 +74,6 @@ var runCommand = &cli.Command{ if err := startUnikontainer(cmd); err != nil { return err } - return fmt.Errorf("urunc run failed: %w", nil) + return nil }, } diff --git a/pkg/network/network.go b/pkg/network/network.go index 187b122c..eee2f834 100644 --- a/pkg/network/network.go +++ b/pkg/network/network.go @@ -387,7 +387,7 @@ func deleteAllTCFilters(device netlink.Link) error { parent := uint32(netlink.HANDLE_ROOT) tapFilters, err := netlink.FilterList(device, parent) if err != nil { - return nil + return err } allFilters = append(allFilters, tapFilters...) device, err = discoverContainerIface() diff --git a/pkg/unikontainers/rootfs.go b/pkg/unikontainers/rootfs.go index 797f0cb6..a416ceab 100644 --- a/pkg/unikontainers/rootfs.go +++ b/pkg/unikontainers/rootfs.go @@ -446,16 +446,16 @@ func prepareMonRootfs(monRootfs string, monitorPath string, monitorDataPath stri // Create /dev/console file consolePath := filepath.Join(monRootfs, "/dev/console") - consoleFile, err := os.Create(consolePath) - if err != nil && !os.IsExist(err) { + consoleFile, err := os.OpenFile(consolePath, os.O_CREATE|os.O_WRONLY, 0o666) + if err != nil { return fmt.Errorf("failed to create /dev/console: %w", err) } + defer consoleFile.Close() + // Ensure correct permissions if err := consoleFile.Chmod(0o666); err != nil { - consoleFile.Close() return fmt.Errorf("failed to chmod /dev/console: %w", err) } - consoleFile.Close() return nil } diff --git a/pkg/unikontainers/unikontainers.go b/pkg/unikontainers/unikontainers.go index 99d4749a..72006710 100644 --- a/pkg/unikontainers/unikontainers.go +++ b/pkg/unikontainers/unikontainers.go @@ -443,7 +443,8 @@ func (u *Unikontainer) Exec(metrics m.Writer) error { // unikernel err = unikernel.Init(unikernelParams) - if err == unikernels.ErrUndefinedVersion || err == unikernels.ErrVersionParsing { + if errors.Is(err, unikernels.ErrUndefinedVersion) || + errors.Is(err, unikernels.ErrVersionParsing) { uniklog.WithError(err).Error("an error occurred while initializing the unikernel") } else if err != nil { return err @@ -1146,7 +1147,7 @@ func (u *Unikontainer) SendMessage(message IPCMessage) error { // isRunning returns true if the PID is alive or hedge.ListVMs returns our containerID func (u *Unikontainer) isRunning() bool { - vmmType := hypervisors.VmmType(u.State.Annotations[annotType]) + vmmType := hypervisors.VmmType(u.State.Annotations[annotHypervisor]) if vmmType != hypervisors.HedgeVmm { return syscall.Kill(u.State.Pid, syscall.Signal(0)) == nil } diff --git a/pkg/unikontainers/utils.go b/pkg/unikontainers/utils.go index ff304015..4ec29cd7 100644 --- a/pkg/unikontainers/utils.go +++ b/pkg/unikontainers/utils.go @@ -57,7 +57,6 @@ func getInitPid(filePath string) (float64, error) { decoder := json.NewDecoder(file) if err := decoder.Decode(&jsonData); err != nil { return 0, nil - } // Extract the specific value "init_process_pid"