Description:
Get the lock lease time from the ingest cycle time
The scripts "queue" and "review" acquire locks to avoid concurrent
runs of these scripts on multiple instances.
The lease time for these locks can and should be set from the
"cycle time" of the scripts. Curtis suggested to keep the lock
for twice as long; I added one minute more to avoid possible
spurious errors that might occur due to clock skew between two
servers.
+from charmsupport.hookenv import config
from charmsupport.hookenv import related_units
from charmsupport.hookenv import relation_ids
@@ -18,6 +19,13 @@
def write_new_config(mongo_url, default, override, target):
new_config = read_config([default, override])
new_config.set('app:main', 'mongo.url', mongo_url)
+ # script_lease_time specifies the time for which the scripts
+ # "queue" and "review" hold their locks. Set to twice the time
+ # interval execute-ingest-every, plus 1 minute slack to address
+ # a possible clock skew between two instances.
+ new_config.set(
+ 'app:main', 'script_lease_time',
+ config()['execute-ingest-every'] * 2 + 1)
with open(target, 'w') as output: new_config.write(output)
Reviewers: mp+151056_ code.launchpad. net,
Message:
Please take a look.
Description:
Get the lock lease time from the ingest cycle time
The scripts "queue" and "review" acquire locks to avoid concurrent
runs of these scripts on multiple instances.
The lease time for these locks can and should be set from the
"cycle time" of the scripts. Curtis suggested to keep the lock
for twice as long; I added one minute more to avoid possible
spurious errors that might occur due to clock skew between two
servers.
https:/ /code.launchpad .net/~adeuring/ charms/ precise/ charmworld/ charm-set- lock-timeout/ +merge/ 151056
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/7422045/
Affected files: write_config. py
A [revision details]
M scripts/
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>
Index: scripts/ write_config. py write_config. py' write_config. py 2013-02-14 19:10:58 +0000 write_config. py 2013-02-28 16:49:04 +0000
=== modified file 'scripts/
--- scripts/
+++ scripts/
@@ -5,6 +5,7 @@
import subprocess
import sys
+from charmsupport. hookenv import config hookenv import related_units hookenv import relation_ids
from charmsupport.
from charmsupport.
@@ -18,6 +19,13 @@ config( mongo_url, default, override, target): [default, override]) config. set('app: main', 'mongo.url', mongo_url) ingest- every, plus 1 minute slack to address lease_time' , )['execute- ingest- every'] * 2 + 1)
new_ config. write(output)
def write_new_
new_config = read_config(
new_
+ # script_lease_time specifies the time for which the scripts
+ # "queue" and "review" hold their locks. Set to twice the time
+ # interval execute-
+ # a possible clock skew between two instances.
+ new_config.set(
+ 'app:main', 'script_
+ config(
with open(target, 'w') as output: