@@ -35,6 +35,8 @@ def __init__(self, group_name):
35
35
self ._last_time_loaded = None
36
36
self ._check_hashring_startup = True
37
37
self ._group = group_name
38
+ # Flag to rate limit the caching log
39
+ self ._prev_num_nodes = - 1
38
40
self .admin_ctx = context .get_admin_context ()
39
41
40
42
@property
@@ -56,11 +58,18 @@ def _wait_startup_before_caching(self):
56
58
self .admin_ctx ,
57
59
constants .HASH_RING_CACHE_TIMEOUT , self ._group , from_host = True )
58
60
59
- if len (nodes ) >= api_workers :
60
- LOG .debug ("Allow caching, nodes %s>=%s" , len (nodes ), api_workers )
61
+ num_nodes = len (nodes )
62
+ if num_nodes >= api_workers :
63
+ LOG .debug ("Allow caching, nodes %s>=%s" , num_nodes , api_workers )
61
64
self ._check_hashring_startup = False
62
65
return False
63
- LOG .debug ("Disallow caching, nodes %s<%s" , len (nodes ), api_workers )
66
+
67
+ # NOTE(lucasagomes): We only log when the number of connected
68
+ # nodes are different to prevent this message from being spammed
69
+ if self ._prev_num_nodes != num_nodes :
70
+ LOG .debug ("Disallow caching, nodes %s<%s" , num_nodes , api_workers )
71
+ self ._prev_num_nodes = num_nodes
72
+
64
73
return True
65
74
66
75
def _load_hash_ring (self , refresh = False ):
0 commit comments