Skip to content

Commit d0c3cc9

Browse files
committed
Have update-all-remote-wn-ce run updaters with a timeout (SOFTWARE-4081)
1 parent b74a974 commit d0c3cc9

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

config/endpoints.ini

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
;;remote_dir = /home/bosco/osg-wn-client
1616
;;; ssh_key (optional) is the SSH key to use to log in with
1717
;;ssh_key = /home/osg/.ssh/id_rsa_bosco
18-
18+
;;; timeout (optional, default 3600 i.e. 1 hour) is the number of seconds to give the updater before killing it
19+
;;timeout = 3600
1920

2021
;;; These are default values that will be used unless overridden in the other
2122
;;; sections.
2223
[DEFAULT]
2324
upstream_url = https://repo.opensciencegrid.org/tarball-install/3.5/osg-wn-client-latest.el7.x86_64.tar.gz
2425
remote_dir = /home/bosco/osg-wn-client
26+
timeout = 3600

scripts/update-all-remote-wn-clients

+22
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import re
99
from subprocess import Popen, STDOUT
1010
import sys
1111

12+
# noinspection PyUnresolvedReferences
1213
from six.moves import configparser
1314

1415

@@ -46,6 +47,18 @@ def call_updater(cfg, section, updater_script, log_dir, dry_run=False):
4647
upstream_url = safe_get("upstream_url")
4748
remote_user = safe_get("remote_user")
4849
remote_dir = safe_get("remote_dir")
50+
# Have default timeout be nonzero
51+
if not cfg.has_section(section) or not cfg.has_option(section, "timeout"):
52+
timeout = "3600"
53+
else:
54+
timeout = safe_get("timeout")
55+
try:
56+
if timeout:
57+
timeout = int(timeout)
58+
else:
59+
timeout = 0
60+
except ValueError as e:
61+
raise Error("%s: Invalid timeout %s" % (section, timeout))
4962

5063
if not local_user:
5164
raise Error("%s: Missing required option local_user" % section)
@@ -64,6 +77,10 @@ def call_updater(cfg, section, updater_script, log_dir, dry_run=False):
6477
if remote_dir:
6578
cmd.append("--remote-dir=%s" % remote_dir)
6679

80+
if timeout:
81+
cmd.insert(0, "timeout")
82+
cmd.insert(1, str(timeout))
83+
6784
if dry_run:
6885
print("Would run %r as %s" % (cmd, local_user))
6986
return
@@ -86,6 +103,11 @@ def call_updater(cfg, section, updater_script, log_dir, dry_run=False):
86103

87104
if returncode == 0:
88105
log.info("Endpoint %s ok.", endpoint)
106+
elif returncode == 124:
107+
raise Error(
108+
"Endpoint %s TIMED OUT. See %s for details."
109+
% (endpoint, log_file_path)
110+
)
89111
else:
90112
raise Error(
91113
"Endpoint %s FAILED with error %d. See %s for details."

0 commit comments

Comments
 (0)