Skip to content

Commit bb725fc

Browse files
committed
Merge pull request #1112 from deis/check-configs
fix(confd): services check for valid config before reloading
2 parents ded216f + 0472135 commit bb725fc

9 files changed

Lines changed: 63 additions & 5 deletions

File tree

controller/bin/check

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
#
3+
# Check that the configuration for deis-controller is valid.
4+
#
5+
6+
if [[ -f /templates/confd_settings.py ]] ; then
7+
set -e
8+
9+
# check that "<no value>" isn't in the templated file
10+
grep -q -v "<no value>" /templates/confd_settings.py
11+
12+
THIS_DIR=$(cd $(dirname $0); pwd) # absolute path
13+
PARENT_DIR=$(dirname $THIS_DIR)
14+
15+
# check the Django configuration file compatibility
16+
$PARENT_DIR/manage.py check > /dev/null
17+
18+
# validate the Django models
19+
$PARENT_DIR/manage.py validate > /dev/null
20+
fi

controller/conf.d/confd_settings.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ keys = [
1111
"/deis/registry",
1212
"/deis/domains",
1313
]
14-
check_cmd = "test -e {{ .src }}"
14+
check_cmd = "/app/bin/check"
1515
reload_cmd = "/app/bin/reload"

database/bin/check

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
#
3+
# Check that the configuration for deis-database is valid.
4+
#
5+
6+
set -e
7+
8+
# check that "<no value>" isn't in the templated files
9+
if [[ -f /etc/postgresql/9.3/main/postgresql.conf ]] ; then
10+
grep -q -v "<no value>" /etc/postgresql/9.3/main/postgresql.conf
11+
fi
12+
if [[ -f /etc/postgresql/9.3/main/pg_hba.conf ]] ; then
13+
grep -q -v "<no value>" /etc/postgresql/9.3/main/pg_hba.conf
14+
fi
15+
if [[ -f /usr/local/bin/reload ]] ; then
16+
grep -q -v "<no value>" /usr/local/bin/reload
17+
fi

database/conf.d/pg_hba.conf.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ gid = 104
66
mode = "0640"
77
keys = [
88
"/deis/database",
9-
]
9+
]
10+
check_cmd = "/app/bin/check"
11+
reload_cmd = "/usr/local/bin/reload"

database/conf.d/postgresql.conf.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ gid = 104
66
mode = "0644"
77
keys = [
88
"/deis/database",
9-
]
9+
]
10+
check_cmd = "/app/bin/check"
11+
reload_cmd = "/usr/local/bin/reload"

database/conf.d/reload.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ mode = "0755"
77
keys = [
88
"/deis/database",
99
]
10-
check_cmd = "netstat -lnt | awk '$6 == \"LISTEN\" && $4 ~ \".5432\"' "
11-
reload_cmd = "/usr/local/bin/reload"
10+
check_cmd = "/app/bin/check"
11+
reload_cmd = "/usr/local/bin/reload"

registry/bin/check

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
#
3+
# Check that the configuration for deis-registry is valid.
4+
#
5+
6+
if [[ -f /docker-registry/config/config.yml ]] ; then
7+
set -e
8+
9+
# check that "<no value>" isn't in the templated file
10+
grep -q -v "<no value>" /docker-registry/config/config.yml
11+
fi

registry/bin/reload

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
# Send SIGHUP to gunicorn in general, since we didn't launch it with `--pid`
4+
pkill -HUP -u registry gunicorn

registry/conf.d/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ mode = "0644"
77
keys = [
88
"/deis/registry",
99
]
10+
check_cmd = "/app/bin/check"
11+
reload_cmd = "/app/bin/reload"

0 commit comments

Comments
 (0)