stage1: use --link-journal=host instead of try-host

Since we check if we're running systemd before appending --link-journal
to systemd-nspawn we can use host instead of try-host.

This allows connecting a pod's journal to the host's journal with
systemd version <219.
This commit is contained in:
Iago López Galeiras
2015-05-26 16:54:00 +02:00
parent 76ed159048
commit 969a57c669
+13 -13
View File
@@ -218,23 +218,23 @@ func getArgsEnv(p *Pod, flavor, systemdVersion string, debug bool) ([]string, []
} else {
args = append(args, fmt.Sprintf("--register=false"))
}
if util.IsRunningSystemd() {
// we write /etc/machine-id here because systemd-nspawn needs it to link
// the container's journal to the host
mPath := filepath.Join(common.Stage1RootfsPath(p.Root), "etc", "machine-id")
mId := strings.Replace(p.UUID.String(), "-", "", -1)
if err := ioutil.WriteFile(mPath, []byte(mId), 0644); err != nil {
log.Fatalf("error writing /etc/machine-id: %v\n", err)
}
args = append(args, "--link-journal=try-host")
}
default:
return nil, nil, fmt.Errorf("unrecognized stage1 flavor: %q", flavor)
}
if util.IsRunningSystemd() {
// we write /etc/machine-id here because systemd-nspawn needs it to link
// the container's journal to the host
mPath := filepath.Join(common.Stage1RootfsPath(p.Root), "etc", "machine-id")
mId := strings.Replace(p.UUID.String(), "-", "", -1)
if err := ioutil.WriteFile(mPath, []byte(mId), 0644); err != nil {
log.Fatalf("error writing /etc/machine-id: %v\n", err)
}
args = append(args, "--link-journal=host")
}
if !debug {
args = append(args, "--quiet") // silence most nspawn output (log_warning is currently not covered by this)
}