diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/files/check-services-installed.sh b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/files/check-services-installed.sh index 1c9b18a4f..dc2142d95 100755 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/files/check-services-installed.sh +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/files/check-services-installed.sh @@ -135,7 +135,30 @@ for c in $(echo $cartridges | jq -r '.[].name');do fi done -if [ $exit_code -ne 0 ];then +# +log "Log status of pods in project ${project} to file ${status_dir}/log/${project}-pods.out" +oc get po -n ${project} > ${status_dir}/log/${project}-pods.out + +# Check if there are any pods in Pending state for > 15 minutes +CURRENT_TIME=$(date +%s) +while read -r line;do + if [ ! -z "${line}" ];then + read -r POD_NAME POD_START POD_STATE <<< "${line}" + POD_START_EPOCH=$(date -d "${POD_START}" +%s) + TIME_DIFF=$((CURRENT_TIME-POD_START_EPOCH)) + if [ ${TIME_DIFF} -gt 900 ];then + log "Pod ${POD_NAME} in project ${project} has been Pending for more than 15 minutes" + exit_code=4 + fi + fi +done <<< $(oc get po -n ${project} -o jsonpath='{range .items[?(@.status.phase=="Pending")]}{.metadata.name}{"\t"}{.metadata.creationTimestamp}{"\t"}{.status.phase}{"\n"}{end}') + +if [ "${exit_code}" == "4" ];then + log "Pods have been in Pending state for more than 15 minutes. Most-likely the OpenShift cluster does not have enough capacity for all selected services." +fi + +if [ "${exit_code}" != "0" ];then + log "Exiting because of error." exit $exit_code fi diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wd.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wd.yml index 70c9134cf..43b4f09f8 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wd.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wd.yml @@ -1,7 +1,7 @@ --- - block: - debug: - var: current_cp4d_cluster + var: _p_current_cp4d_cluster - name: Prepare yaml file for network policy template: diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wks-45.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wks-45.yml new file mode 100644 index 000000000..0267e8be1 --- /dev/null +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/tasks/cp4d-pre-wks-45.yml @@ -0,0 +1,14 @@ +--- +- block: + - debug: + var: _p_current_cp4d_cluster + + - name: Prepare yaml file for Watson Knowledge Studio CR + template: + src: watson-ks-cr-45.j2 + dest: "{{ status_dir }}/cp4d/watson-ks-cr-45-{{ _p_current_cp4d_cluster.project }}.yml" + + - name: Create Watson Knowledge Studio CR + shell: | + oc apply -f {{ status_dir }}/cp4d/watson-ks-cr-45-{{ _p_current_cp4d_cluster.project }}.yml + when: _p_current_cp4d_cluster.cp4d_version >= "4.5.0" diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-cartridges.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-cartridges.j2 index 3856622b4..0d4cce2ab 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-cartridges.j2 +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/apply-cr-cartridges.j2 @@ -5,7 +5,7 @@ -v \ --cpd_instance_ns={{ _p_current_cp4d_cluster.project }} \ --components={% for c in _cartridges_to_install -%} -{%- if (c.state | default('installed')) == 'installed' -%} +{%- if (c.state | default('installed')) == 'installed' and c.name != 'watson-ks' -%} {%- if not loop.first -%},{% endif -%} {{ c.olm_utils_name }} {%- endif -%} diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/watson-ks-cr-45.j2 b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/watson-ks-cr-45.j2 new file mode 100644 index 000000000..05b6788e7 --- /dev/null +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-cartridge-install/templates/watson-ks-cr-45.j2 @@ -0,0 +1,11 @@ +apiVersion: knowledgestudio.watson.ibm.com/v1 +kind: KnowledgeStudio +metadata: + name: wks + namespace: {{ _p_current_cp4d_cluster.project }} +spec: + license: + accept: {{ _cpd_accept_licenses | default(False) }} + global: + storageClassName: {{ ocp_storage_class_block }} + size: {{ _current_cp4d_cartridge.size }} \ No newline at end of file diff --git a/automation-roles/50-install-cloud-pak/cp4d/cp4d-variables/vars/vars-cp4d-installation.yml b/automation-roles/50-install-cloud-pak/cp4d/cp4d-variables/vars/vars-cp4d-installation.yml index c2dc2571c..68a80510a 100644 --- a/automation-roles/50-install-cloud-pak/cp4d/cp4d-variables/vars/vars-cp4d-installation.yml +++ b/automation-roles/50-install-cloud-pak/cp4d/cp4d-variables/vars/vars-cp4d-installation.yml @@ -514,6 +514,7 @@ cartridge_cr: cr_file_prefix: watson-ks olm_utils_name: watson_ks cartridge_label: operators.coreos.com/ibm-watson-ks-operator.ibm-common-services + cr_preprocessing_script: cp4d-pre-wks-45.yml inventory: wksOperatorSetup search_string: ibm-watson-ks package_manifest: ibm-watson-ks-operator diff --git a/docker-scripts/run_automation.sh b/docker-scripts/run_automation.sh index a78b30ec2..e10fe0a4e 100755 --- a/docker-scripts/run_automation.sh +++ b/docker-scripts/run_automation.sh @@ -21,14 +21,18 @@ if [[ error -ne 0 ]];then exit 1 fi -echo "" -echo "Starting Automation script..." -echo "" +# Change to base directory cd ${SCRIPT_DIR}/.. # Ensure /tmp/work exists mkdir -p /tmp/work +# Retrieve version by checking the git log +DEPLOYER_VERSION_INFO=$(git log -n1 --pretty='format:%h %cd |%s' --date=format:'%Y-%m-%dT%H:%M:%S' 2> /dev/null) +COMMIT_HASH=$(echo $DEPLOYER_VERSION_INFO | awk '{print $1}') +COMMIT_TIMESTAMP=$(echo $DEPLOYER_VERSION_INFO | awk '{print $2}') +COMMIT_MESSAGE=$(echo $DEPLOYER_VERSION_INFO | cut -d'|' -f2) + # Check that subcommand is valid export SUBCOMMAND=${SUBCOMMAND,,} export ACTION=${ACTION,,} @@ -97,6 +101,9 @@ env|environment) mkdir -p ${STATUS_DIR}/log echo "===========================================================================" | tee -a ${STATUS_DIR}/log/cloud-pak-deployer.log echo "Starting deployer" | tee -a ${STATUS_DIR}/log/cloud-pak-deployer.log + echo " Commit ID : ${COMMIT_HASH}" | tee -a ${STATUS_DIR}/log/cloud-pak-deployer.log + echo " Commit timestamp: ${COMMIT_TIMESTAMP}" | tee -a ${STATUS_DIR}/log/cloud-pak-deployer.log + echo " Commit message : ${COMMIT_MESSAGE}" | tee -a ${STATUS_DIR}/log/cloud-pak-deployer.log echo "===========================================================================" | tee -a ${STATUS_DIR}/log/cloud-pak-deployer.log run_cmd+=" 2>&1 | tee -a ${STATUS_DIR}/log/cloud-pak-deployer.log" echo "$run_cmd" >> /tmp/deployer_run_cmd.log diff --git a/scripts/cp4d/cp4d-delete-instance.sh b/scripts/cp4d/cp4d-delete-instance.sh index e692f800b..da32e3c90 100755 --- a/scripts/cp4d/cp4d-delete-instance.sh +++ b/scripts/cp4d/cp4d-delete-instance.sh @@ -41,8 +41,8 @@ while read -r line;do ;; *) log "Deleting $CR $CR_NAME" - oc delete -n ${CP4D_PROJECT} ${CR} ${CR_NAME} --wait=false - oc patch -n ${CP4D_PROJECT} ${CR}/${CR_NAME} --type=merge -p '{"metadata": {"finalizers":null}}' + oc delete -n ${CP4D_PROJECT} ${CR} ${CR_NAME} --wait=false --ignore-not-found + oc patch -n ${CP4D_PROJECT} ${CR}/${CR_NAME} --type=merge -p '{"metadata": {"finalizers":null}}' 2> /dev/null resource_deleted=true ;; esac @@ -60,8 +60,8 @@ while read -r line;do case $CR in Ibmcpd|CommonService|OperandRequest) log "Deleting $CR $CR_NAME" - oc delete -n ${CP4D_PROJECT} ${CR} ${CR_NAME} --wait=false - oc patch -n ${CP4D_PROJECT} ${CR}/${CR_NAME} --type=merge -p '{"metadata": {"finalizers":null}}' + oc delete -n ${CP4D_PROJECT} ${CR} ${CR_NAME} --wait=false --ignore-not-found + oc patch -n ${CP4D_PROJECT} ${CR}/${CR_NAME} --type=merge -p '{"metadata": {"finalizers":null}}' 2> /dev/null resource_deleted=true ;; *) @@ -79,20 +79,20 @@ oc delete ns ${CP4D_PROJECT} log "Deleting everything in the ibm-common-services project" oc project ibm-common-services -oc delete CommonService -n ibm-common-services common-service -oc delete sub -n ibm-common-services -l operators.coreos.com/ibm-common-service-operator.ibm-common-services -oc delete csv -n ibm-common-services -l operators.coreos.com/ibm-common-service-operator.ibm-common-services +oc delete CommonService -n ibm-common-services common-service --ignore-not-found +oc delete sub -n ibm-common-services -l operators.coreos.com/ibm-common-service-operator.ibm-common-services --ignore-not-found +oc delete csv -n ibm-common-services -l operators.coreos.com/ibm-common-service-operator.ibm-common-services --ignore-not-found -oc delete operandrequest -n ibm-common-services --all +oc delete operandrequest -n ibm-common-services --all --ignore-not-found -oc delete operandconfig -n ibm-common-services --all +oc delete operandconfig -n ibm-common-services --all --ignore-not-found -oc delete operandregistry -n ibm-common-services --all +oc delete operandregistry -n ibm-common-services --all --ignore-not-found -oc delete nss -n ibm-common-services --all +oc delete nss -n ibm-common-services --all --ignore-not-found -oc delete sub -n ibm-common-services --all -oc delete csv -n ibm-common-services --all +oc delete sub -n ibm-common-services --all --ignore-not-found +oc delete csv -n ibm-common-services --all --ignore-not-found log "Deleting ibm-common-services project" oc delete ns ibm-common-services @@ -100,6 +100,6 @@ oc delete ns ibm-common-services log "Deleting IBM catalog sources" oc delete catsrc -n openshift-marketplace \ $(oc get catsrc -n openshift-marketplace \ - --no-headers | grep -E 'IBM|MANTA' | awk '{print $1}') + --no-headers | grep -E 'IBM|MANTA' | awk '{print $1}') --ignore-not-found exit 0 \ No newline at end of file