projects
/
mirror
/
dsa-puppet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d4594ee
)
Fix name of variable (it is a timestamp, not a zone) and log a bit more
author
Tollef Fog Heen
<tfheen@err.no>
Sat, 30 Sep 2017 19:52:41 +0000
(21:52 +0200)
committer
Tollef Fog Heen
<tfheen@err.no>
Sat, 30 Sep 2017 19:52:41 +0000
(21:52 +0200)
modules/roles/files/mirror_health/mirror-health
patch
|
blob
|
history
diff --git
a/modules/roles/files/mirror_health/mirror-health
b/modules/roles/files/mirror_health/mirror-health
index
0e10fa7
..
f70cf71
100755
(executable)
--- a/
modules/roles/files/mirror_health/mirror-health
+++ b/
modules/roles/files/mirror_health/mirror-health
@@
-14,7
+14,7
@@
HEALTH_FILE = os.path.join(OUTPUT_DIR, "health")
URL = os.environ['MIRROR_CHECK_URL']
INTERVAL = int(os.environ.get('MIRROR_CHECK_INTERVAL', '60'))
URL = os.environ['MIRROR_CHECK_URL']
INTERVAL = int(os.environ.get('MIRROR_CHECK_INTERVAL', '60'))
-latest_t
z
= 0
+latest_t
s
= 0
def retrieve_from_host(host, url):
proxies = {
def retrieve_from_host(host, url):
proxies = {
@@
-34,18
+34,18
@@
while True:
for host in HOSTS:
lm = last_modified(retrieve_from_host(host, URL))
logging.debug("lm for host %s: %s", host, lm)
for host in HOSTS:
lm = last_modified(retrieve_from_host(host, URL))
logging.debug("lm for host %s: %s", host, lm)
- if lm > latest_t
z
:
- latest_t
z
= lm
+ if lm > latest_t
s
:
+ latest_t
s
= lm
local_lm = last_modified(retrieve_from_host('localhost', URL))
logging.debug("lm for localhost: %s", lm)
local_lm = last_modified(retrieve_from_host('localhost', URL))
logging.debug("lm for localhost: %s", lm)
- if latest_t
z
<= local_lm:
+ if latest_t
s
<= local_lm:
try:
try:
- logging.
debug("considering myself unhealthy"
)
+ logging.
info("considering myself unhealthy my ts=%s latest_ts=%s", local_lm, latest_ts
)
os.remove(HEALTH_FILE)
except OSError:
pass
else:
os.remove(HEALTH_FILE)
except OSError:
pass
else:
- logging.
debug
("considering myself healthy")
+ logging.
info
("considering myself healthy")
open(HEALTH_FILE, 'w').write("OK")
sleep_time = start + INTERVAL - time.time()
logging.debug("sleeping for %d seconds", sleep_time)
open(HEALTH_FILE, 'w').write("OK")
sleep_time = start + INTERVAL - time.time()
logging.debug("sleeping for %d seconds", sleep_time)