...
 
Commits (2)
......@@ -2367,16 +2367,23 @@ class ContainerDocker(Container):
# search for image based on name
# expecting command like '/apps/jupyter/r16/middleware/invoke'
toolname = command.split('/')[2]
revision = command.split('/')[3]
# toolname should be like 'jupyter'
image_test = ['docker', 'image', 'ls', toolname, '-q']
image_test = ['docker', 'image', 'ls', toolname + '_' + revision, '-q']
p = subprocess.Popen(image_test, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
if len(stdout) > 0:
args += [toolname]
elif 'DOCKER_IMAGE_TOOL' in self.k:
args += [self.k["DOCKER_IMAGE_TOOL"]]
args += [toolname + '_' + revision]
else:
args += ['hubzero_tools']
image_test = ['docker', 'image', 'ls', toolname, '-q']
p = subprocess.Popen(image_test, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
if len(stdout) > 0:
args += [toolname]
elif 'DOCKER_IMAGE_TOOL' in self.k:
args += [self.k["DOCKER_IMAGE_TOOL"]]
else:
args += ['hubzero_tools']
if DEBUG:
log("DEBUG: command is %s" % args)
......
......@@ -870,7 +870,7 @@ class Session:
status = int(v)
elif k == 'squid':
# expecting string like toolname/revision/hashkey
if re.match('\A[a-z0-9_\-]+/[0-9]+/[a-z0-9]{40}\Z', v) is None:
if re.match(r'\A[a-z0-9_\-]+/[0-9]+/[a-z0-9]{40}\Z', v) is None:
continue
squid = v
else:
......
......@@ -252,7 +252,9 @@ class User_account():
def group_pairs(self):
"""return array of pairs of group names, gids
something like this [['group10', 10], ['group11', 11]]
encapsulate calls to getgrnam()."""
encapsulate calls to getgrnam().
This function can fail when calling grp.getgrnam due to LDAP or network issues,
or due to race conditions when group memberships change just when a tool is launched"""
import grp
groups_a = []
for g in self.groups():
......@@ -263,6 +265,8 @@ class User_account():
groups_a.append([gname, gid])
except EnvironmentError:
pass
except KeyError:
raise MaxwellError("Error: Info unavailable for group '%s'." % g)
return groups_a
def ext_homedir(self):
......