Skip to content
This repository has been archived by the owner on Feb 24, 2020. It is now read-only.

stage1/init: link pod's journal in kvm flavor #2934

Merged
merged 4 commits into from
Jul 19, 2016

Conversation

iaguis
Copy link
Member

@iaguis iaguis commented Jul 14, 2016

In nspawn flavors, nspawn creates a symlink from /var/log/journal/${machine-id}
to the pod's journal directory. In kvm we need to do the link ourselves.

Logs can be inspected like this:

$ journalctl -m _MACHINE_ID=${MACHINE_ID}

where MACHINE_ID is the pod UUID without the dashes.

Fixes #2798

@s-urbaniak
Copy link
Contributor

LGTM modulo tests

@iaguis
Copy link
Member Author

iaguis commented Jul 14, 2016

Added a functional test.

@s-urbaniak
Copy link
Contributor

Semafailure seems unrelated?!

panic: Failed to remove temporary data directory "/tmp/datadir-247751001": remove /tmp/datadir-247751001/pods/run/53d7f847-5051-4da1-ae23-a20b34c5a21a/stage1/rootfs/sys: device or resource busy

but Jenkins seems to be related:

17:19:47 === RUN   TestJournalLink
17:19:55 --- FAIL: TestJournalLink (7.97s)
17:19:55    rkt_tests.go:115: Running command: /home/admin/workspace/rkt-github-ci/os_type/debian-8/stage1_flavor/coreos/builds/build-rkt-coreos/build-rkt-1.10.0+git/tmp/functional/rkt --dir=/tmp/datadir-806869495 --local-config=/tmp/localdir-380774634 --system-config=/tmp/systemdir-422192961 --user-config=/tmp/userdir-821941164 prepare --insecure-options=image /home/admin/workspace/rkt-github-ci/os_type/debian-8/stage1_flavor/coreos/builds/build-rkt-coreos/build-rkt-1.10.0+git/tmp/functional/rkt-inspect.aci
17:19:55    rkt_tests.go:115: Running command: /home/admin/workspace/rkt-github-ci/os_type/debian-8/stage1_flavor/coreos/builds/build-rkt-coreos/build-rkt-1.10.0+git/tmp/functional/rkt --dir=/tmp/datadir-806869495 --local-config=/tmp/localdir-380774634 --system-config=/tmp/systemdir-422192961 --user-config=/tmp/userdir-821941164 run-prepared 62f06f1a-5a7a-4b00-9f0b-c5eddc1f12ff
17:19:55    rkt_journal_test.go:51: failed to read journal link "/var/log/journal/62f06f1a5a7a4b009f0bc5eddc1f12ff"

@iaguis
Copy link
Member Author

iaguis commented Jul 15, 2016

It seems I broke something, I'll look into it.

@iaguis
Copy link
Member Author

iaguis commented Jul 15, 2016

I was actually expecting the debian failure. It doesn't have persistent journaling enabled, so there's no /var/log/journal.

I'll see if nspawn does a link from /run/log/journal and imitate that behavior in kvm. I'll also fix the test if that's the case.

@iaguis
Copy link
Member Author

iaguis commented Jul 15, 2016

It seems systemd-nspawn doesn't link the logs if persistent journaling is not enabled.

I'll skip the test if /var/log/journal doesn't exist and I'll create it in the jenkins debian machine.

@iaguis iaguis force-pushed the iaguis/fix-journal-kvm branch 3 times, most recently from 83f19bc to ddee40c Compare July 15, 2016 14:20
@iaguis
Copy link
Member Author

iaguis commented Jul 15, 2016

Semaphore fails on master too. It seems #2888 breaks kvm.

@iaguis
Copy link
Member Author

iaguis commented Jul 18, 2016

PTAL?

@@ -254,6 +260,7 @@ func getArgsEnv(p *stage1commontypes.Pod, flavor string, debug bool, n *networki
"noreplace-smp",
"systemd.default_standard_error=journal+console",
"systemd.default_standard_output=journal+console",
"systemd.machine_id=" + machineID,
Copy link
Member

Choose a reason for hiding this comment

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

Just FYI, it will conflict with #2684

/cc @jjlakis

Copy link
Member Author

@iaguis iaguis Jul 18, 2016

Choose a reason for hiding this comment

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

I can rebase/merge this after #2684

@s-urbaniak
Copy link
Contributor

LGTM

@jjlakis
Copy link
Contributor

jjlakis commented Jul 18, 2016

@iaguis Thanks!

So the kvm flavor has the right machine ID (taken from the pod UUID).
@iaguis
Copy link
Member Author

iaguis commented Jul 18, 2016

Rebased.

In nspawn flavors, nspawn creates a symlink from
/var/log/journal/${machine-id} to the pod's journal directory. In kvm we
need to do the link ourselves.

Logs can be inspected like this:

```
$ journalctl -m _MACHINE_ID=${MACHINE_ID}
```

where MACHINE_ID is the pod UUID without the dashes.
If we don't pass --debug. We do this on the nspawn flavors.
@euank
Copy link
Member

euank commented Jul 19, 2016

Semaphore has

--- SKIP: TestJournalLink (0.00s)
    rkt_journal_test.go:34: Systemd is not running on the host.

and afaict the kvm flavor tests aren't run anywhere else. Codewise, LGTM, but it would be nice if we had a testing environment for this to avoid regressions.

@jjlakis
Copy link
Contributor

jjlakis commented Jul 19, 2016

PTAL @coreos/rkt-kvm-maintainers

@iaguis
Copy link
Member Author

iaguis commented Jul 19, 2016

it would be nice if we had a testing environment for this to avoid regressions.

So true. This is on my local machine:

        rkt 1.10.0+gitd16776a

        stage1 setup

        type:                                   'flavor'
        default stage1 location:                ''
        default stage1 images directory:        '/usr/local/lib/rkt/stage1-images'

        built stage1 flavors:                   'host,coreos,fly,kvm'
        default stage1 flavor:                  'kvm'
        implied default stage1 name:            'coreos.com/rkt/stage1-kvm'
        implied default stage1 version:         '1.10.0+gitd16776a'

        coreos/kvm flavor specific build parameters

        local CoreOS PXE image path:            ''
        local CoreOS PXE image systemd version: ''
        stage1 CoreOS board:                    'amd64-usr'

        kvm flavor specific build parameters

        hypervisor:                             'lkvm'

        other build parameters

        functional tests enabled:               'yes'
        features:                               '-TPM +SDJOURNAL'
        ACI arch:                               'amd64'
        go version:                             '1.6.2'
        go arch:                                'amd64'
> make functional-check GO_TEST_FUNC_ARGS='-run TestJournalLink' BUILDDIR=build-rkt
  GO TEST      github.com/coreos/rkt/tests
=== RUN   TestJournalLink
--- PASS: TestJournalLink (4.52s)
    rkt_tests.go:115: Running command: /home/iaguis/work/coreos/go/src/github.com/coreos/rkt/build-rkt/tmp/functional/rkt --dir=/tmp/datadir-116942572 --local-config=/tmp/localdir-009774427 --system-config=/tmp/systemdir-829923070 --user-config=/tmp/userdir-020845125 prepare --insecure-options=image /home/iaguis/work/coreos/go/src/github.com/coreos/rkt/build-rkt/tmp/functional/rkt-inspect.aci
    rkt_tests.go:115: Running command: /home/iaguis/work/coreos/go/src/github.com/coreos/rkt/build-rkt/tmp/functional/rkt --dir=/tmp/datadir-116942572 --local-config=/tmp/localdir-009774427 --system-config=/tmp/systemdir-829923070 --user-config=/tmp/userdir-020845125 run-prepared 6c5077ed-c5d6-4594-ba97-8883b9b1ad3b
PASS
ok      github.com/coreos/rkt/tests 4.529s

@iaguis iaguis merged commit fca22ab into rkt:master Jul 19, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants