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

Propagate panics up handler chain #71076

Merged
merged 1 commit into from
Nov 16, 2018

Conversation

liggitt
Copy link
Member

@liggitt liggitt commented Nov 15, 2018

What type of PR is this?
/kind bug

What this PR does / why we need it:

Fixes panic propagation in finishRequest. finishRequest incorrectly assumed that HandleCrash was the correct way to recover a panic in order to propagate it up the handler chain. In actuality, HandleCrash simply logs and repanics, which causes the process to exit in finishRequest, which means we don't get the full call stack. We want to capture the panic reason/stack, and propagate it upward so the full stack is logged at the top of the handler chain.

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

apiserver: fixes handling and logging of panics in REST handlers to prevent crashes

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 15, 2018
@liggitt
Copy link
Member Author

liggitt commented Nov 15, 2018

/assign lavalamp sttts

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 15, 2018
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 15, 2018
@liggitt
Copy link
Member Author

liggitt commented Nov 15, 2018

/priority critical-urgent
/sig api-machinery

@k8s-ci-robot k8s-ci-robot added priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 15, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liggitt

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

const size = 64 << 10
buf := make([]byte, size)
buf = buf[:goruntime.Stack(buf, false)]
panicReason = fmt.Sprintf("%v\n%s", panicReason, string(buf))
Copy link
Contributor

Choose a reason for hiding this comment

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

trim trailing newline

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes concatenation of further backtraces cleaner

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@liggitt
Copy link
Member Author

liggitt commented Nov 15, 2018

/milestone v1.13

@sttts
Copy link
Contributor

sttts commented Nov 15, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 15, 2018
@liggitt
Copy link
Member Author

liggitt commented Nov 15, 2018

/retest

1 similar comment
@liggitt
Copy link
Member Author

liggitt commented Nov 15, 2018

/retest

@fedebongio
Copy link
Contributor

/cc @roycaihw

@k8s-ci-robot k8s-ci-robot merged commit f1e4ec8 into kubernetes:master Nov 16, 2018
@liggitt liggitt deleted the preserve-stack branch November 16, 2018 21:23
k8s-ci-robot added a commit that referenced this pull request Nov 28, 2018
…#71076-upstream-release-1.12

Automated cherry pick of #71067: apiserver: in timeout_test separate out handler #71076: apiserver: propagate panics from REST handlers correctly
k8s-ci-robot added a commit that referenced this pull request Nov 30, 2018
…#71076-upstream-release-1.10

Automated cherry pick of #71067: apiserver: in timeout_test separate out handler #71076: apiserver: propagate panics from REST handlers correctly
k8s-ci-robot added a commit that referenced this pull request Dec 3, 2018
…#71076-upstream-release-1.11

Automated cherry pick of #71067: apiserver: in timeout_test separate out handler #71076: apiserver: propagate panics from REST handlers correctly
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/apiserver 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 "Looks good to me", indicates that a PR is ready to be merged. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants