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

Improve webhook error handling #517

Closed
wants to merge 3 commits into from

Conversation

khogeland
Copy link
Contributor

@khogeland khogeland commented Jun 13, 2019

  • Ensures all errors (internal and bad input) have a properly formatted AdmissionReview response
  • Returns internal errors in mutatePods to the client and API server instead of logging/swallowing

(FYI, 4xx response codes are still not properly handled by the API server, but that's been fixed recently. They'll continue to return 500 to the client until 1.16.)

Copy link
Collaborator

@liyinan926 liyinan926 left a comment

Choose a reason for hiding this comment

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

LGTM with some minor comments.

return
}
} else {
denyRequest(w, fmt.Sprintf("Unexpected resource type: %v", review.Request.Resource.String()), http.StatusUnsupportedMediaType)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We use lower-case for the first letter of error messages throughout the code base. Better to be consistent.

}

func internalError(w http.ResponseWriter, err error) {
glog.Errorf("Internal error: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto. Lower case for the first letter.

@khogeland
Copy link
Contributor Author

@liyinan926 updated

@khogeland khogeland mentioned this pull request Jul 3, 2019
@khogeland khogeland closed this Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants