@@ -94,11 +94,6 @@ def finish_cluster(names):
94
94
else :
95
95
print ("This pod is intentionally skipping the call to http://127.0.0.1:5984/_cluster_setup" )
96
96
97
- def diff (first , second ):
98
- second = set (second )
99
- return [item for item in first if item not in second ]
100
-
101
-
102
97
@backoff .on_exception (
103
98
backoff .expo ,
104
99
requests .exceptions .ConnectionError ,
@@ -126,6 +121,8 @@ def are_nodes_in_sync(names):
126
121
remote_membership_uri = "http://{0}:5984/_membership" .format (name )
127
122
if creds [0 ] and creds [1 ]:
128
123
remote_resp = requests .get (remote_membership_uri , auth = creds )
124
+ else :
125
+ remote_resp = requests .get (remote_membership_uri )
129
126
# Compare local and remote _mebership data. Make sure the set
130
127
# of nodes match. This will ensure that the remote nodes
131
128
# are fully primed with nodes data before progressing with
@@ -137,14 +134,15 @@ def are_nodes_in_sync(names):
137
134
if ordered (local_resp .json ()) != ordered (remote_resp .json ()):
138
135
is_different = True
139
136
print ("Fetching CouchDB node mebership from this pod: {0}" .format (local_membership_uri ),flush = True )
140
- records_in_local_but_not_in_remote = diff (local_resp .json ().cluster_nodes , remote_resp .json ().cluster_nodes )
141
- records_in_remote_but_not_in_local = diff (remote_resp .json ().cluster_nodes , local_resp .json ().cluster_nodes )
137
+ records_in_local_but_not_in_remote = set (local_resp .json ().cluster_nodes ) - set ( remote_resp .json ().cluster_nodes )
138
+ records_in_remote_but_not_in_local = set (remote_resp .json ().cluster_nodes ) - set ( local_resp .json ().cluster_nodes )
142
139
if records_in_local_but_not_in_remote :
143
140
print ("Cluster members in {0} not yet present in {1}: {2}" .format (os .getenv ("HOSTNAME" ), name .split ("." ,1 )[0 ], records_in_local_but_not_in_remote ))
144
141
if records_in_remote_but_not_in_local :
145
142
print ("Cluster members in {0} not yet present in {1}: {2}" .format (name .split ("." ,1 )[0 ], os .getenv ("HOSTNAME" ), records_in_remote_but_not_in_local ))
146
143
else :
147
144
is_different = True
145
+ print ('returnerar' , not is_different )
148
146
return not is_different
149
147
150
148
def sleep_forever ():
0 commit comments