From 0b7a03e5f444816a891fa39e426644ca64e4f9b1 Mon Sep 17 00:00:00 2001 From: Maciej Mensfeld Date: Fri, 3 May 2024 18:23:56 +0200 Subject: [PATCH] fix missing stored lag reference in OSS consumers (#329) --- CHANGELOG.md | 3 ++ Gemfile.lock | 2 +- .../web/ui/views/consumers/_consumer.erb | 2 +- lib/karafka/web/version.rb | 2 +- .../controllers/consumers_controller_spec.rb | 29 +++++++++++++++++++ 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dea97104..f53e9457 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Karafka Web changelog +## 0.9.1 (2024-05-03) +- [Fix] OSS `lag_stored` for not-subscribed consumers causes Web UI to crash. + ## 0.9.0 (2024-04-26) - **[Breaking]** Drop Ruby `2.7` support. - **[Feature]** Provide ability to stop and quiet running consumers (Pro). diff --git a/Gemfile.lock b/Gemfile.lock index bf6d7288..a730cf13 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - karafka-web (0.9.0) + karafka-web (0.9.1) erubi (~> 1.4) karafka (>= 2.4.0, < 2.5.0) karafka-core (>= 2.4.0, < 2.5.0) diff --git a/lib/karafka/web/ui/views/consumers/_consumer.erb b/lib/karafka/web/ui/views/consumers/_consumer.erb index 2233bcda..3313d3ef 100644 --- a/lib/karafka/web/ui/views/consumers/_consumer.erb +++ b/lib/karafka/web/ui/views/consumers/_consumer.erb @@ -35,6 +35,6 @@ - <%= process.lag_stored %> + <%= process.lag_hybrid %> diff --git a/lib/karafka/web/version.rb b/lib/karafka/web/version.rb index 2e04533d..623a38dd 100644 --- a/lib/karafka/web/version.rb +++ b/lib/karafka/web/version.rb @@ -3,6 +3,6 @@ module Karafka module Web # Current gem version - VERSION = '0.9.0' + VERSION = '0.9.1' end end diff --git a/spec/lib/karafka/web/ui/controllers/consumers_controller_spec.rb b/spec/lib/karafka/web/ui/controllers/consumers_controller_spec.rb index 2490c445..01c5d0a9 100644 --- a/spec/lib/karafka/web/ui/controllers/consumers_controller_spec.rb +++ b/spec/lib/karafka/web/ui/controllers/consumers_controller_spec.rb @@ -52,6 +52,35 @@ end end + context 'when there is an active consumer but without any partitions assigned yet' do + before do + topics_config.consumers.states = states_topic + topics_config.consumers.reports = reports_topic + + report = Fixtures.consumers_reports_json + scope = report[:consumer_groups][:example_app6_app][:subscription_groups][:c4ca4238a0b9_0] + scope[:topics].clear + + produce(states_topic, Fixtures.consumers_states_file) + produce(reports_topic, report.to_json) + + get 'consumers' + end + + it do + expect(response).to be_ok + expect(body).not_to include('partitions: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9') + expect(body).to include(support_message) + expect(body).not_to include(breadcrumbs) + expect(body).not_to include(no_processes) + expect(body).not_to include(pagination) + expect(body).to include('246 MB') + expect(body).to include('shinra:1:1') + expect(body).to include('/consumers/shinra:1:1/subscriptions') + expect(body).to include('2690818651.82293') + end + end + context 'when there are active consumers with many partitions assigned' do before do topics_config.consumers.states = states_topic