Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use custom log writer for stdout/err in supervisor #2674

Merged
merged 1 commit into from
Feb 6, 2023

Conversation

twz123
Copy link
Member

@twz123 twz123 commented Feb 1, 2023

Description

The io.Writer implementation provided by logrus refuses to write lines that are longer than 64k. An error is logged and the log pipe is closed. This will cause the stdout or stderr of the supervised process to be broken ("broken pipe"). Depending on the supervised process, the result may vary. At a minimum, k0s will no longer log anything from the affected processes. Some processes (e.g. the kubelet) will terminate themselves when trying to use stdout/stderr, resulting in a restart.

Use a custom io.Writer instead. It will do pretty much the same thing as logrus's one, but it will chunk long lines into multiple log statements.

See:

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Manual test
  • Auto test added

Checklist:

  • My code follows the style guidelines of this project
  • My commit messages are signed-off
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@twz123 twz123 added the bug Something isn't working label Feb 1, 2023
@twz123 twz123 force-pushed the supervisor-logging branch 2 times, most recently from 6d8cd90 to 8da28f9 Compare February 2, 2023 08:48
@twz123 twz123 force-pushed the supervisor-logging branch from 8da28f9 to b4f2226 Compare February 2, 2023 10:50
@twz123 twz123 marked this pull request as ready for review February 2, 2023 12:27
@twz123 twz123 requested a review from a team as a code owner February 2, 2023 12:27
@twz123 twz123 linked an issue Feb 3, 2023 that may be closed by this pull request
4 tasks
@twz123 twz123 force-pushed the supervisor-logging branch from b4f2226 to fa89caf Compare February 3, 2023 11:33
juanluisvaladas
juanluisvaladas previously approved these changes Feb 3, 2023
Copy link
Contributor

@juanluisvaladas juanluisvaladas left a comment

Choose a reason for hiding this comment

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

LGTM.

The io.Writer implementation provided by logrus refuses to write
lines that are longer than 64k. An error is logged and the log pipe is
closed. This will cause the stdout or stderr of the supervised process
to be broken ("broken pipe"). Depending on the supervised process, the
result may vary. At a minimum, k0s will no longer log anything from the
affected processes. Some processes (e.g. the kubelet) will terminate
themselves when trying to use stdout/stderr, resulting in a restart.

Use a custom io.Writer instead. It will do pretty much the same thing as
logrus's one, but it will chunk long lines into multiple log statements.

Signed-off-by: Tom Wieczorek <twieczorek@mirantis.com>
@twz123 twz123 force-pushed the supervisor-logging branch from fa89caf to 46f816f Compare February 3, 2023 15:44
@twz123 twz123 added the backport/release-1.26 PR that needs to be backported/cherrypicked to release-1.26 branch label Feb 3, 2023
Copy link
Contributor

@juanluisvaladas juanluisvaladas left a comment

Choose a reason for hiding this comment

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

LGTM.

@twz123 twz123 merged commit a3606ca into k0sproject:main Feb 6, 2023
@twz123 twz123 deleted the supervisor-logging branch February 6, 2023 11:17
@k0s-bot
Copy link

k0s-bot commented Feb 6, 2023

Successfully created backport PR for release-1.26:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/release-1.26 PR that needs to be backported/cherrypicked to release-1.26 branch bug Something isn't working security fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can not start after restart k0scontroler, bufio.Scanner: token too long
4 participants