Skip to content

Commit 8306ce3

Browse files
authored
Classify CH access denied (#4528)
1 parent a072710 commit 8306ce3

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

flow/alerting/classifier.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ var (
250250
ErrorNotifyTooManyPartsError = ErrorClass{
251251
Class: "NOTIFY_TOO_MANY_PARTS", action: NotifyUser,
252252
}
253+
ErrorNotifyClickHousePermissionsError = ErrorClass{
254+
Class: "NOTIFY_CLICKHOUSE_PERMISSIONS_ERROR", action: NotifyUser,
255+
}
253256
// Catch-all for misc ClickHouse errors
254257
ErrorNotifyClickHouseError = ErrorClass{
255258
Class: "NOTIFY_CLICKHOUSE_ERROR", action: NotifyUser,
@@ -998,6 +1001,8 @@ func GetErrorClass(ctx context.Context, err error) (ErrorClass, ErrorInfo) {
9981001
if strings.HasSuffix(chException.Message, "is either DETACHED PERMANENTLY or was just created by another replica") {
9991002
return ErrorRetryRecoverable, chErrorInfo
10001003
}
1004+
case chproto.ErrAccessDenied:
1005+
return ErrorNotifyClickHousePermissionsError, chErrorInfo
10011006
case chproto.ErrUnsupportedMethod,
10021007
chproto.ErrIllegalColumn,
10031008
chproto.ErrDuplicateColumn,

flow/alerting/classifier_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,21 @@ func TestClickHouseAccessEntityNotFoundErrorShouldBeRecoverable(t *testing.T) {
269269
}
270270
}
271271

272+
func TestClickHouseAccessDeniedErrorShouldBeNotifyPermissions(t *testing.T) {
273+
err := &clickhouse.Exception{
274+
Code: int32(chproto.ErrAccessDenied),
275+
Message: "user@example.com: Not enough privileges. To execute this query, it's necessary to have the grant READ ON S3",
276+
}
277+
errorClass, errInfo := GetErrorClass(t.Context(),
278+
exceptions.NewNormalizationError(fmt.Errorf(
279+
"failed to normalize records: failed to copy avro stages to destination: %w", err)))
280+
assert.Equal(t, ErrorNotifyClickHousePermissionsError, errorClass, "Unexpected error class")
281+
assert.Equal(t, ErrorInfo{
282+
Source: ErrorSourceClickHouse,
283+
Code: strconv.Itoa(int(chproto.ErrAccessDenied)),
284+
}, errInfo, "Unexpected error info")
285+
}
286+
272287
func TestClickHousePushingToViewShouldBeMvError(t *testing.T) {
273288
err := &clickhouse.Exception{
274289
Code: int32(chproto.ErrCannotConvertType),

0 commit comments

Comments
 (0)