Skip to content

Conversation

@kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Aug 4, 2021

This is a backport of #3120 to release-1.0 branch,
fixing rare but critical issue #3119. Update: this is not critical -- the effect is we lost one
debug log entry, and get a weird error in runc logs.


As reported in issue #3119, there is a race in nsexec logging
that can lead to garbled json received by log forwarder, which
complains about it with a "failed to decode" error.

This happens because dprintf (used since the very beginning of nsexec
logging introduced in commit ba3cabf) relies on multiple write(2)
calls, and with additional logging added by 64bb59f (appeared in rc94)
a race is possible between runc init parent and its children.

The fix is to prepare a string and write it using a single call to
write(2).

Signed-off-by: Kir Kolyshkin [email protected]
(cherry picked from commit fb6ba04)
Signed-off-by: Kir Kolyshkin [email protected]

@kolyshkin kolyshkin added kind/bug area/logging backport/1.0-pr A backport PR to release-1.0 labels Aug 4, 2021
@kolyshkin kolyshkin added this to the 1.0.2 milestone Aug 4, 2021
@kolyshkin kolyshkin changed the title [1.0] fix logging race in nsexec [1.0] fix logging race in nsexec (regression in rc94) Aug 4, 2021
AkihiroSuda
AkihiroSuda previously approved these changes Aug 5, 2021
@kolyshkin kolyshkin requested a review from cyphar August 5, 2021 15:26
@AkihiroSuda
Copy link
Member

Let me mark this as a draft until getting #3120 merged

@AkihiroSuda AkihiroSuda marked this pull request as draft August 11, 2021 05:41
As reported in issue 3119, there is a race in nsexec logging
that can lead to garbled json received by log forwarder, which
complains about it with a "failed to decode" error.

This happens because dprintf (used since the very beginning of nsexec
logging introduced in commit ba3cabf) relies on multiple write(2)
calls, and with additional logging added by 64bb59f a race is
possible between runc init parent and its children.

The fix is to prepare a string and write it using a single call to
write(2).

[v2: NULLify json on error from asprintf]

Signed-off-by: Kir Kolyshkin <[email protected]>
(cherry picked from commit 2bab4a5)
Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin
Copy link
Contributor Author

#3120 is merged; no longer a draft.

@kolyshkin kolyshkin marked this pull request as ready for review August 12, 2021 00:04
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