Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that job is unmonitored before monitoring it again #202

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions jobs/cloud_controller_ng/templates/restart_drain.sh.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

source /var/vcap/jobs/cloud_controller_ng/packages/capi_utils/monit_utils.sh

PIDFILE="/var/vcap/sys/run/cloud_controller_ng/restart_drain.pid"

# As this script might run longer than a monit cycle (10s) and thus might be
Expand All @@ -9,7 +11,7 @@ PIDFILE="/var/vcap/sys/run/cloud_controller_ng/restart_drain.pid"
function on_exit {
# Re-enable monitoring of ccng_monit_http_healthcheck. This also enables
# monitoring of nginx_cc and cloud_controller_ng.
/var/vcap/bosh/bin/monit monitor ccng_monit_http_healthcheck
monit_monitor_job ccng_monit_http_healthcheck
rm -f $PIDFILE
}

Expand All @@ -22,6 +24,6 @@ echo "$(date) - pid: $BASHPID - Monit triggered shutdown drain" >> "$LOGFILE"
# Unmonitor cloud_controller_ng. This also unmonitors nginx_cc and
# ccng_monit_http_healthcheck. Monit should not interfere with the graceful
# shutdown.
/var/vcap/bosh/bin/monit unmonitor cloud_controller_ng
monit_unmonitor_job cloud_controller_ng

/var/vcap/jobs/cloud_controller_ng/bin/shutdown_drain 1>&2
11 changes: 11 additions & 0 deletions src/capi_utils/monit_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ function wait_for_server_to_become_healthy() {
return 1
}

# monit_monitor_job
#
# @param job_name
#
# Tells monit to monitor the given job.
#
function monit_monitor_job() {
local job_name="$1"
sudo /var/vcap/bosh/bin/monit monitor "${job_name}"
}

# monit_unmonitor_job
#
# @param job_name
Expand Down