Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
c103467 to
8375bbd
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (2)
pkg/status/status_server_test.go:736
- This assertion relies on substring matching the JSON response body. To make the test resilient to formatting changes and consistent with other JSON-response tests in this file, unmarshal the body and assert the Enabled field.
assert.Equal(t, http.StatusOK, w.Code)
assert.Contains(t, w.Body.String(), `"enabled": true`)
authzOffload := l.GetAuthzOffload()
assert.Equal(t, constants.ENABLED, authzOffload)
})
pkg/status/status_server_test.go:699
- The test is validating the GET /authz response by substring matching the raw body. This is brittle (whitespace/formatting changes) and less consistent with other tests in this file that unmarshal JSON before asserting fields (e.g., TestServer_getLoggerLevel). Consider unmarshalling the response JSON and asserting the Enabled field instead.
This issue also appears on line 731 of the same file.
assert.Equal(t, http.StatusOK, w.Code)
assert.Contains(t, w.Body.String(), `"enabled": false`)
})
Codecov Report❌ Patch coverage is
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
The authzHandler currently rejects GET requests with 405, but the CLI fetchAuthzStatus() already sends GET to query the current state. Add a getAuthzStatus handler that reads from BpfLoader.GetAuthzOffload() and returns the status as JSON, following the existing loggersHandler pattern. Also adds test coverage for the authz handler which previously had none. Signed-off-by: devGP7 <gauravpatil232005@gmail.com>
dac5669 to
ef61602
Compare
|
/retest |
|
@devGPP23: Cannot trigger testing until a trusted user reviews the PR and leaves an DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (3)
pkg/status/status_server_test.go:732
- This assertion is coupled to JSON formatting/indentation. Parsing the response and asserting on the decoded
enabledfield is more robust and makes the test intent clearer.
assert.Equal(t, http.StatusOK, w.Code)
assert.Contains(t, w.Body.String(), `"enabled": true`)
pkg/status/status_server_test.go:698
- This assertion is coupled to JSON formatting/indentation. Parsing the response and asserting on the decoded
enabledfield is more robust and makes the test intent clearer.
This issue also appears on line 731 of the same file.
assert.Equal(t, http.StatusOK, w.Code)
assert.Contains(t, w.Body.String(), `"enabled": false`)
pkg/status/status_server.go:345
GetAuthzOffload()logs and returns the zero value on map read failures. With this GET endpoint, that means an internal read error will be reported to clients asenabled=false(200 OK) instead of an error response, which can mask operational problems.
func (s *Server) getAuthzStatus(w http.ResponseWriter) {
authzOffload := s.loader.GetAuthzOffload()
enabled := authzOffload == constants.ENABLED
|
@yashisrani @LiZhenCheng9527 @hzxuzhonghu The failing E2E Test(istio 1.26) is unrelated to my changes Could you please /retest when they get a chance? |
Signed-off-by: devGP7 <gauravpatil232005@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
pkg/status/status_server.go:355
getAuthzStatususesjson.MarshalIndent, which inserts newlines/spaces into the response body.kmeshctl authz statuscurrently prints the raw response into a tabwriter table, so multi-line JSON will break the table formatting. Return compact, single-line JSON here (no trailing newline) to keep CLI output stable.
data, err := json.MarshalIndent(&struct {
Enabled bool `json:"enabled"`
}{Enabled: enabled}, "", " ")
if err != nil {
|
cc/ @yashisrani |
|
/lgtm |
| w.WriteHeader(http.StatusInternalServerError) | ||
| return | ||
| } | ||
| w.WriteHeader(http.StatusOK) |
There was a problem hiding this comment.
Content-Type: application/json is not set.
|
New changes are detected. LGTM label has been removed. |
|
Adding label DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
🟡 Changes recommended
Set the response Content-Type to application/json and assert it in tests.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
c473d9f to
6cb75a7
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
The tests do not verify the default GET status before changing the authz setting.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
pkg/status/status_server_test.go:686
- This test does not cover the default-state behavior described by the PR: it first POSTs
enable=falseand only then exercises GET. Please issue a GET before the POST and assert the initial response, so regressions in reading the default offload value are actually detected.
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Lite
6cb75a7 to
742bb2b
Compare
…onse Signed-off-by: devGP7 <gauravpatil232005@gmail.com>
742bb2b to
877008d
Compare
Signed-off-by: devGP7 <gauravpatil232005@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
🟡 Changes recommended
The certificate retry test relies on fixed sleeps and may remain intermittent under load.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
| // Wait long enough for the ADD request to be processed and the error path | ||
| // (including scheduling a time.AfterFunc retry) to complete. | ||
| time.Sleep(500 * time.Millisecond) | ||
| patches2.Reset() | ||
|
|
||
| // Wait for any pending auto-retry (time.AfterFunc(1s) in fetchCert) to fire | ||
| // after the patch has been removed so it can succeed with the real mock client. | ||
| time.Sleep(1500 * time.Millisecond) |
Problem
I was going through the
authzCLI code and saw thatfetchAuthzStatus()inctl/authz/authz.gosends a GET to/authzto check the current state. But when I looked at the server side,authzHandleronly accepts POST and rejects everything else with 405. Sokmeshctl authzstatus was never actually working — it always gets a 405 back.due to these lines of code in authzHandler,whenever someone tried GET endpoint , it return method not allowed
Solution
I added GET support to
authzHandlerthe same wayloggersHandleralready handles it — GET goes to a read function, POST goes to the write function.The new
getAuthzStatus()reads fromBpfLoader.GetAuthzOffload()and returns the state as JSON. The POST logic is unchanged, just moved it tosetAuthzStatus()to keep things clean.There were no tests for this handler before so I added a couple — one to check the default state and one to verify it updates after enabling
authz.Below is the terminal output from testing the /authz endpoint locally against the Kmesh status server:
We got status 200 with Json telling if authz is enabled or not