From 4d15d435e4792b52aa6146c7430814e31b10c6bf Mon Sep 17 00:00:00 2001 From: Daijiro Fukuda Date: Thu, 21 Aug 2025 13:25:21 +0900 Subject: [PATCH] Add small sleep to retryment for GoneError To fix unstable tests: TestWatchNamespaces#test_0012_namespace watch retries when 410 Gone errors are encountered: NoMethodError: undefined method `>=' for nil:NilClass test/plugin/test_watch_namespaces.rb:250:in `block (3 levels) in ' test/plugin/test_watch_namespaces.rb:241:in `block (2 levels) in ' test/plugin/test_watch_namespaces.rb:240:in `block in ' TestWatchPods#test_0013_pod watch retries when 410 Gone errors are encountered: NoMethodError: undefined method '>=' for nil test/plugin/test_watch_pods.rb:360:in 'block (3 levels) in ' test/plugin/test_watch_pods.rb:351:in 'block (2 levels) in ' test/plugin/test_watch_pods.rb:350:in 'block in ' It appears that the cause could be the infinite loop without any sleep when GoneError occurs. Signed-off-by: Daijiro Fukuda --- lib/fluent/plugin/kubernetes_metadata_watch_namespaces.rb | 1 + lib/fluent/plugin/kubernetes_metadata_watch_pods.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/fluent/plugin/kubernetes_metadata_watch_namespaces.rb b/lib/fluent/plugin/kubernetes_metadata_watch_namespaces.rb index f74caa7..73459a0 100644 --- a/lib/fluent/plugin/kubernetes_metadata_watch_namespaces.rb +++ b/lib/fluent/plugin/kubernetes_metadata_watch_namespaces.rb @@ -47,6 +47,7 @@ def set_up_namespace_thread # rubocop:disable Metrics/AbcSize, Metrics/MethodLen @stats.bump(:namespace_watch_gone_errors) log.info('410 Gone encountered. Restarting namespace watch to reset resource versions.', e) namespace_watcher = nil + sleep 1 rescue KubeException => e if e.error_code == 401 # recreate client to refresh token diff --git a/lib/fluent/plugin/kubernetes_metadata_watch_pods.rb b/lib/fluent/plugin/kubernetes_metadata_watch_pods.rb index 8ba223d..3448a53 100644 --- a/lib/fluent/plugin/kubernetes_metadata_watch_pods.rb +++ b/lib/fluent/plugin/kubernetes_metadata_watch_pods.rb @@ -48,6 +48,7 @@ def set_up_pod_thread # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, M @stats.bump(:pod_watch_gone_errors) log.info('410 Gone encountered. Restarting pod watch to reset resource versions.', e) pod_watcher = nil + sleep 1 rescue KubeException => e if e.error_code == 401 # recreate client to refresh token