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

Execute the Run function of kubelet, Remove invalid comments and remove run function #110691

Merged
merged 1 commit into from Jul 5, 2022

Conversation

yangjunmyfm192085
Copy link
Contributor

@yangjunmyfm192085 yangjunmyfm192085 commented Jun 21, 2022

What type of PR is this?

/kind bug

What this PR does / why we need it:

Run the Run function, when there is an error exit, print the error log

Which issue(s) this PR fixes:

Fixes #110690

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Run kubelet, when there is an error exit, print the error log

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 21, 2022
@yangjunmyfm192085
Copy link
Contributor Author

yangjunmyfm192085 commented Jun 21, 2022

/cc @endocrimes @dims

@k8s-ci-robot k8s-ci-robot requested review from dims and endocrimes Jun 21, 2022
Copy link
Contributor Author

@yangjunmyfm192085 yangjunmyfm192085 left a comment

/retest

@dims dims removed their request for review Jun 21, 2022
@pacoxu pacoxu added this to Triage in SIG Node PR Triage Jun 24, 2022
Copy link
Contributor Author

@yangjunmyfm192085 yangjunmyfm192085 left a comment

/cc @pohly
Or we modify to the way as kube-apiserver?
such as:

code := cli.Run(command)

@k8s-ci-robot k8s-ci-robot requested a review from pohly Jun 30, 2022
if err != nil {
klog.ErrorS(err, "Failed to run kubelet")
}
return err
Copy link
Contributor

@pohly pohly Jun 30, 2022

Choose a reason for hiding this comment

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

This seems odd. Why is the caller not printing the error when RunE returns it?

Copy link
Contributor Author

@yangjunmyfm192085 yangjunmyfm192085 Jul 1, 2022

Choose a reason for hiding this comment

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

I think the code is just made a judgment and did not print,

	if err := command.Execute(); err != nil {
		return 1
	}
	return 0

But I noticed that this code has been modified again recently.

7a5af81

@yxxhero, I noticed that the annotation describes

	// kubelet uses a config file and does its own special
	// parsing of flags and that config file. It initializes
	// logging after it is done with that. Therefore it does
	// not use cli.Run like other, simpler commands.

Is your modification correct?

Copy link
Contributor

@pohly pohly Jul 1, 2022

Choose a reason for hiding this comment

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

That comment should have been removed in 7a5af81 because clearly now kubelet does use cli.Run.

Originally, that comment was correct. InitLogs had to be called after flag parsing, and kubelet therefore couldn't use cli.run.

But that restriction has been lifted when allowing reconfiguration of the flush interval in 18bf5d2

Copy link
Contributor

@pohly pohly Jul 1, 2022

Choose a reason for hiding this comment

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

7a5af81 cannot be backported to 1.24. In 1.24, adding error printing to

is the best solution.

Copy link
Contributor Author

@yangjunmyfm192085 yangjunmyfm192085 Jul 1, 2022

Choose a reason for hiding this comment

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

Yeah I think you are right, Let me take a look,thanks

@pohly
Copy link
Contributor

pohly commented Jun 30, 2022

Or we modify to the way as kube-apiserver?

Yes, making the main function more like in other commands would be the preferred solution. I don't remember why that wasn't already done.

@yangjunmyfm192085 yangjunmyfm192085 force-pushed the fixlogprint branch 2 times, most recently from be4f779 to 1162ba3 Compare Jul 1, 2022
@yangjunmyfm192085 yangjunmyfm192085 changed the title Execute the Run function of kubelet, no log output after failure Execute the Run function of kubelet, Remove invalid comments Jul 1, 2022
Copy link
Contributor Author

@yangjunmyfm192085 yangjunmyfm192085 left a comment

Due to the following modification, the issue that the main branch cannot print the log has been solved.
This pr is only used to delete invalid logs.
In the 1.24 branch I will take pohly's suggestion and resubmit pr to fix
7a5af81

@yangjunmyfm192085
Copy link
Contributor Author

yangjunmyfm192085 commented Jul 1, 2022

/cc @pohly @yxxhero @endocrimes

@k8s-ci-robot k8s-ci-robot requested a review from yxxhero Jul 1, 2022
// kubelet uses a config file and does its own special
// parsing of flags and that config file. It initializes
// logging after it is done with that. Therefore it does
// not use cli.Run like other, simpler commands.
Copy link
Contributor

@pohly pohly Jul 1, 2022

Choose a reason for hiding this comment

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

Can you also eliminate the run function? It serves no purpose anymore.

Copy link
Contributor

@pohly pohly Jul 1, 2022

Choose a reason for hiding this comment

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

And remove command.SetGlobalNormalizationFunc(cliflag.WordSepNormalizeFunc)?

That is done by cli.Run:

cmd.SetGlobalNormalizationFunc(cliflag.WordSepNormalizeFunc)

Copy link
Contributor Author

@yangjunmyfm192085 yangjunmyfm192085 Jul 1, 2022

Choose a reason for hiding this comment

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

Let me update

Copy link
Contributor Author

@yangjunmyfm192085 yangjunmyfm192085 Jul 1, 2022

Choose a reason for hiding this comment

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

I have updated. could you please take a look again, thanks? @pohly

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jul 1, 2022
@yangjunmyfm192085 yangjunmyfm192085 changed the title Execute the Run function of kubelet, Remove invalid comments Execute the Run function of kubelet, Remove invalid comments and remove run function Jul 1, 2022
@yangjunmyfm192085
Copy link
Contributor Author

yangjunmyfm192085 commented Jul 1, 2022

/retest

pohly
pohly approved these changes Jul 1, 2022
Copy link
Contributor

@pohly pohly left a comment

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 1, 2022
@yangjunmyfm192085 yangjunmyfm192085 moved this from Triage to Needs Approver in SIG Node PR Triage Jul 4, 2022
Copy link
Contributor Author

@yangjunmyfm192085 yangjunmyfm192085 left a comment

/triage accepted
/assign @mrunalp

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Jul 5, 2022
mrunalp
mrunalp approved these changes Jul 5, 2022
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Jul 5, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mrunalp, pohly, yangjunmyfm192085

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 Jul 5, 2022
@mrunalp mrunalp moved this from Needs Approver to Done in SIG Node PR Triage Jul 5, 2022
@k8s-ci-robot k8s-ci-robot merged commit fe1d3fe into kubernetes:master Jul 5, 2022
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.25 milestone Jul 5, 2022
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. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging this pull request may close these issues.

Execute the Run function of kubelet, no log output after failure
4 participants