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

Automatically execute podman-remote if vars set #4981

Closed
wants to merge 1 commit into from
Closed
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
31 changes: 31 additions & 0 deletions cmd/podman/main_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io/ioutil"
"log/syslog"
"os"
"os/exec"
"runtime/pprof"
"strconv"
"strings"
Expand All @@ -31,7 +32,37 @@ import (

const remote = false

func runRemote(path string, args ...string) (int, error) {
c := exec.Command(path, args...)
c.Stdin = os.Stdin
c.Stdout = os.Stdout
c.Stderr = os.Stderr
if err := c.Run(); err != nil {
if exitError, ok := err.(*exec.ExitError); ok {
waitStatus := exitError.Sys().(syscall.WaitStatus)
return waitStatus.ExitStatus(), nil
}
return 1, err
}
return 0, nil
}

func init() {
host := os.Getenv("PODMAN_HOST")
bridge := os.Getenv("PODMAN_VARLINK_BRIDGE")
address := os.Getenv("PODMAN_VARLINK_ADDRESS")
if host != "" || bridge != "" || address != "" {
program := "podman-remote"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to have a debug statement in here to just say "Attempting to connect to remote Podman" or some such. I could see it as being potentially helpful in a debugging situation later on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So something like a logrus.Debugf with the command being executed perhaps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried adding logging, but it doesn't show up in the logs (at the debug level)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomSweeneyRedHat : apparently this (init) happens before logging has been set up

That is, we are still running with the default log level of InfoLevel (hiding the debug logging)

if path, err := exec.LookPath(program); err == nil {
if rc, err := runRemote(path, os.Args[1:]...); err == nil {
os.Exit(rc)
} else {
fmt.Fprintf(os.Stderr, "Error running %s: %v\n", path, err)
}
} else {
fmt.Fprintf(os.Stderr, "Error finding %s: %v\n", program, err)
}
}
cgroupManager := define.SystemdCgroupsManager
cgroupHelp := `Cgroup manager to use ("cgroupfs"|"systemd")`
cgroupv2, _ := cgroups.IsCgroup2UnifiedMode()
Expand Down