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

Addresses logging failure and ENTESB-12633 #218

Merged
merged 3 commits into from Feb 19, 2020
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
17 changes: 13 additions & 4 deletions base_functions.sh
Expand Up @@ -4,7 +4,8 @@

check_error() {
local msg="$*"
if [ "${msg//ERROR/}" != "${msg}" ]; then
local umsg==${msg^^} # Upper-case everything to ensure 'error' is detected as well as 'ERROR'
if [ "${umsg//ERROR/}" != "${umsg}" ]; then
if [ -n "${ERROR_FILE:-}" ] && [ -f "$ERROR_FILE" ] && ! grep "$msg" $ERROR_FILE ; then
local tmp=$(mktemp /tmp/error-XXXX)
echo ${msg} >> $tmp
Expand All @@ -23,15 +24,23 @@ check_error() {
print_error() {
local error_file="${1:-}"
if [ -f $error_file ]; then
if grep -q "ERROR" $error_file; then
# The word 'error' can be upper or lower case
if grep -q "ERROR\|error" $error_file; then
cat $error_file
fi
rm $error_file
fi
}

ERROR_FILE="$(mktemp /tmp/syndesis-output-XXXXX)"
trap "print_error $ERROR_FILE" EXIT
#
# Only initialize ERROR_FILE once regardless of how many times
# this file is sourced, ie. its sourced by other scripts directly
# or indirectly when sourced by common_config.sh
#
if [ -z ${ERROR_FILE+x} ]; then
ERROR_FILE="$(mktemp /tmp/syndesis-output-XXXXX)"
trap "print_error $ERROR_FILE" EXIT
fi

get_executable_file_extension() {
local os=$(get_current_os)
Expand Down
15 changes: 15 additions & 0 deletions default-cr.yml
@@ -0,0 +1,15 @@
apiVersion: syndesis.io/v1beta1
kind: Syndesis
metadata:
name: app
spec:
integration:
# No limitations by default on OCP
limit: 0
addons:
jaeger:
enabled: true
camel-k:
enabled: false
komodo:
enabled: false
63 changes: 33 additions & 30 deletions install_ocp.sh
Expand Up @@ -13,6 +13,8 @@ set -eu
# Save global script args
ARGS=("$@")

DEFAULT_CR_FILE="./default-cr.yml"

# Helper functions:

# Dir where this script is located
Expand Down Expand Up @@ -116,11 +118,7 @@ with options:
if it already exists. By default, install into the current project (without deleting)
-w --watch Wait until the installation has completed
-o --open Open Fuse Online after installation (implies --watch)
--camel-k Install also the camel-k operator
(version is optional)
--camel-k-options "opts" Options used when installing the camel-k operator.
Use quotes and start with a space before appending the options.
--custom-resource Provide a custom resource file to be installed by the operator.
--help This help message
-v --verbose Verbose logging

Expand All @@ -129,7 +127,6 @@ EOT
}

# ============================================================

open_url() {
local url=$1
local cmd="$(probe_commands open xdg-open chrome firefox)"
Expand Down Expand Up @@ -186,7 +183,9 @@ grant_role() {
clusterwide="--cluster"
fi

set +e
$SYNDESIS_CLI grant --user "$user_to_prepare" $clusterwide
set -e
}

# ==============================================================
Expand Down Expand Up @@ -235,11 +234,11 @@ if [ $(hasflag -s --setup) ]; then

$SYNDESIS_CLI install cluster

if [ $(hasflag --camel-k) ]; then
echo "Installing Camel-K CRDs"

$KAMEL_CLI install --cluster-setup
fi
#
# As camel-k addon may well be used we install these anyway
#
echo "Installing Camel-K CRDs"
$KAMEL_CLI install --cluster-setup
prep_only="true"
fi

Expand Down Expand Up @@ -295,42 +294,46 @@ if [ $? -ne 0 ]; then
check_error "ERROR: No CRD Syndesis installed or no permissions to read them. Please run --setup and/or --grant as cluster-admin. Please use '--help' for more information."
fi

if [ $(hasflag --camel-k) ]; then
oc get integration >/dev/null 2>&1
if [ $? -ne 0 ]; then
check_error "ERROR: Camel-K installation requested but no Camel-K CRDs accessible. Please run --setup --camel-k to register the proper CRDs."
fi
oc get integration >/dev/null 2>&1
if [ $? -ne 0 ]; then
check_error "ERROR: Failure to install Camel-K CRDs."
fi
set -e

# Deploy operator and wait until its up
echo "Deploying Syndesis operator"
$SYNDESIS_CLI install operator

set +e
result=$(oc secrets link syndesis-operator syndesis-pull-secret --for=pull >$ERROR_FILE 2>&1)
check_error $result

if [ $(hasflag --camel-k) ]; then
echo "Deploying Camel-K operator"
$KAMEL_CLI install --skip-cluster-setup $(readopt --camel-k-options)

result=$(oc secrets link camel-k-operator syndesis-pull-secret --for=pull >$ERROR_FILE 2>&1)
check_error $result
fi
set -e

# Wait for deployment
wait_for_deployments 1 syndesis-operator

# Check syndesis cr already installed. If force then remove first.
syndesis_installed=$(oc get syndesis -o name | wc -l)
force=$(hasflag --force)
if [ $syndesis_installed -gt 0 ]; then
echo "Warning ... Syndesis custom resource already installed: '${syndesis_installed}'"
if [ -n "${force}" ]; then
echo "Removing already installed Syndesis custom resource"
oc delete $(oc get syndesis -o name)
fi
fi

# Create syndesis resource
customcr=$(readopt --custom-resource)
if [ -n "${customcr}" ]; then
echo "Creating Syndesis with custom resource ${customcr}"
customcr=" --custom-resource ${customcr}"
else
echo "Creating Syndesis resource"
echo "Creating Syndesis with fuse-online resource"
if [ ! -f "${DEFAULT_CR_FILE}" ]; then
echo "Cannot custom-resource file '$DEFAULT_CR_FILE' ... exiting."
exit 1
fi

result=$($SYNDESIS_CLI install app ${customcr})
set +e
result=$($SYNDESIS_CLI install app --custom-resource ${DEFAULT_CR_FILE})
check_error $result
set -e

if [ $(hasflag --watch -w) ] || [ $(hasflag --open -o) ]; then
wait_for_deployments 1 syndesis-server syndesis-ui syndesis-meta
Expand Down
2 changes: 2 additions & 0 deletions libs/openshift_functions.sh
Expand Up @@ -258,8 +258,10 @@ create_secret_if_not_present() {

echo "enter email address for registry.redhat.io and press [ENTER]: "
read email
set +e
local result=$(oc create secret docker-registry syndesis-pull-secret --docker-server=registry.redhat.io --docker-username=$username --docker-password=$password --docker-email=$email)
check_error $result
set -e
fi
}

Expand Down