-
Notifications
You must be signed in to change notification settings - Fork 74
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
Addition of disable-debug mode to ECS Logs Collector #79
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,7 @@ mode='brief' # defined in parse_options | |
# --------------------------------------------------------------------------------------- | ||
|
||
help() { | ||
echo "USAGE: ${progname} [--mode=[brief|enable-debug]]" | ||
echo "USAGE: ${progname} [--mode=[brief|enable-debug|disable-debug]]" | ||
echo " ${progname} --help" | ||
echo "" | ||
echo "OPTIONS:" | ||
|
@@ -77,6 +77,8 @@ help() { | |
echo " enable-debug Enables debug mode for the Docker daemon and the Amazon" | ||
echo " ECS Container Agent. Only supported on Systemd init systems" | ||
echo " and Amazon Linux." | ||
echo " disable-debug Disables debug mode for the Docker daemon and the Amazon" | ||
echo " ECS Container Agent. reverse of enable-debug option." | ||
} | ||
|
||
parse_options() { | ||
|
@@ -193,6 +195,13 @@ enable_debug() { | |
enable_ecs_agent_debug | ||
} | ||
|
||
disable_debug() { | ||
is_root | ||
get_init_type | ||
disable_docker_debug | ||
disable_ecs_agent_debug | ||
} | ||
|
||
# Routines | ||
# --------------------------------------------------------------------------------------- | ||
|
||
|
@@ -797,6 +806,80 @@ enable_ecs_agent_debug() { | |
fi | ||
} | ||
|
||
disable_docker_debug() { | ||
try "disable debug mode for the Docker daemon" | ||
|
||
if [ -e /etc/sysconfig/docker ] && ! grep -q "^\\s*OPTIONS=\"-D" /etc/sysconfig/docker; then | ||
info "Debug mode is already disabled." | ||
else | ||
|
||
if [ -e /etc/sysconfig/docker ]; then | ||
case "${init_type}" in | ||
systemd) | ||
# sed -i 's/^OPTIONS="\(.*\)/OPTIONS="-D \1/g' /etc/sysconfig/docker | ||
sed -i 's/\-D//g' /etc/sysconfig/docker | ||
ok | ||
Comment on lines
+820
to
+821
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems to be common to both cases (systemd and *). can we move this to be before the case and remove it here and L829 below? |
||
|
||
try "restart Docker daemon to enable debug mode" | ||
systemctl restart docker.service | ||
ok | ||
;; | ||
*) | ||
# echo "OPTIONS=\"-D \$OPTIONS\"" >> /etc/sysconfig/docker | ||
sed -i 's/\-D//g' /etc/sysconfig/docker | ||
|
||
try "restart Docker daemon to enable debug mode" | ||
service docker restart | ||
ok | ||
|
||
esac | ||
|
||
else | ||
warning "the current operating system is not supported." | ||
fi | ||
fi | ||
} | ||
|
||
disable_ecs_agent_debug() { | ||
try "disable debug mode for the Amazon ECS Container Agent" | ||
|
||
if [ -e /etc/ecs/ecs.config ] && ! grep -q "^\\s*ECS_LOGLEVEL=debug" /etc/ecs/ecs.config; then | ||
info "Debug mode is already disabled." | ||
|
||
else | ||
case "${init_type}" in | ||
systemd) | ||
if [ ! -d /etc/ecs ]; then | ||
mkdir /etc/ecs | ||
fi | ||
Comment on lines
+852
to
+854
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if |
||
|
||
sed -i '/^\s*ECS_LOGLEVEL=debug/d' /etc/ecs/ecs.config | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this sets the log level to debug, instead of unsetting it or setting it back to info |
||
ok | ||
|
||
try "restart the Amazon ECS Container Agent to disable debug mode" | ||
systemctl restart ecs | ||
ok | ||
;; | ||
*) | ||
if rpm -q --quiet ecs-init; then | ||
if [ ! -d /etc/ecs ]; then | ||
mkdir /etc/ecs | ||
fi | ||
|
||
sed -i '/^\s*ECS_LOGLEVEL=debug/d' /etc/ecs/ecs.config | ||
ok | ||
|
||
try "restart the Amazon ECS Container Agent to disable debug mode" | ||
stop ecs; start ecs | ||
ok | ||
else | ||
warning "the current operating system is not supported." | ||
fi | ||
;; | ||
esac | ||
fi | ||
} | ||
|
||
# nvidia-smi is a tool available on GPU based AMIs provides detailed | ||
# information about the GPU present on the VM. | ||
get_gpu_info() { | ||
|
@@ -832,6 +915,9 @@ case "${mode}" in | |
enable-debug) | ||
enable_debug | ||
;; | ||
disable-debug) | ||
disable_debug | ||
;; | ||
*) | ||
help && exit 1 | ||
;; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: lets remove this comment and L828