-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from cdalvaro/feature/restar_salt_master_on_c…
…onfig_changes Restart `salt-master` on config changes
- Loading branch information
Showing
15 changed files
with
177 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck source=assets/runtime/functions.sh | ||
FUNCTIONS_FILE="${SALT_RUNTIME_DIR}/functions.sh" | ||
source "${FUNCTIONS_FILE}" | ||
|
||
function check_for_config_changes() | ||
{ | ||
inotifywait -qq --recursive \ | ||
--event modify,move,create,delete \ | ||
"${SALT_CONFS_DIR}" | ||
} | ||
|
||
while check_for_config_changes; do | ||
log_info "Configuration changes detected. Reloading salt-master ..." | ||
supervisorctl restart salt-master | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Config Reloader Tests | ||
|
||
Checks: | ||
|
||
- `salt-master` is reloaded after config changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# The buffer size in the file server can be adjusted here: | ||
file_buffer_size: 1048576 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
[ "${DEBUG}" == true ] && set -vx | ||
|
||
echo "🧪 Running config-reloader tests ..." | ||
|
||
# https://stackoverflow.com/a/4774063/3398062 | ||
SCRIPT_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" | ||
|
||
# shellcheck source=assets/build/functions.sh | ||
COMMON_FILE="${SCRIPT_PATH}/../lib/common.sh" | ||
source "${COMMON_FILE}" | ||
trap cleanup EXIT | ||
|
||
# Run test instance | ||
echo "==> Starting docker-salt-master (${PLATFORM}) ..." | ||
start_container_and_wait \ | ||
--env SALT_RESTART_MASTER_ON_CONFIG_CHANGE=true \ | ||
--volume "${SCRIPT_PATH}/config":/home/salt/data/config:ro \ | ||
|| error "container started" | ||
ok "container started" | ||
|
||
# Get initial configuration values | ||
echo "==> Checking initial configuration values ..." | ||
FILE_BUFFER_SIZE="$(salt-run config.get file_buffer_size)" | ||
YAML_UTF8="$(salt-run config.get yaml_utf8)" | ||
|
||
FILE_BUFFER_SIZE_EXPECTED=1048576 | ||
YAML_UTF8_EXPECTED= | ||
|
||
check_equal "${FILE_BUFFER_SIZE}" "${FILE_BUFFER_SIZE_EXPECTED}" "file_buffer_size" | ||
check_equal "${YAML_UTF8}" "${YAML_UTF8_EXPECTED}" "yaml_utf8" | ||
|
||
# Update fileserver config | ||
echo "==> Updating file_buffer_size config ..." | ||
FILE_BUFFER_SIZE_EXPECTED=2097152 | ||
sed -i "s/file_buffer_size:.*/file_buffer_size: ${FILE_BUFFER_SIZE_EXPECTED}/" "${SCRIPT_PATH}/config/fileserver.conf" | ||
sleep 30 # Wait for the config to be reloaded | ||
|
||
FILE_BUFFER_SIZE="$(salt-run config.get file_buffer_size)" | ||
check_equal "${FILE_BUFFER_SIZE}" "${FILE_BUFFER_SIZE_EXPECTED}" "file_buffer_size" | ||
|
||
# Create yaml_utf8 config | ||
echo "==> Creating yaml_utf8 config ..." | ||
YAML_UTF8_EXPECTED=True | ||
cat > "${SCRIPT_PATH}/config/yaml_utf8.conf" <<EOF | ||
# Enable extra routines for YAML renderer used states containing UTF characters. | ||
yaml_utf8: ${YAML_UTF8_EXPECTED} | ||
EOF | ||
sleep 30 # Wait for the config to be reloaded | ||
|
||
YAML_UTF8="$(salt-run config.get yaml_utf8)" | ||
check_equal "${YAML_UTF8}" "${YAML_UTF8_EXPECTED}" "yaml_utf8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.