1
0
mirror of https://github.com/phusion/baseimage-docker.git synced 2026-03-26 04:18:46 +00:00

Compare commits

..

5 Commits

Author SHA1 Message Date
Hongli Lai (Phusion)
775ded05dc Fix permissions on test scripts 2014-02-26 11:56:19 +01:00
Hongli Lai (Phusion)
cc9847580d Document release date 2014-02-26 11:56:10 +01:00
Hongli Lai (Phusion)
46334c7363 Bump version to 0.9.8 2014-02-26 11:44:19 +01:00
Hongli Lai (Phusion)
1684aa1448 Fix my_init not properly forcing Runit to shut down if Runit appears to refuse to respond to SIGTERM. 2014-02-25 22:49:34 +01:00
Hongli Lai (Phusion)
367cddb201 Fix a regression in my_init which causes it to delete environment variables passed from Docker. 2014-02-25 22:08:37 +01:00
5 changed files with 31 additions and 7 deletions

View File

@@ -1,3 +1,8 @@
## 0.9.8 (release date: 2014-02-26)
* Fixed a regression in `my_init` which causes it to delete environment variables passed from Docker.
* Fixed `my_init` not properly forcing Runit to shut down if Runit appears to refuse to respond to SIGTERM.
## 0.9.7 (release date: 2014-02-25) ## 0.9.7 (release date: 2014-02-25)
* Improved and fixed bugs in `my_init` (Thomas LÉVEIL): * Improved and fixed bugs in `my_init` (Thomas LÉVEIL):

View File

@@ -1,5 +1,5 @@
NAME = phusion/baseimage NAME = phusion/baseimage
VERSION = 0.9.7 VERSION = 0.9.8
.PHONY: all build test tag_latest release ssh .PHONY: all build test tag_latest release ssh

View File

@@ -54,14 +54,15 @@ def is_exe(path):
except OSError: except OSError:
return False return False
def import_envvars(): def import_envvars(clear_existing_environment = True):
new_env = {} new_env = {}
for envfile in listdir("/etc/container_environment"): for envfile in listdir("/etc/container_environment"):
name = os.path.basename(envfile) name = os.path.basename(envfile)
with open("/etc/container_environment/" + envfile, "r") as f: with open("/etc/container_environment/" + envfile, "r") as f:
value = f.read() value = f.read()
new_env[name] = value new_env[name] = value
os.environ.clear() if clear_existing_environment:
os.environ.clear()
for name, value in new_env.items(): for name, value in new_env.items():
os.environ[name] = value os.environ[name] = value
@@ -93,6 +94,13 @@ def shquote(s):
def waitpid_reap_other_children(pid): def waitpid_reap_other_children(pid):
done = False done = False
status = None status = None
try:
this_pid, status = os.waitpid(pid, os.WNOHANG)
except OSError as e:
if e.errno == errno.ECHILD or e.errno == errno.ESRCH:
return None
else:
raise
while not done: while not done:
this_pid, status = os.waitpid(-1, 0) this_pid, status = os.waitpid(-1, 0)
done = this_pid == pid done = this_pid == pid
@@ -134,7 +142,10 @@ def run_command_killable(*argv):
stop_child_process(filename, pid) stop_child_process(filename, pid)
raise raise
if status != 0: if status != 0:
error("%s failed with exit code %d\n" % (filename, status)) if status is None:
error("%s exited with unknown exit code\n" % filename)
else:
error("%s failed with exit code %d\n" % (filename, status))
sys.exit(1) sys.exit(1)
def run_command_killable_and_import_envvars(*argv): def run_command_killable_and_import_envvars(*argv):
@@ -213,7 +224,7 @@ def install_insecure_key():
run_command_killable("/usr/sbin/enable_insecure_key") run_command_killable("/usr/sbin/enable_insecure_key")
def main(args): def main(args):
import_envvars() import_envvars(False)
export_envvars() export_envvars()
if args.enable_insecure_key: if args.enable_insecure_key:
@@ -231,13 +242,21 @@ def main(args):
if len(args.main_command) == 0: if len(args.main_command) == 0:
runit_exited, exit_code = wait_for_runit_or_interrupt(runit_pid) runit_exited, exit_code = wait_for_runit_or_interrupt(runit_pid)
if runit_exited: if runit_exited:
info("Runit exited with code %d" % exit_code) if exit_code is None:
info("Runit exited with unknown exit code")
exit_code = 1
else:
info("Runit exited with code %d" % exit_code)
else: else:
info("Running %s..." % " ".join(args.main_command)) info("Running %s..." % " ".join(args.main_command))
pid = os.spawnvp(os.P_NOWAIT, args.main_command[0], args.main_command) pid = os.spawnvp(os.P_NOWAIT, args.main_command[0], args.main_command)
try: try:
exit_code = waitpid_reap_other_children(pid) exit_code = waitpid_reap_other_children(pid)
info("%s exited with exit code %d." % (args.main_command[0], exit_code)) if exit_code is None:
info("%s exited with unknown exit code." % args.main_command[0])
exit_code = 1
else:
info("%s exited with exit code %d." % (args.main_command[0], exit_code))
except KeyboardInterrupt: except KeyboardInterrupt:
stop_child_process(args.main_command[0], pid) stop_child_process(args.main_command[0], pid)
except BaseException as s: except BaseException as s:

0
test/runner.sh Normal file → Executable file
View File

0
test/test.sh Normal file → Executable file
View File