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

[cli] Add ability to skip config regeneration when starting #4244

Merged
merged 4 commits into from
Mar 1, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions dockerfiles/base/scripts/base/commands/cmd_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,34 @@ before execution. If you have mounted a local repository or assembly, the ${CHE_
images will use those binaries instead of their embedded ones.\n"
text "\n"
text "PARAMETERS:\n"
text " --force Uses 'docker rmi' and 'docker pull' to forcibly retrieve latest images\n"
text " --no-force Updates images if matching tag not found in local cache\n"
text " --pull Uses 'docker pull' to check for new remote versions of images\n"
text " --force Uses 'docker rmi' and 'docker pull' to forcibly retrieve latest images\n"
text " --skip:config Skip re-generation of config files placed into /instance\n"
text "\n"
}

pre_cmd_config() {
:
CHE_SKIP_CONFIG=false
FORCE_UPDATE="--no-force"

while [ $# -gt 0 ]; do
case $1 in
--skip:config)
CHE_SKIP_CONFIG=true
shift ;;
--force)
FORCE_UPDATE="--force"
shift ;;
--no-force)
FORCE_UPDATE="--no-force"
shift ;;
--pull)
FORCE_UPDATE="--pull"
shift ;;
*) error "Unknown parameter: $1" return 2 ;;
esac
done
}

post_cmd_config() {
Expand All @@ -39,7 +59,6 @@ post_cmd_config() {
cmd_config() {
# If the system is not initialized, initalize it.
# If the system is already initialized, but a user wants to update images, then re-download.
FORCE_UPDATE=${1:-"--no-force"}
if ! is_initialized; then
cmd_lifecycle init $FORCE_UPDATE
elif [[ "${FORCE_UPDATE}" == "--pull" ]] || \
Expand All @@ -62,7 +81,9 @@ cmd_config() {
info "config" "Generating $CHE_MINI_PRODUCT_NAME configuration..."

# Run the docker configurator
generate_configuration_with_puppet
if ! skip_config; then
generate_configuration_with_puppet
fi

# Replace certain environment file lines with their container counterparts
info "config" "Customizing docker-compose for running in a container"
Expand Down
2 changes: 2 additions & 0 deletions dockerfiles/base/scripts/base/commands/cmd_restart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ help_cmd_restart() {
text " --force Uses 'docker rmi' and 'docker pull' to forcibly retrieve latest images\n"
text " --no-force Updates images if matching tag not found in local cache\n"
text " --pull Uses 'docker pull' to check for new remote versions of images\n"
text " --skip:config Skip re-generation of config files placed into /instance\n"
text " --skip:graceful Do not wait for confirmation that workspaces have stopped\n"
text " --skip:preflight Skip preflight checks\n"
text " --skip:postflight Skip postflight checks\n"
text "\n"
}

Expand Down
64 changes: 59 additions & 5 deletions dockerfiles/base/scripts/base/commands/cmd_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,41 @@ help_cmd_start() {
text " --force Uses 'docker rmi' and 'docker pull' to forcibly retrieve latest images\n"
text " --no-force Updates images if matching tag not found in local cache\n"
text " --pull Uses 'docker pull' to check for new remote versions of images\n"
text " --skip:config Skip re-generation of config files placed into /instance\n"
text " --skip:preflight Skip preflight checks\n"
text " --skip:postflight Skip postflight checks\n"
text "\n"
}

pre_cmd_start() {
:
CHE_SKIP_CONFIG=false
CHE_SKIP_PREFLIGHT=false
CHE_SKIP_POSTFLIGHT=false
FORCE_UPDATE="--no-force"

while [ $# -gt 0 ]; do
case $1 in
--skip:config)
CHE_SKIP_CONFIG=true
shift ;;
--skip:preflight)
CHE_SKIP_PREFLIGHT=true
shift ;;
--skip:postflight)
CHE_SKIP_POSTFLIGHT=true
shift ;;
--force)
FORCE_UPDATE="--force"
shift ;;
--no-force)
FORCE_UPDATE="--no-force"
shift ;;
--pull)
FORCE_UPDATE="--pull"
shift ;;
*) error "Unknown parameter: $1" return 2 ;;
esac
done
}

post_cmd_start() {
Expand All @@ -40,12 +69,13 @@ cmd_start() {
return 1
fi

# To protect users from accidentally updating their ${CHE_FORMAL_PRODUCT_NAME} servers when they didn't mean
# to, which can happen if CHE_VERSION=latest
FORCE_UPDATE=${1:-"--no-force"}
# Always regenerate puppet configuration from environment variable source, whether changed or not.
# If the current directory is not configured with an .env file, it will initialize
cmd_lifecycle config $FORCE_UPDATE
if skip_config; then
cmd_lifecycle config $FORCE_UPDATE --skip:config
else
cmd_lifecycle config $FORCE_UPDATE
fi

# Preflight checks
# a) Check for open ports
Expand Down Expand Up @@ -255,3 +285,27 @@ check_containers_are_running() {
done <<< "${CONTAINER_ID_MATCHING_SERVICE_NAMES}"
done <<< "${LIST_OF_COMPOSE_CONTAINERS}"
}

skip_config() {
if [ "${CHE_SKIP_CONFIG}" = "true" ]; then
return 0
else
return 1
fi
}

skip_preflight() {
if [ "${CHE_SKIP_PREFLIGHT}" = "true" ]; then
return 0
else
return 1
fi
}

skip_postflight() {
if [ "${CHE_SKIP_POSTFLIGHT}" = "true" ]; then
return 0
else
return 1
fi
}
12 changes: 0 additions & 12 deletions dockerfiles/base/scripts/base/startup_01_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ init_global_vars() {
FAST_BOOT=false
CHE_DEBUG=false
CHE_OFFLINE=false
CHE_SKIP_PREFLIGHT=false
CHE_SKIP_POSTFLIGHT=false
CHE_SKIP_NIGHTLY=false
CHE_SKIP_NETWORK=false
CHE_SKIP_PULL=false
Expand Down Expand Up @@ -209,14 +207,6 @@ init_usage_check() {
set -x
fi

if [[ "$@" == *"--skip:preflight"* ]]; then
CHE_SKIP_PREFLIGHT=true
fi

if [[ "$@" == *"--skip:postflight"* ]]; then
CHE_SKIP_POSTFLIGHT=true
fi

if [[ "$@" == *"--skip:nightly"* ]]; then
CHE_SKIP_NIGHTLY=true
fi
Expand Down Expand Up @@ -329,8 +319,6 @@ start() {
set -- "${@/\-\-debug/}"
set -- "${@/\-\-offline/}"
set -- "${@/\-\-trace/}"
set -- "${@/\-\-skip\:preflight/}"
set -- "${@/\-\-skip\:postflight/}"
set -- "${@/\-\-skip\:nightly/}"
set -- "${@/\-\-skip\:network/}"
set -- "${@/\-\-skip\:pull/}"
Expand Down
16 changes: 0 additions & 16 deletions dockerfiles/base/scripts/base/startup_02_pre_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,6 @@ is_trace() {
fi
}

skip_preflight() {
if [ "${CHE_SKIP_PREFLIGHT}" = "true" ]; then
return 0
else
return 1
fi
}

skip_postflight() {
if [ "${CHE_SKIP_POSTFLIGHT}" = "true" ]; then
return 0
else
return 1
fi
}

skip_nightly() {
if [ "${CHE_SKIP_NIGHTLY}" = "true" ]; then
return 0
Expand Down