Skip to content

Kafka scaler doesn't handle Sarama errors properly #3056

Closed
@lsolovey

Description

Report

Sarama can report Kafka errors not just as Go standard error but rather use custom field on the returned data object.
(I'm not a Go expert so please excuse my terminology).

For example, DescribeTopics() in Sarama Admin client is declared as:

DescribeTopics(topics []string) (metadata []*TopicMetadata, err error)

And TopicMetadata is a struct with "custom" KError field.

type TopicMetadata struct {
	Err        KError
	Name       string
	IsInternal bool // Only valid for Version >= 1
	Partitions []*PartitionMetadata
}

Kafka scaler only checks for error returned from DescribeTopics, but it doesn't check for any KErrors on the returned payloads.
So effectively - some Kafka errors are ignored by KEDA.

The same applies for all other Sarama API calls used by Kafka Scaler.

I debugged KEDA Kafka Scaler - please see the screenshot with a sample response from DescribeTopics() call:
image

Expected Behavior

KEDA Kafka Scaler correctly reports errors from Sarama client in logs.

Actual Behavior

KEDA Kafka Scaler doesn't report errors from Sarama client in logs.
No way to troubleshoot Kafka Scaler other than debugging.

Steps to Reproduce the Problem

  1. We use Confluent Platform Kafka with RBAC enabled.
  2. Create ScaledObject with Kafka Trigger. Use TLS certs issued for Kafka principal which has just one RBAC permission: DeveloperRead permission on the Consumer Group used by Kafka trigger.
  3. Publish some records in the Kafka topic specified in Kafka Trigger (to increase the offset).
  4. KEDA doesn't activate target Deployment. No errors reported in KEDA logs.
  5. Upon debugging of Kafka Scaler, it's clear that Kafka error about unauthorized topic access is reported by Sarama but ignored by KEDA.

Logs from KEDA operator

No response

KEDA Version

2.7.1

Kubernetes Version

1.21

Platform

Other

Scaler Details

Kafka

Anything else?

No response

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions