Skip to content

Commit

Permalink
Merge pull request #475 from cgalibern/global_expect_unset_after_conf…
Browse files Browse the repository at this point in the history
…_consensus

fix possible provision failure on fresh objects
  • Loading branch information
cgalibern committed Oct 26, 2021
2 parents 010ecb7 + 07d2f63 commit 8c395af
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions opensvc/daemon/monitor.py
Expand Up @@ -3233,7 +3233,7 @@ def wait_service_config_consensus(self, path, peers, timeout=60):
path, timeout)
return False

def service_config_consensus(self, path, peers):
def has_service_config_consensus(self, path, peers):
if len(peers) < 2:
self.log.debug("%s auto consensus. peers: %s", path, peers)
return True
Expand All @@ -3255,6 +3255,11 @@ def service_config_consensus(self, path, peers):
if ref_csum is not None and ref_csum != csum:
# self.log.debug("service %s peer %s has a different config cksum", path, peer)
return False
return True

def service_config_consensus(self, path, peers):
if not self.has_service_config_consensus(path, peers):
return False
self.log.info("service %s config consensus reached", path)
return True

Expand Down Expand Up @@ -3449,12 +3454,24 @@ def set_smon_g_expect_from_status(self, path, smon, status):
"""
Align global_expect with the actual service states.
"""
instance = self.get_service_instance(path, Env.nodename)
agg = self.get_service_agg(path)
try:
ge, at = smon.global_expect.split("@", 1)
handler = "handle_%s_at" % ge
except AttributeError:
return
except ValueError:
handler = "handle_" + smon.global_expect

instance = self.get_service_instance(path, Env.nodename)
if instance is None:
return

svc = self.get_service(path)
if svc and not self.has_service_config_consensus(path, svc.peers):
self.log.debug("%s has not yet config consensus", path)
return
agg = self.get_service_agg(path)

def handle_stopped():
local_frozen = instance.get("frozen", 0)
stopped = status in STOPPED_STATES
Expand Down Expand Up @@ -3574,14 +3591,6 @@ def handle_placed_at():
if self.instances_started_or_start_failed(path, target):
self.set_smon(path, global_expect="unset")

try:
ge, at = smon.global_expect.split("@", 1)
handler = "handle_%s_at" % ge
except AttributeError:
return
except ValueError:
handler = "handle_" + smon.global_expect

try:
fn = locals()[handler]
except KeyError:
Expand Down

0 comments on commit 8c395af

Please sign in to comment.