Skip to content

Commit

Permalink
return if kafka offset response is nil (#689)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Zingel <[email protected]>
  • Loading branch information
flecno authored Mar 17, 2020
1 parent 75878a9 commit 3692eca
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/scalers/kafka_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ func (s *kafkaScaler) getOffsets(partitions []int32) (*sarama.OffsetFetchRespons

func (s *kafkaScaler) getLagForPartition(partition int32, offsets *sarama.OffsetFetchResponse) int64 {
block := offsets.GetBlock(s.metadata.topic, partition)
if block == nil {
kafkaLog.Error(fmt.Errorf("error finding offset block for topic %s and partition %d", s.metadata.topic, partition), "")
return 0
}
consumerOffset := block.Offset
latestOffset, err := s.client.GetOffset(s.metadata.topic, partition, sarama.OffsetNewest)
if err != nil {
Expand Down

0 comments on commit 3692eca

Please sign in to comment.