karafka / karafka-web

Web UI for monitoring and managing Karafka consumers
Other
53 stars 8 forks source link

Key not found :jobs #417

Closed BrandonHicks-msr closed 3 weeks ago

BrandonHicks-msr commented 3 weeks ago

Expected behavior

While using v0.9.1 it works as expected, karafka is able to consume and produce topic messages as expected. It is not used as an ActiveJob replacement (we have sidekiq for this). We are using karafka as a message bus to pass topic messages between applications

Actual behavior

When upgrading to v0.10 this seems to no longer be the case, with 0.10 when accessing the karafka-web ui key not found :jobs is immediately thrown.

Screenshot 2024-08-21 at 8 11 19 AM 2

Your setup details

$ [bundle exec] karafka info
Karafka version: 2.4.8
Ruby version: ruby 3.3.4 (2024-07-09 revision be1089c8ec) [arm64-darwin23]
Rdkafka version: 0.17.3
Consumer groups count: 2
Subscription groups count: 2
Workers count: 5
Application client id: measurabl_api
Boot file: /Users/******/karafka.rb
Environment: development
License: LGPL-3.0
Shutting down background worker

The karafka config is setup and very basic:

# frozen_string_literal: true

# Logs
require 'datadog'
require 'karafka/instrumentation/vendors/datadog/logger_listener'

class KarafkaApp < Karafka::App
  setup do |config|
    config.kafka = {
      'bootstrap.servers': ENV.fetch('KAFKA_URL', ''),
      'security.protocol': ENV.fetch('KAFKA_SECURITY_PROTOCOL', 'ssl'),
      'api.version.request': true,
      'ssl.key.pem': ENV.fetch('KAFKA_SERVICE_KEY', ''),
      'ssl.certificate.pem': ENV.fetch('KAFKA_SERVICE_CERT', ''),
      'ssl.ca.pem': ENV.fetch('KAFKA_CA_CERT', ''),
      partitioner: 'murmur2_random',
    }
    config.client_id = 'app_client'
    config.consumer_persistence = true
  end

  Karafka.monitor.subscribe(Karafka::Instrumentation::LoggerListener.new)
  # Log Karafka exceptions to sentry
  Karafka.monitor.subscribe 'error.occurred' do |event|
    Sentry.capture_exception(event[:error])
  end

  # This logger prints the producer development info using the Karafka logger.
  # It is similar to the consumer logger listener but producer oriented.
  Karafka.producer.monitor.subscribe(
    WaterDrop::Instrumentation::LoggerListener.new(
      Karafka.logger,
      log_messages: false
    )
  )

  routes.draw do
    topic :sample_topic do
      consumer Sample::ResultsConsumer
    end
  end
end

##############################
# Karafka instrumentation and logging
##############################
# Initialize the listener for logging with Datadog
dd_logger_listener = Karafka::Instrumentation::Vendors::Datadog::LoggerListener.new do |config|
  config.client = Datadog::Tracing
end
# Use the DD tracing only for staging and production
Karafka.monitor.subscribe(dd_logger_listener) if %w[staging production].include?(Rails.env)

Karafka::Web.setup do |config|
  config.ui.sessions.secret = ENV.fetch('KARAFKA_WEB_SECRET', SecureRandom.hex(64))
end

Karafka::Web.enable!
mensfeld commented 3 weeks ago

update fully and reload both front and backend (web and consumers). After that, does it persist?

mensfeld commented 3 weeks ago

this has nothing to do with AJ jobs. It's related to karafka jobs and this looks like a partial upgrade. Once front and backend is upgraded this should go away.

mensfeld commented 3 weeks ago

ref https://github.com/karafka/karafka-web/blob/master/lib/karafka/web/management/migrations/consumers_metrics/1716218393_populate_jobs_metrics.rb ref https://github.com/karafka/karafka-web/blob/master/lib/karafka/web/management/migrations/consumers_states/1716218393_add_jobs_counter.rb ref

mensfeld commented 3 weeks ago

I was able to reproduce it:

image

mensfeld commented 3 weeks ago

My initial recommendation resolves the problem, and this behavior is consistent with the docs. Closing.

If you attempt to deploy the updated Web UI before the Karafka consumer processes, you may encounter errors. This could range from 500 Internal Server errors to incorrect or missing offset-related data displays.