Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
738d959
#695: Adds feature to self-destruct a container after a (1 hour defau…
jdeathe Jun 10, 2019
0bd1b43
#695: Separate out the reaper env variable names from sshd.
jdeathe Jun 12, 2019
6ef33d5
#695: Fixes __reap call and missed variable rename.
jdeathe Jun 12, 2019
6b2eb19
#695: Renames reaper autostart variable in systemd template.
jdeathe Jun 13, 2019
1358399
#695: Adds simplified sessing expiry warnimg message.
jdeathe Jun 14, 2019
b8de2bf
#695: Adds lock file feature to reaper.
jdeathe Jun 14, 2019
ed072a0
#695: Adds feature to get reaper start/end timestamp or ttl (remainin…
jdeathe Jun 14, 2019
86ff3c4
#695: Adds reaper usage help/error catching.
jdeathe Jun 15, 2019
5447f0c
#695: Adds parameters for wall and wall timeout to reaper.
jdeathe Jun 15, 2019
5e6ec08
#695: Adds --timeout parameter to reaper and sets default timeout of …
jdeathe Jun 17, 2019
1970259
Merge branch 'centos-7-develop' into issue/695
jdeathe Jun 20, 2019
3eeb6fc
#695: Renames reaper config file to follow existing p1 processes.
jdeathe Jun 20, 2019
56d75b4
Merge branch 'centos-7-develop' into issue/695
jdeathe Sep 19, 2019
4998338
#695: Adds improved message output.
jdeathe Sep 20, 2019
4e00ad3
#695: Fixes error return code when requesting help
jdeathe Sep 20, 2019
8607a70
#695: Emmit WARN message when expiring session.
jdeathe Sep 20, 2019
414a39b
#695: Fixes WARN messages and quite/silent options.
jdeathe Sep 20, 2019
a3199c3
#695: Adds logging output improvements.
jdeathe Sep 21, 2019
3bcaaa1
#695: Order variables alphabetically.
jdeathe Sep 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
#695: Adds --timeout parameter to reaper and sets default timeout of …
…0 (i.e. immediate execution).
  • Loading branch information
jdeathe committed Jun 17, 2019
commit 5e6ec088a6f1bb09caa54a086ccc61a9381ce9a5
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ENABLE_REAPER=false
REAPER_TIMEOUT=3600
REAPER_TIMEOUT=0
SSH_AUTHORIZED_KEYS=
SSH_AUTOSTART_SSHD=true
SSH_AUTOSTART_SSHD_BOOTSTRAP=true
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Summary of release changes for Version 2 - CentOS-7
- Adds improved `clean` Makefile target; includes exited containers and dangling images.
- Adds feature to optionally exit the container after a specified timout period.
- Adds `ENABLE_REAPER` with a default value of `false` to enable the `reaper` service.
- Adds `REAPER_TIMEOUT` with a default value of `3600` seconds (i.e 1 hour).
- Adds `REAPER_TIMEOUT` with a default value of `0` seconds (i.e no timeout delay).
- Fixes port incrementation failures when installing systemd units via `scmi`.
- Fixes etcd port registration failures when installing systemd units via `scmi` with the `--register` option.
- Fixes binary paths in systemd unit files for compatibility with both EL and Ubuntu hosts.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ EXPOSE 22
# ------------------------------------------------------------------------------
ENV \
ENABLE_REAPER="false" \
REAPER_TIMEOUT="3600" \
REAPER_TIMEOUT="0" \
SSH_AUTHORIZED_KEYS="" \
SSH_AUTOSTART_SSHD="true" \
SSH_AUTOSTART_SSHD_BOOTSTRAP="true" \
Expand Down
2 changes: 1 addition & 1 deletion environment.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ STARTUP_TIME ?= 2
# Application container configuration
# ------------------------------------------------------------------------------
ENABLE_REAPER ?= false
REAPER_TIMEOUT ?= 3600
REAPER_TIMEOUT ?= 0
SSH_AUTHORIZED_KEYS ?=
SSH_AUTOSTART_SSHD ?= true
SSH_AUTOSTART_SSHD_BOOTSTRAP ?= true
Expand Down
2 changes: 1 addition & 1 deletion src/etc/supervisord.d/01-reaper.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[program:reaper]
autorestart = false
autostart = %(ENV_ENABLE_REAPER)s
command = /usr/sbin/reaper --verbose --wall-timeout 30 --wall="Session expiring in 30 seconds."
command = /usr/sbin/reaper --verbose --timeout %(ENV_REAPER_TIMEOUT)s --wall-timeout 30 --wall="Session expiring in 30 seconds."
priority = 1
startsecs = 0
stderr_logfile = /dev/stderr
Expand Down
2 changes: 1 addition & 1 deletion src/etc/systemd/system/centos-ssh@.service
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Environment="DOCKER_IMAGE_TAG={{RELEASE_VERSION}}"
Environment="DOCKER_PORT_MAP_TCP_22=2020"
Environment="DOCKER_USER=jdeathe"
Environment="ENABLE_REAPER=false"
Environment="REAPER_TIMEOUT=3600"
Environment="REAPER_TIMEOUT=0"
Environment="SSH_AUTHORIZED_KEYS="
Environment="SSH_AUTOSTART_SSHD=true"
Environment="SSH_AUTOSTART_SSHD_BOOTSTRAP=true"
Expand Down
2 changes: 1 addition & 1 deletion src/opt/scmi/environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ STARTUP_TIME="${STARTUP_TIME:-2}"
# Application container configuration
# ------------------------------------------------------------------------------
ENABLE_REAPER="${ENABLE_REAPER:-false}"
REAPER_TIMEOUT="${REAPER_TIMEOUT:-3600}"
REAPER_TIMEOUT="${REAPER_TIMEOUT:-0}"
SSH_AUTHORIZED_KEYS="${SSH_AUTHORIZED_KEYS:-}"
SSH_AUTOSTART_SSHD="${SSH_AUTOSTART_SSHD:-true}"
SSH_AUTOSTART_SSHD_BOOTSTRAP="${SSH_AUTOSTART_SSHD_BOOTSTRAP:-true}"
Expand Down
74 changes: 38 additions & 36 deletions src/usr/sbin/reaper
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,6 @@ function __delete_lock ()
fi
}

function __get_reaper_timeout ()
{
local -r default_value="${1:-3600}"

local value="${REAPER_TIMEOUT}"

if ! __is_valid_reaper_timeout "${value}"
then
value="${default_value}"
fi

printf -- '%s' "${value}"
}

function __is_valid_get ()
{
local -r get_options='^(end|start|ttl)$'
Expand All @@ -75,7 +61,7 @@ function __is_valid_positive_integer ()
return 1
}

function __is_valid_reaper_timeout ()
function __is_valid_timeout ()
{
__is_valid_positive_integer "${@}"
}
Expand Down Expand Up @@ -112,6 +98,9 @@ function __usage ()
If not specified the default is pid 1.
-s, --signal SIG Send the signal SIG to the process.
If not specified the default is SIGTERM.
-t, --timeout SECONDS Time in seconds to wait before sending the
signal to the process. The default is 0 seconds
which indicates no delay.
-v, --verbose Output informational messages.
If not specified the default is quiet.
-w, --wall MESSAGE Set a wall message to send before session end.
Expand All @@ -126,9 +115,6 @@ function main ()
{
local -r lock_file="/var/lock/subsys/reaper"
local -r state_file="/var/lib/misc/reaper"
local -r timeout="$(
__get_reaper_timeout
)"

local current_time
local get
Expand All @@ -137,6 +123,7 @@ function main ()
local session_start
local session_end
local state_value
local timeout="0"
local verbose="false"
local wall_message
local wall_timeout="30"
Expand Down Expand Up @@ -171,6 +158,14 @@ function main ()
signal="${2}"
shift 2 || break
;;
-t|--timeout)
timeout="${2}"
shift 2 || break
;;
--timeout=*)
timeout="${1#*=}"
shift 1
;;
-v|--verbose)
verbose="true"
shift 1
Expand Down Expand Up @@ -256,30 +251,37 @@ function main ()
EXIT INT TERM
__create_lock

if ! __is_valid_timeout "${timeout}"
then
>&2 printf -- \
'ERROR: Invalid --timeout\n' \
__usage
fi

if ! __is_valid_wall_timeout "${wall_timeout}"
then
>&2 printf -- \
'ERROR: Invalid --wall-timeout\n' \
__usage
fi

if (( timeout > 0 ))
if [[ -z ${wall_message} ]] \
|| (( timeout <= wall_timeout ))
then
trap __reap \
EXIT INT TERM
wall_timeout="0"
fi

if [[ -z ${wall_message} ]] \
|| (( timeout <= wall_timeout ))
then
wall_timeout="0"
fi
session_start="$(
date -u +%s
)"

session_start="$(
date -u +%s
)"
trap __reap \
EXIT INT TERM

__create_state
__create_state

if (( timeout > 0 ))
then
if coproc read -t "$(( ${timeout} - ${wall_timeout} ))"
then
wait "${!}" || :
Expand All @@ -294,13 +296,13 @@ function main ()
fi
fi
fi
fi

if [[ ${verbose} == true ]]
then
printf -- \
'INFO: %s expiring session.\n' \
"${0##*/}"
fi
if [[ ${verbose} == true ]]
then
printf -- \
'INFO: %s expiring session.\n' \
"${0##*/}"
fi

exit 0
Expand Down