Skip to content

Conversation

fahedouch
Copy link
Member

enhance #1039 with journald log driver

@fahedouch fahedouch force-pushed the implement-journald-logging-driver branch 2 times, most recently from 9edae9d to dfb7419 Compare May 13, 2022 16:56
found := 0
check := func(log poll.LogT) poll.Result {
c, err := jr.Read(b)
assert.NilError(t, err)
Copy link
Member

Choose a reason for hiding this comment

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

Can we verify the content? How is it formatted?

Copy link
Member Author

@fahedouch fahedouch May 17, 2022

Choose a reason for hiding this comment

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

fixed, our scope is to check that the tag is well formated and this is guaranteed with SYSLOG IDENTIFIER. Other log part are handled in the journald scope

@fahedouch fahedouch marked this pull request as draft May 17, 2022 16:03
@fahedouch fahedouch force-pushed the implement-journald-logging-driver branch 4 times, most recently from af23936 to 0372a81 Compare May 17, 2022 17:09
@fahedouch fahedouch marked this pull request as ready for review May 17, 2022 17:10
@fahedouch fahedouch requested a review from AkihiroSuda May 17, 2022 17:11
@fahedouch fahedouch changed the title [WIP] Implement journald logging driver Implement journald logging driver May 17, 2022
@fahedouch fahedouch force-pushed the implement-journald-logging-driver branch 2 times, most recently from 1bb2a52 to 94c079b Compare May 17, 2022 17:14
@AkihiroSuda AkihiroSuda added this to the v0.21.0 (tentative) milestone May 17, 2022
@fahedouch fahedouch force-pushed the implement-journald-logging-driver branch 3 times, most recently from 9f3bf9b to 640e0de Compare May 19, 2022 21:36
@AkihiroSuda AkihiroSuda removed this from the v0.20.1 milestone May 21, 2022
inspectedContainer := base.InspectContainer(containerName)
found := 0
check := func(log poll.LogT) poll.Result {
res := icmd.RunCmd(icmd.Command("journalctl", "--no-pager", fmt.Sprintf("SYSLOG_IDENTIFIER=%s", inspectedContainer.ID[:12])))
Copy link
Member

@AkihiroSuda AkihiroSuda May 24, 2022

Choose a reason for hiding this comment

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

needs something like --since <timestamp>, otherwise journalctl produces a huge hog

@AkihiroSuda
Copy link
Member

Can we implement nerdctl logs for journald, or at least print a human-readable error to clarify that the feature is not implemented yet?

@fahedouch fahedouch marked this pull request as draft May 25, 2022 12:09
@fahedouch fahedouch force-pushed the implement-journald-logging-driver branch 2 times, most recently from 3ddd2ec to 759713d Compare May 25, 2022 15:30
@fahedouch fahedouch requested a review from AkihiroSuda May 25, 2022 15:30
@fahedouch fahedouch marked this pull request as ready for review May 25, 2022 15:30
@fahedouch fahedouch force-pushed the implement-journald-logging-driver branch 3 times, most recently from 5a78ae8 to 1b36608 Compare May 27, 2022 18:33
README.md Outdated
@@ -694,7 +695,9 @@ Usage: `nerdctl logs [OPTIONS] CONTAINER`
Flags:
- :whale: `--f, --follow`: Follow log output
- :whale: `--since`: Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)
- for journald log driver logs since relative should be in this format `42 minutes ago`
Copy link
Member

Choose a reason for hiding this comment

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

Can we just use the same format?
If difficult this flag can be implemented in a separate PR.

return jsonfile.Decode(os.Stdout, os.Stderr, reader, timestamps, since, until, logsEOFChan)
case "journald":
var journalctlArgs []string
journalctlArgs = append(journalctlArgs, fmt.Sprintf("SYSLOG_IDENTIFIER=%s", found.Container.ID()[:12]))
Copy link
Member

Choose a reason for hiding this comment

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

Please use a const or at least add a comment line for 12

journalctlArgs = append(journalctlArgs, "-f")
}
if since != "" {
journalctlArgs = append(journalctlArgs, "--since", since)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
journalctlArgs = append(journalctlArgs, "--since", since)
journalctlArgs = append(journalctlArgs, "--since", since + " ago")

}
return jsonfile.Decode(os.Stdout, os.Stderr, reader, timestamps, since, until, logsEOFChan)
case "journald":
var journalctlArgs []string
Copy link
Member

Choose a reason for hiding this comment

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

Please add --output=cat to eliminate extra header


var syslogIdentifier string
if _, ok := journaldLogger.Opts[Tag]; !ok {
syslogIdentifier = config.ID[:12]
Copy link
Member

Choose a reason for hiding this comment

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

Please add a const or at least add a comment line for this magic number

@fahedouch fahedouch force-pushed the implement-journald-logging-driver branch 4 times, most recently from 81be1dd to 16f8c5c Compare May 31, 2022 15:24
Signed-off-by: Fahed DORGAA <fahed.dorgaa@gmail.com>
@fahedouch fahedouch force-pushed the implement-journald-logging-driver branch from 16f8c5c to dd8a0ff Compare May 31, 2022 15:25
@fahedouch fahedouch requested a review from AkihiroSuda May 31, 2022 15:25
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit 3cc456a into containerd:master Jun 2, 2022
@AkihiroSuda AkihiroSuda added this to the v0.20.1 milestone Jun 2, 2022
@fahedouch fahedouch mentioned this pull request Jul 12, 2022
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants