From 1066d9d618da1ecca093274f0f0f6795dd780eef Mon Sep 17 00:00:00 2001 From: Samuel M Smith Date: Fri, 20 Jun 2014 12:56:15 -0600 Subject: [PATCH] Attempt to fix race condition --- salt/daemons/flo/core.py | 39 +++++++++++++++++++++++++++++- salt/daemons/flo/minion.flo | 4 ++- salt/daemons/test/test_saltsafe.py | 8 +++--- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/salt/daemons/flo/core.py b/salt/daemons/flo/core.py index 659a801c4a..6b34183f05 100644 --- a/salt/daemons/flo/core.py +++ b/salt/daemons/flo/core.py @@ -181,6 +181,8 @@ class SaltRaetRoadStackJoined(ioflo.base.deeding.Deed): stack='stack', status=odict(ipath='status', ival=odict(joined=False, allowed=False, + alived=False, + rejected=False, idle=False, ))) def action(self, **kwa): @@ -195,6 +197,39 @@ class SaltRaetRoadStackJoined(ioflo.base.deeding.Deed): self.status.update(joined=joined) +class SaltRaetRoadStackRejected(ioflo.base.deeding.Deed): + ''' + Updates status with rejected of .acceptance of zeroth remote estate (master) + FloScript: + + do salt raet road stack rejected + go next if rejected in .raet.udp.stack.status + + ''' + Ioinits = odict( + inode=".raet.udp.stack.", + stack='stack', + status=odict(ipath='status', ival=odict(joined=False, + allowed=False, + alived=False, + rejected=False, + idle=False, ))) + + def action(self, **kwa): + ''' + Update .status share + ''' + stack = self.stack.value + rejected = False + if stack and isinstance(stack, RoadStack): + if stack.remotes: + rejected = (stack.remotes.values()[0].acceptance + == raeting.acceptances.rejected) + else: #no remotes so assume rejected + rejected = True + self.status.update(rejected=rejected) + + class SaltRaetRoadStackAllower(ioflo.base.deeding.Deed): ''' Initiates allow (CurveCP handshake) transaction with master @@ -214,7 +249,7 @@ class SaltRaetRoadStackAllower(ioflo.base.deeding.Deed): ''' stack = self.stack.value if stack and isinstance(stack, RoadStack): - stack.allow() + stack.allow(timeout=0.0) return None @@ -232,6 +267,8 @@ class SaltRaetRoadStackAllowed(ioflo.base.deeding.Deed): stack='stack', status=odict(ipath='status', ival=odict(joined=False, allowed=False, + alived=False, + rejected=False, idle=False, ))) def action(self, **kwa): diff --git a/salt/daemons/flo/minion.flo b/salt/daemons/flo/minion.flo index 1c15bf2682..c5e76e0714 100644 --- a/salt/daemons/flo/minion.flo +++ b/salt/daemons/flo/minion.flo @@ -32,8 +32,10 @@ framer bootstrap be active first join do salt raet road stack joiner per inode ".raet.udp.stack." recur do salt raet road stack joined per inode ".raet.udp.stack." + do salt raet road stack rejected per inode ".raet.udp.stack." go next if joined in .raet.udp.stack.status + #go abort if rejected in .raet.udp.stack.status #go abort if elapsed >= 10 frame joined @@ -48,7 +50,7 @@ framer bootstrap be active first join do salt raet road stack allowed per inode ".raet.udp.stack." go next if allowed in .raet.udp.stack.status - go abort if elapsed >= 5 + #go abort if elapsed >= 5 frame allowed print Allowed diff --git a/salt/daemons/test/test_saltsafe.py b/salt/daemons/test/test_saltsafe.py index 99f6c9e16b..c87cd5fbf3 100644 --- a/salt/daemons/test/test_saltsafe.py +++ b/salt/daemons/test/test_saltsafe.py @@ -271,13 +271,13 @@ class BasicTestCase(unittest.TestCase): 'name': 'remote1', 'ha': ['127.0.0.1', 7532], 'sid': 0, - 'rsid': 0}, + 'joined': None,}, '4': {'uid': 4, 'name': 'remote2', 'ha': ['127.0.0.1', 7533], 'sid': 0, - 'rsid': 0}}) + 'joined': None,}}) # now recreate with saved data main.server.close() @@ -355,13 +355,13 @@ class BasicTestCase(unittest.TestCase): 'name': 'remote3', 'ha': ['127.0.0.1', 7534], 'sid': 0, - 'rsid': 0}, + 'joined': None,}, '4': {'uid': 4, 'name': 'remote4', 'ha': ['127.0.0.1', 7535], 'sid': 0, - 'rsid': 0}}) + 'joined': None,}}) main.server.close() other.server.close()