@@ -67,7 +67,7 @@ def ordered(obj):
67
67
else :
68
68
return obj
69
69
70
- # Run action:finish_cluster on one (and only one) CouchDB cluster node
70
+ # Call action:finish_cluster on one (and only one) CouchDB cluster node
71
71
def finish_cluster (names ):
72
72
# The HTTP POST to /_cluster_setup should be done to
73
73
# one (and only one) of the CouchDB cluster nodes.
@@ -90,9 +90,10 @@ def finish_cluster(names):
90
90
print ("\t \t Response:" , setup_resp .status_code , setup_resp .json ())
91
91
print ("Time to relax!" )
92
92
else :
93
- print ('Ouch! Failed the final step: http://127.0.0.1:5984/_cluster_setup returned {0}' . format ( setup_resp . status_code ) )
93
+ print ('Ouch! Failed the final step finalizing the cluster.' )
94
94
else :
95
- print ("This pod is intentionally skipping the call to http://127.0.0.1:5984/_cluster_setup" )
95
+ print ('This pod is intentionally skipping the POST to http://127.0.0.1:5984/_cluster_setup {"action": "finish_cluster"}' )
96
+
96
97
97
98
@backoff .on_exception (
98
99
backoff .expo ,
@@ -106,7 +107,6 @@ def are_nodes_in_sync(names):
106
107
# have the same _membership data.Use "this" nodes memebership as
107
108
# "source"
108
109
local_membership_uri = "http://127.0.0.1:5984/_membership"
109
- print ("Fetching CouchDB node mebership from this pod: {0}" .format (local_membership_uri ),flush = True )
110
110
creds = (os .getenv ("COUCHDB_USER" ), os .getenv ("COUCHDB_PASSWORD" ))
111
111
if creds [0 ] and creds [1 ]:
112
112
local_resp = requests .get (local_membership_uri , auth = creds )
@@ -139,20 +139,16 @@ def are_nodes_in_sync(names):
139
139
is_different = True
140
140
if ordered (local_resp .json ()) != ordered (remote_resp .json ()):
141
141
is_different = True
142
- print ("Fetching CouchDB node mebership from this pod: {0}" .format (local_membership_uri ),flush = True )
142
+
143
+ # For logging only...
143
144
records_in_local_but_not_in_remote = set (local_resp .json ()['cluster_nodes' ]) - set (remote_resp .json ()['cluster_nodes' ])
144
- records_in_remote_but_not_in_local = set (remote_resp .json ()['cluster_nodes' ]) - set (local_resp .json ()['cluster_nodes' ])
145
145
if records_in_local_but_not_in_remote :
146
- 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 ))
146
+ print ("\t 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 ))
147
+ records_in_remote_but_not_in_local = set (remote_resp .json ()['cluster_nodes' ]) - set (local_resp .json ()['cluster_nodes' ])
147
148
if records_in_remote_but_not_in_local :
148
- 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 ))
149
+ print ("\t 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 ))
149
150
else :
150
151
is_different = True
151
-
152
- if (remote_resp .status_code == 200 ) and (local_resp .status_code == 200 ):
153
- print ("local: " ,local_resp .json ()['cluster_nodes' ])
154
- print ("remote: " ,remote_resp .json ()['cluster_nodes' ])
155
- print ('returnerar' , not is_different )
156
152
return not is_different
157
153
158
154
def sleep_forever ():
0 commit comments