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

refactor: change returned status code and description in clickhouse error handling #286

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/e2e-test/carbon-clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type CarbonClickhouse struct {

func (c *CarbonClickhouse) Start(testDir, clickhouseURL string) (string, error) {
if len(c.Version) == 0 {
c.Version = "0.11.4"
c.Version = "latest"
}
if len(c.DockerImage) == 0 {
c.DockerImage = "ghcr.io/go-graphite/carbon-clickhouse"
Expand Down
5 changes: 4 additions & 1 deletion helper/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ func extractClickhouseError(e string) (int, string) {
return http.StatusServiceUnavailable, "Storage configuration error"
}
}
return http.StatusInternalServerError, "Storage error"
if strings.HasPrefix(e, "clickhouse response status 404: Code: 60. DB::Exception: Table default.") {
return http.StatusServiceUnavailable, "Storage default tables damaged"
}
return http.StatusServiceUnavailable, "Storage unavailable"
}

func HandleError(w http.ResponseWriter, err error) (status int, queueFail bool) {
Expand Down
9 changes: 7 additions & 2 deletions helper/clickhouse/clickhouse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ func Test_extractClickhouseError(t *testing.T) {
wantStatus: http.StatusForbidden,
wantMessage: "Storage read limit for memory",
},
{
errStr: "clickhouse response status 404: Code: 60. DB::Exception: Table default.graphite_index does not exist. (UNKNOWN_TABLE) (version 23.12.6.19 (official build))\n",
wantStatus: http.StatusServiceUnavailable,
wantMessage: "Storage default tables damaged",
},
{
errStr: "Other error",
wantStatus: http.StatusInternalServerError,
wantMessage: "Storage error",
wantStatus: http.StatusServiceUnavailable,
wantMessage: "Storage unavailable",
},
}
for _, tt := range tests {
Expand Down
Loading