-
Notifications
You must be signed in to change notification settings - Fork 274
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
Optimize the handling of the return messages of the extender scheduler #908
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: learner0810 <zhongjun.li@daocloud.io>
e69abdc
to
5886aca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR optimizes the handling of return messages in the extender scheduler by refactoring manual JSON marshalling and response writing to use the unrolled render package. Key changes include:
- Removal of redundant fmt import.
- Updated PredicateRoute and Bind handlers to use render.New(...).JSON.
- Consistent logging of JSON rendering errors.
Reviewed Changes
File | Description |
---|---|
pkg/scheduler/routes/route.go | Refactored JSON response construction in two routes using render for cleaner code |
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
w.Write(resultBody) | ||
klog.V(5).InfoS("Returning predicate response", "result", extenderFilterResult) | ||
|
||
err := render.New(render.Options{IndentJSON: true}).JSON(w, http.StatusOK, extenderFilterResult) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If render.New(...).JSON fails, the client receives no fallback error response, which may lead to unexpected behavior. Consider adding a mechanism to send an appropriate error message to the client.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
w.Write(response) | ||
klog.V(5).InfoS("Returning bind response", "result", extenderBindingResult) | ||
|
||
err := render.New(render.Options{IndentJSON: true}).JSON(w, http.StatusOK, extenderBindingResult) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Bind handler, if JSON rendering fails, no error response is sent to the client. It is recommended to include fallback error handling, similar to how errors were handled in the previous implementation.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
What type of PR is this?
/kind flake
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Optimize the handling of the return messages of the extender scheduler
Does this PR introduce a user-facing change?: