From 969a57c669977a002db6f7c8562a0fb10ad192b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iago=20L=C3=B3pez=20Galeiras?= Date: Tue, 26 May 2015 16:54:00 +0200 Subject: [PATCH] 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. --- stage1/init/init.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/stage1/init/init.go b/stage1/init/init.go index 4038172..caf3c90 100644 --- a/stage1/init/init.go +++ b/stage1/init/init.go @@ -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) }