-
Notifications
You must be signed in to change notification settings - Fork 759
resourcemanager: make controller config updates atomic #10504
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -336,6 +336,21 @@ func (suite *resourceManagerAPITestSuite) TestControllerConfigAPI() { | |||||||||||||||||||||||||
| re.Equal(2.0, config.RequestUnit.WriteBaseCost) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| func (suite *resourceManagerAPITestSuite) TestControllerConfigAPIAllOrNothing() { | ||||||||||||||||||||||||||
| re := suite.Require() | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| before := suite.mustGetControllerConfig(re) | ||||||||||||||||||||||||||
| resp, statusCode := tryToSetControllerConfig(re, suite.cluster.GetLeaderServer().GetAddr(), map[string]any{ | ||||||||||||||||||||||||||
| "enable-controller-trace-log": "true", | ||||||||||||||||||||||||||
| "ltb-max-wait-duration": "not-a-duration", | ||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||
| re.Equal(http.StatusBadRequest, statusCode) | ||||||||||||||||||||||||||
| re.Contains(resp, "time:") | ||||||||||||||||||||||||||
|
Comment on lines
+318
to
+323
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a real boolean here to keep the regression deterministic. Line 319 sends Suggested fix resp, statusCode := tryToSetControllerConfig(re, suite.cluster.GetLeaderServer().GetAddr(), map[string]any{
- "enable-controller-trace-log": "true",
+ "enable-controller-trace-log": true,
"ltb-max-wait-duration": "not-a-duration",
})📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| after := suite.mustGetControllerConfig(re) | ||||||||||||||||||||||||||
| re.Equal(before, after) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| func (suite *resourceManagerAPITestSuite) mustGetControllerConfig(re *require.Assertions) *server.ControllerConfig { | ||||||||||||||||||||||||||
| bodyBytes := suite.mustSendRequest(re, http.MethodGet, "/config/controller", nil) | ||||||||||||||||||||||||||
| config := &server.ControllerConfig{} | ||||||||||||||||||||||||||
|
|
@@ -344,8 +359,14 @@ func (suite *resourceManagerAPITestSuite) mustGetControllerConfig(re *require.As | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| func (suite *resourceManagerAPITestSuite) mustSetControllerConfig(re *require.Assertions, config map[string]any) { | ||||||||||||||||||||||||||
| bodyBytes := suite.mustSendRequest(re, http.MethodPost, "/config/controller", config) | ||||||||||||||||||||||||||
| re.Equal("Success!", string(bodyBytes)) | ||||||||||||||||||||||||||
| body, statusCode := tryToSetControllerConfig(re, suite.cluster.GetLeaderServer().GetAddr(), config) | ||||||||||||||||||||||||||
| re.Equal(http.StatusOK, statusCode, body) | ||||||||||||||||||||||||||
| re.Equal("Success!", body) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| func tryToSetControllerConfig(re *require.Assertions, leaderAddr string, config map[string]any) (string, int) { | ||||||||||||||||||||||||||
| bodyBytes, statusCode := sendRequest(re, leaderAddr, http.MethodPost, "/config/controller", nil, config) | ||||||||||||||||||||||||||
| return string(bodyBytes), statusCode | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| func (suite *resourceManagerAPITestSuite) TestKeyspaceServiceLimitAPI() { | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
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.
Don't collapse persistence failures into
400 Bad Request.Line 251 now calls the batch path, and that path can fail after validation when
SaveControllerConfighits storage. Returning400for every non-permission error will mislabel etcd/write failures as client input problems; please distinguish validation errors from persistence errors here, even if that means wrapping save failures from the store layer. As per coding guidelines, "HTTP handlers must validate payloads and return proper status codes; avoid panics".🤖 Prompt for AI Agents