File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,7 @@ def __init__(
198
198
sentinels ,
199
199
min_other_sentinels = 0 ,
200
200
sentinel_kwargs = None ,
201
+ force_master_ip = None ,
201
202
** connection_kwargs ,
202
203
):
203
204
# if sentinel_kwargs isn't defined, use the socket_* options from
@@ -214,6 +215,7 @@ def __init__(
214
215
]
215
216
self .min_other_sentinels = min_other_sentinels
216
217
self .connection_kwargs = connection_kwargs
218
+ self ._force_master_ip = force_master_ip
217
219
218
220
async def execute_command (self , * args , ** kwargs ):
219
221
"""
@@ -277,7 +279,13 @@ async def discover_master(self, service_name: str):
277
279
sentinel ,
278
280
self .sentinels [0 ],
279
281
)
280
- return state ["ip" ], state ["port" ]
282
+
283
+ ip = (
284
+ self ._force_master_ip
285
+ if self ._force_master_ip is not None
286
+ else state ["ip" ]
287
+ )
288
+ return ip , state ["port" ]
281
289
282
290
error_info = ""
283
291
if len (collected_errors ) > 0 :
Original file line number Diff line number Diff line change @@ -151,8 +151,10 @@ async def sentinel_setup(local_cache, request):
151
151
for ip , port in (endpoint .split (":" ) for endpoint in sentinel_ips .split ("," ))
152
152
]
153
153
kwargs = request .param .get ("kwargs" , {}) if hasattr (request , "param" ) else {}
154
+ force_master_ip = request .param .get ("force_master_ip" , None )
154
155
sentinel = Sentinel (
155
156
sentinel_endpoints ,
157
+ force_master_ip = force_master_ip ,
156
158
socket_timeout = 0.1 ,
157
159
client_cache = local_cache ,
158
160
protocol = 3 ,
You can’t perform that action at this time.
0 commit comments