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

KEP 3288: Split stdout and stderr log stream #3289

Merged
merged 6 commits into from
Jun 15, 2022

Conversation

knight42
Copy link
Member

@knight42 knight42 commented May 1, 2022

Signed-off-by: Jian Zeng anonymousknight96@gmail.com

  • One-line PR description: Split stdout and stderr log stream of container
  • Other comments:

Rendered

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory sig/node Categorizes an issue or PR as relevant to SIG Node. labels May 1, 2022
@knight42
Copy link
Member Author

/cc @mrunalp

Hi! Please take a look when you are available 🚀

@k8s-ci-robot k8s-ci-robot requested a review from mrunalp May 12, 2022 02:58
Comment on lines +805 to +786
<!--
What other approaches did you consider, and why did you rule them out? These do
not need to be as detailed as the proposal, but should include enough
information to express the idea and why it was not acceptable.
-->
Copy link
Contributor

Choose a reason for hiding this comment

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

I presume “just one multiplexed log stream” is the only alternative we could consider here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Did you mean we return the combined stdout and stderr and let the client somehow filter out the unwanted stream?

Copy link
Contributor

Choose a reason for hiding this comment

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

Another option could be kubectl log directing these 2 streams to stdout/stderr. The downside of that approach would be distinguishing the errors from kubectl log vs. what's coming from the container process.

Copy link
Contributor

Choose a reason for hiding this comment

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

kubectl log directing these 2 streams to stdout/stderr

That actually sounds like something that'd be useful to offer, and doesn't conflict with this KEP.

return the combined stdout and stderr and let the client somehow filter out the unwanted stream?

If an API client got a stream of CRI-format logs, the demultiplexing could be client side.

To be clear, I wouldn't implement that. We should list the alternative and then briefly explain why the approach we've selected is better.

Copy link
Member

Choose a reason for hiding this comment

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

+1 on listing alternative explicitly

Copy link
Member Author

Choose a reason for hiding this comment

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

I have updated the Alternatives section to describe this alternative approach.

@dchen1107
Copy link
Member

Thanks for making the proposal. Thanks @mrunalp to bring this up to today's SIG Node. We quickly discussed it at the meeting earlier, and will track it with 1.25 release. Thanks!

...
// If set, return the given log stream of the container.
// Otherwise, the combined stdout and stderr from the container is returned.
// Available values are: "stdout", "stderr", "" (empty string).
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest to have "all" as an available value so it can be set explicitly to all - it will be more user friendly than explicit empty string or omitted parameter.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am up for that and I have added "all" as available value.

// If set, return the given log stream of the container.
// Otherwise, the combined stdout and stderr from the container is returned.
// Available values are: "stdout", "stderr", "" (empty string).
Stream string
Copy link
Member

Choose a reason for hiding this comment

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

is it a string for implementation simplicity or expect any other values to be added later? Perhaps a custom type with three constants instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Perhaps a custom type with three constants instead?

Yeah I think this is better, I have updated the proposal.

}
```

### Changes of kubelet
Copy link
Member

Choose a reason for hiding this comment

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

will there be any issues with TailLines log option? What will be the behavior of this log option when only one stream was specified? (I haven't looked deep in the code)

Copy link
Member Author

Choose a reason for hiding this comment

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

will there be any issues with TailLines log option?

If TailLines is set, only the last N lines in the log file whose stream match the one user specified would be returned.

What will be the behavior of this log option when only one stream was specified?

Then only that log stream from the beginning would be returned.

Copy link
Member

Choose a reason for hiding this comment

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

I haven't looked into code, I just anticipate possible additional changes needed to ensure that the counting of TailLines happens properly and only logs from a specified stream were counted. Definitely add this to the test plan section

Copy link
Member Author

Choose a reason for hiding this comment

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

I just anticipate possible additional changes needed to ensure that the counting of TailLines happens properly and only logs from a specified stream were counted.

Actually my original thought is slightly different, I expected kubelet still examine the last TailLines of the log file, but only returns lines that matches the stream user specified.

I also understand my original thought is easy to implement, though it might confuse users. I agree that the most intutive way is only counting logs from a specified stream, and it would require extra work to be done in kubelet.

Copy link
Member

Choose a reason for hiding this comment

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

+1 on counting logs from a specified stream.

@knight42 knight42 force-pushed the feat/split-stdout-stderr branch 3 times, most recently from 328368c to 3059d92 Compare June 1, 2022 17:20
Copy link
Member

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

/lgtm

this feels small enough to include into 1.25. It's important to ensure that the test coverage is there

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 3, 2022
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 8, 2022

Yes.

###### What happens if we reenable the feature if it was previously rolled back?
Copy link
Contributor

Choose a reason for hiding this comment

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

requires an answer, but since this is not persisted, I don't think there's a concern here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated


###### What happens if we reenable the feature if it was previously rolled back?

###### Are there any tests for feature enablement/disablement?
Copy link
Contributor

Choose a reason for hiding this comment

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

requires an answer

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

@deads2k
Copy link
Contributor

deads2k commented Jun 9, 2022

minor PRR comments and then PRR lgtm

@dchen1107 dchen1107 added this to the v1.25 milestone Jun 9, 2022
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 10, 2022
@knight42
Copy link
Member Author

The failed tests seems to be caused by a recent merged PR #3281

@deads2k
Copy link
Contributor

deads2k commented Jun 10, 2022

PRR lgtm. The sig still owns review of the overall feature.

/approve

@knight42
Copy link
Member Author

@deads2k Thanks a lot!

Gently ping @dchen1107 @derekwaynecarr for final approval 🚀 . It would be great if we could ship it before enhancements freeze.

Copy link
Member

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 10, 2022
Signed-off-by: Jian Zeng <anonymousknight96@gmail.com>
Signed-off-by: Jian Zeng <anonymousknight96@gmail.com>
Signed-off-by: Jian Zeng <anonymousknight96@gmail.com>
Signed-off-by: Jian Zeng <anonymousknight96@gmail.com>
Signed-off-by: Jian Zeng <anonymousknight96@gmail.com>
Signed-off-by: Jian Zeng <anonymousknight96@gmail.com>
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 11, 2022
Copy link
Member

@SergeyKanzhelev SergeyKanzhelev left a comment

Choose a reason for hiding this comment

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

/lgtm
/assign @dchen1107

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 11, 2022
@dchen1107
Copy link
Member

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dchen1107, deads2k, knight42, SergeyKanzhelev

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 15, 2022
@k8s-ci-robot k8s-ci-robot merged commit ce61e37 into kubernetes:master Jun 15, 2022
@knight42 knight42 deleted the feat/split-stdout-stderr branch June 15, 2022 01:22
@cathchu
Copy link

cathchu commented Jul 27, 2022

Hi @knight42

1.25 Release Docs Shadow here. Does this enhancement work planned for 1.25 require any new docs or modification to existing docs?
If so, please follows the steps here to open a PR against dev-1.25 branch in the k/website repo. This PR can be just a placeholder at this time and must be created before August 4.
Also, take a look at Documenting for a release to get yourself familiarize with the docs requirement for the release.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/node Categorizes an issue or PR as relevant to SIG Node. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
Development

Successfully merging this pull request may close these issues.