Skip to content

Add shim log pipe for log forwarding to the daemon#2528

Merged
dmcgowan merged 1 commit intocontainerd:masterfrom
crosbymichael:shim-debug
Aug 7, 2018
Merged

Add shim log pipe for log forwarding to the daemon#2528
dmcgowan merged 1 commit intocontainerd:masterfrom
crosbymichael:shim-debug

Conversation

@crosbymichael
Copy link
Copy Markdown
Member

@crosbymichael crosbymichael commented Aug 6, 2018

A fifo on unix or named pipe on Windows will be provided to the shim.
It can be located inside the cwd of the shim named "log".
The shims can use the existing github.com/containerd/containerd/log package to log debug messages.
Messages will automatically be output in the containerd's daemon logs with the correct fiels and runtime set.

Using a pipe allows containerd to reconnect after a reboot and collect logs from shims.

Signed-off-by: Michael Crosby [email protected]

@crosbymichael
Copy link
Copy Markdown
Member Author

@jterry75 @ehazlett can you two review this change?

Comment thread runtime/v2/README.md Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NIT: fields

Comment thread runtime/v2/shim_windows.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doesn't this leak the listener?

Comment thread runtime/v2/shim/shim_windows.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here. This leaks the listener right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would also be more useful I think to name it like: util_windows.go so it can be predicted?

fmt.Sprintf("\\\\.\\pipe\\containerd-shim-%s-%s-log-pipe", ns, id)

Copy link
Copy Markdown
Contributor

@jterry75 jterry75 left a comment

Choose a reason for hiding this comment

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

Minor feedback otherwise looks pretty good

@codecov-io
Copy link
Copy Markdown

codecov-io commented Aug 6, 2018

Codecov Report

Merging #2528 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2528   +/-   ##
=======================================
  Coverage   45.05%   45.05%           
=======================================
  Files          94       94           
  Lines        9796     9796           
=======================================
  Hits         4414     4414           
  Misses       4662     4662           
  Partials      720      720
Flag Coverage Δ
#linux 49.08% <ø> (ø) ⬆️
#windows 41.59% <ø> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4fb9230...6ba4ddf. Read the comment docs.

@crosbymichael
Copy link
Copy Markdown
Member Author

@jterry75 updated based on your feedback

@ehazlett
Copy link
Copy Markdown
Member

ehazlett commented Aug 7, 2018

LGTM

Comment thread runtime/v2/shim/shim_windows.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh I didn't understand this correctly the first time. I think you want this side to be the winio.DialPipe side for the client connection. The connection is then an io.Writer and the listener is part of the v2/shim.go

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What happens if the listener and other end of the pipe goes away then comes back, this connection connection is still maintained?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Its a good question. I think that we will have to create some sort of reconnect logic for Windows if the containerd daemon goes down when it reconnects to shims they will re-open the log connection but this is a good start.

@jterry75
Copy link
Copy Markdown
Contributor

jterry75 commented Aug 7, 2018

Ok 1 last comment and I think this is good

A fifo on unix or named pipe on Windows will be provided to the shim.
It can be located inside the `cwd` of the shim named "log".
The shims can use the existing `github.com/containerd/containerd/log` package to log debug messages.
Messages will automatically be output in the containerd's daemon logs with the correct fiels and runtime set.

Signed-off-by: Michael Crosby <[email protected]>
@jterry75
Copy link
Copy Markdown
Contributor

jterry75 commented Aug 7, 2018

LGTM

@dmcgowan
Copy link
Copy Markdown
Member

dmcgowan commented Aug 7, 2018

Sounds like there is some follow up to make sure this is working on Windows when containerd restarts, for now though LGTM

@dmcgowan dmcgowan merged commit 1ba4aa0 into containerd:master Aug 7, 2018
@crosbymichael crosbymichael deleted the shim-debug branch August 8, 2018 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants