Attempt to fix race condition

This commit is contained in:
Samuel M Smith 2014-06-20 12:56:15 -06:00
parent d2f82c8bba
commit 1066d9d618
3 changed files with 45 additions and 6 deletions

View File

@ -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):

View File

@ -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

View File

@ -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()