mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
cleanup old sreqs if the master changed
Jumping back and forth between different masters will over time add more and more sreqs to the sreq_cache. That might be ok in MultiMaster, with signed master-pubkeys, we only want one single master sreq we re-use and remove all the others.
This commit is contained in:
parent
decbe41612
commit
1a656859bd
@ -12,6 +12,8 @@ from collections import defaultdict
|
||||
import salt.payload
|
||||
import salt.auth
|
||||
import salt.utils
|
||||
from re import match
|
||||
|
||||
try:
|
||||
from raet import raeting
|
||||
from raet.road.stacking import RoadStack
|
||||
@ -139,7 +141,15 @@ class ZeroMQChannel(Channel):
|
||||
@property
|
||||
def sreq(self):
|
||||
key = self.sreq_key
|
||||
|
||||
if key not in ZeroMQChannel.sreq_cache:
|
||||
if self.opts['master_type'] == 'failover':
|
||||
# remove all cached sreqs to the old master
|
||||
for check_key in self.sreq_cache.keys():
|
||||
if self.opts['master_uri'] != check_key[0]:
|
||||
del self.sreq_cache[check_key]
|
||||
print("removed {0}".format(check_key))
|
||||
|
||||
ZeroMQChannel.sreq_cache[key] = salt.payload.SREQ(self.master_uri)
|
||||
|
||||
return ZeroMQChannel.sreq_cache[key]
|
||||
|
Loading…
Reference in New Issue
Block a user