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

Remove obsolete serviceMonitors #601

Merged
merged 3 commits into from
Jan 17, 2024
Merged

Remove obsolete serviceMonitors #601

merged 3 commits into from
Jan 17, 2024

Conversation

cumcke
Copy link
Collaborator

@cumcke cumcke commented Jan 11, 2024

No description provided.

Copy link
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck -e SC1004' returned error 1 finding the following syntactical issues:

----------

In monitoring/bin/deploy_monitoring_viya.sh line 6:
cd "$(dirname $BASH_SOURCE)/../.."
              ^----------^ SC2128 (warning): Expanding an array without an index only gives the first element.
              ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cd "$(dirname "$BASH_SOURCE")/../.."


In monitoring/bin/deploy_monitoring_viya.sh line 7:
source monitoring/bin/common.sh
       ^----------------------^ SC1091 (info): Not following: monitoring/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/deploy_monitoring_viya.sh line 8:
source bin/openshift-include.sh
       ^----------------------^ SC1091 (info): Not following: bin/openshift-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/deploy_monitoring_viya.sh line 66:
      source bin/airgap-include.sh
             ^-------------------^ SC1091 (info): Not following: bin/airgap-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/deploy_monitoring_viya.sh line 72:
      airgapValuesFile=$updatedAirgapValuesFile
                       ^----------------------^ SC2154 (warning): updatedAirgapValuesFile is referenced but not assigned.


In monitoring/bin/deploy_monitoring_viya.sh line 77:
   if helm3ReleaseExists prometheus-pushgateway $VIYA_NS; then
                                                ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   if helm3ReleaseExists prometheus-pushgateway "$VIYA_NS"; then


In monitoring/bin/deploy_monitoring_viya.sh line 78:
      kubectl delete deployment -n $VIYA_NS prometheus-pushgateway --ignore-not-found
                                   ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      kubectl delete deployment -n "$VIYA_NS" prometheus-pushgateway --ignore-not-found


In monitoring/bin/deploy_monitoring_viya.sh line 79:
      svcClusterIP=$(kubectl get svc -n $VIYA_NS prometheus-pushgateway -o 'jsonpath={.spec.clusterIP}')
                                        ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      svcClusterIP=$(kubectl get svc -n "$VIYA_NS" prometheus-pushgateway -o 'jsonpath={.spec.clusterIP}')


In monitoring/bin/deploy_monitoring_viya.sh line 83:
   helm2ReleaseCheck pushgateway-$VIYA_NS
                                 ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   helm2ReleaseCheck pushgateway-"$VIYA_NS"


In monitoring/bin/deploy_monitoring_viya.sh line 87:
   chart2install="$(get_helmchart_reference $PUSHGATEWAY_CHART_REPO $PUSHGATEWAY_CHART_NAME $PUSHGATEWAY_CHART_VERSION)"
                                            ^---------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                    ^---------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                            ^------------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   chart2install="$(get_helmchart_reference "$PUSHGATEWAY_CHART_REPO" "$PUSHGATEWAY_CHART_NAME" "$PUSHGATEWAY_CHART_VERSION")"


In monitoring/bin/deploy_monitoring_viya.sh line 90:
   helm $helmDebug upgrade --install prometheus-pushgateway \
        ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   helm "$helmDebug" upgrade --install prometheus-pushgateway \


In monitoring/bin/deploy_monitoring_viya.sh line 91:
        --namespace $VIYA_NS \
                    ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        --namespace "$VIYA_NS" \


In monitoring/bin/deploy_monitoring_viya.sh line 92:
        --version $PUSHGATEWAY_CHART_VERSION \
                  ^------------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        --version "$PUSHGATEWAY_CHART_VERSION" \


In monitoring/bin/deploy_monitoring_viya.sh line 93:
        --set service.clusterIP=$svcClusterIP \
                                ^-----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        --set service.clusterIP="$svcClusterIP" \


In monitoring/bin/deploy_monitoring_viya.sh line 95:
        -f $airgapValuesFile \
           ^---------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        -f "$airgapValuesFile" \


In monitoring/bin/deploy_monitoring_viya.sh line 96:
        -f $wnpValuesFile \
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        -f "$wnpValuesFile" \


In monitoring/bin/deploy_monitoring_viya.sh line 97:
        -f $PUSHGATEWAY_USER_YAML \
           ^--------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        -f "$PUSHGATEWAY_USER_YAML" \


In monitoring/bin/deploy_monitoring_viya.sh line 98:
         $chart2install
         ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         "$chart2install"


In monitoring/bin/deploy_monitoring_viya.sh line 112:
    kubectl apply -n $VIYA_NS -f "$f" --validate=$VALIDATE_MONITORS
                     ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^----------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl apply -n "$VIYA_NS" -f "$f" --validate="$VALIDATE_MONITORS"


In monitoring/bin/deploy_monitoring_viya.sh line 115:
    kubectl apply -n $VIYA_NS -f "$f" --validate=$VALIDATE_MONITORS
                     ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^----------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl apply -n "$VIYA_NS" -f "$f" --validate="$VALIDATE_MONITORS"


In monitoring/bin/deploy_monitoring_viya.sh line 120:
  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-java-services
                                                      ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
  kubectl delete --ignore-not-found ServiceMonitor -n "$VIYA_NS" sas-java-services


In monitoring/bin/deploy_monitoring_viya.sh line 121:
  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-go-services
                                                      ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
  kubectl delete --ignore-not-found ServiceMonitor -n "$VIYA_NS" sas-go-services


In monitoring/bin/deploy_monitoring_viya.sh line 122:
  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-deployment-operator
                                                      ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
  kubectl delete --ignore-not-found ServiceMonitor -n "$VIYA_NS" sas-deployment-operator


In monitoring/bin/deploy_monitoring_viya.sh line 123:
  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-elasticsearch
                                                      ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
  kubectl delete --ignore-not-found ServiceMonitor -n "$VIYA_NS" sas-elasticsearch


In monitoring/bin/deploy_monitoring_viya.sh line 124:
  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-opendistro
                                                      ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
  kubectl delete --ignore-not-found ServiceMonitor -n "$VIYA_NS" sas-opendistro


In monitoring/bin/deploy_monitoring_viya.sh line 130:
if helm3ReleaseExists "v4m-viya" $VIYA_NS; then
                                 ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if helm3ReleaseExists "v4m-viya" "$VIYA_NS"; then

For more information:
  https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind...
  https://www.shellcheck.net/wiki/SC2154 -- updatedAirgapValuesFile is refere...
  https://www.shellcheck.net/wiki/SC1091 -- Not following: bin/airgap-include...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt -s' returned error 1 finding the following formatting issues:

----------
--- monitoring/bin/deploy_monitoring_viya.sh.orig
+++ monitoring/bin/deploy_monitoring_viya.sh
@@ -9,21 +9,21 @@
 
 # If openshift deployment, ensure user-workload monitoring is enabled
 if [ "$OPENSHIFT_CLUSTER" == "true" ]; then
-  if [ -n "$(kubectl get po -n openshift-user-workload-monitoring -o name 2>/dev/null)" ]; then
-    log_debug "User workload monitoring is enabled"
-  else
-    log_error "User workload monitoring pods not detected in the openshift-user-workload-monitoring namespace"
-    log_error "Ensure that user workload monitoring is enabled"
-    log_error "See more here: https://github.com/sassoftware/viya4-monitoring-kubernetes/blob/stable/monitoring/OpenShift.md#azure-red-hat-openshift-experimental"
-    exit 1
-  fi
+	if [ -n "$(kubectl get po -n openshift-user-workload-monitoring -o name 2>/dev/null)" ]; then
+		log_debug "User workload monitoring is enabled"
+	else
+		log_error "User workload monitoring pods not detected in the openshift-user-workload-monitoring namespace"
+		log_error "Ensure that user workload monitoring is enabled"
+		log_error "See more here: https://github.com/sassoftware/viya4-monitoring-kubernetes/blob/stable/monitoring/OpenShift.md#azure-red-hat-openshift-experimental"
+		exit 1
+	fi
 fi
 
 checkDefaultStorageClass
 
 HELM_DEBUG="${HELM_DEBUG:-false}"
 if [ "$HELM_DEBUG" == "true" ]; then
-  helmDebug="--debug"
+	helmDebug="--debug"
 fi
 
 helmRepoAdd prometheus-community https://prometheus-community.github.io/helm-charts
@@ -33,23 +33,23 @@
 
 PUSHGATEWAY_USER_YAML="${PUSHGATEWAY_USER_YAML:-$USER_DIR/monitoring/user-values-pushgateway.yaml}"
 if [ ! -f "$PUSHGATEWAY_USER_YAML" ]; then
-  log_debug "[$PUSHGATEWAY_USER_YAML] not found. Using $TMP_DIR/empty.yaml"
-  PUSHGATEWAY_USER_YAML=$TMP_DIR/empty.yaml
+	log_debug "[$PUSHGATEWAY_USER_YAML] not found. Using $TMP_DIR/empty.yaml"
+	PUSHGATEWAY_USER_YAML=$TMP_DIR/empty.yaml
 fi
 
 if [ "$VIYA_NS" == "" ]; then
-  log_error "VIYA_NS must be set to the namespace of an existing SAS Viya deployment"
-  exit 1
+	log_error "VIYA_NS must be set to the namespace of an existing SAS Viya deployment"
+	exit 1
 fi
 
 # Optional workload node placement support
 MON_NODE_PLACEMENT_ENABLE=${MON_NODE_PLACEMENT_ENABLE:-${NODE_PLACEMENT_ENABLE:-false}}
 if [ "$MON_NODE_PLACEMENT_ENABLE" == "true" ]; then
-  log_info "Enabling monitoring components for workload node placement"
-  wnpValuesFile="monitoring/node-placement/values-pushgateway-wnp.yaml"
+	log_info "Enabling monitoring components for workload node placement"
+	wnpValuesFile="monitoring/node-placement/values-pushgateway-wnp.yaml"
 else
-  log_debug "Workload node placement support is disabled"
-  wnpValuesFile="$TMP_DIR/empty.yaml"
+	log_debug "Workload node placement support is disabled"
+	wnpValuesFile="$TMP_DIR/empty.yaml"
 fi
 
 log_notice "Enabling the [$VIYA_NS] namespace for SAS Viya Monitoring"
@@ -61,76 +61,75 @@
 PUSHGATEWAY_ENABLED=${PUSHGATEWAY_ENABLED:-true}
 if [ "$PUSHGATEWAY_ENABLED" == "true" ]; then
 
-   ## Check for air gap deployment
-   if [ "$AIRGAP_DEPLOYMENT" == "true" ]; then
-      source bin/airgap-include.sh
+	## Check for air gap deployment
+	if [ "$AIRGAP_DEPLOYMENT" == "true" ]; then
+		source bin/airgap-include.sh
 
-      # Check for the image pull secret for the air gap environment and replace placeholders
-      checkForAirgapSecretInNamespace "$AIRGAP_IMAGE_PULL_SECRET_NAME" "$MON_NS"
-      replaceAirgapValuesInFiles "monitoring/airgap/airgap-values-pushgateway.yaml"
+		# Check for the image pull secret for the air gap environment and replace placeholders
+		checkForAirgapSecretInNamespace "$AIRGAP_IMAGE_PULL_SECRET_NAME" "$MON_NS"
+		replaceAirgapValuesInFiles "monitoring/airgap/airgap-values-pushgateway.yaml"
 
-      airgapValuesFile=$updatedAirgapValuesFile
-   else
-      airgapValuesFile=$TMP_DIR/empty.yaml
-   fi
+		airgapValuesFile=$updatedAirgapValuesFile
+	else
+		airgapValuesFile=$TMP_DIR/empty.yaml
+	fi
 
-   if helm3ReleaseExists prometheus-pushgateway $VIYA_NS; then
-      kubectl delete deployment -n $VIYA_NS prometheus-pushgateway --ignore-not-found
-      svcClusterIP=$(kubectl get svc -n $VIYA_NS prometheus-pushgateway -o 'jsonpath={.spec.clusterIP}')
-   fi
+	if helm3ReleaseExists prometheus-pushgateway $VIYA_NS; then
+		kubectl delete deployment -n $VIYA_NS prometheus-pushgateway --ignore-not-found
+		svcClusterIP=$(kubectl get svc -n $VIYA_NS prometheus-pushgateway -o 'jsonpath={.spec.clusterIP}')
+	fi
 
-   log_info "Installing the Prometheus Pushgateway to the [$VIYA_NS] namespace"
-   helm2ReleaseCheck pushgateway-$VIYA_NS
+	log_info "Installing the Prometheus Pushgateway to the [$VIYA_NS] namespace"
+	helm2ReleaseCheck pushgateway-$VIYA_NS
 
-   ## Get Helm Chart Name
-   log_debug "Prometheus Pushgateway Helm Chart: repo [$PUSHGATEWAY_CHART_REPO] name [$PUSHGATEWAY_CHART_NAME] version [$PUSHGATEWAY_CHART_VERSION]"
-   chart2install="$(get_helmchart_reference $PUSHGATEWAY_CHART_REPO $PUSHGATEWAY_CHART_NAME $PUSHGATEWAY_CHART_VERSION)"
-   log_debug "Installing Helm chart from artifact [$chart2install]"
+	## Get Helm Chart Name
+	log_debug "Prometheus Pushgateway Helm Chart: repo [$PUSHGATEWAY_CHART_REPO] name [$PUSHGATEWAY_CHART_NAME] version [$PUSHGATEWAY_CHART_VERSION]"
+	chart2install="$(get_helmchart_reference $PUSHGATEWAY_CHART_REPO $PUSHGATEWAY_CHART_NAME $PUSHGATEWAY_CHART_VERSION)"
+	log_debug "Installing Helm chart from artifact [$chart2install]"
 
-   helm $helmDebug upgrade --install prometheus-pushgateway \
-        --namespace $VIYA_NS \
-        --version $PUSHGATEWAY_CHART_VERSION \
-        --set service.clusterIP=$svcClusterIP \
-        -f monitoring/values-pushgateway.yaml \
-        -f $airgapValuesFile \
-        -f $wnpValuesFile \
-        -f $PUSHGATEWAY_USER_YAML \
-         $chart2install
+	helm $helmDebug upgrade --install prometheus-pushgateway \
+		--namespace $VIYA_NS \
+		--version $PUSHGATEWAY_CHART_VERSION \
+		--set service.clusterIP=$svcClusterIP \
+		-f monitoring/values-pushgateway.yaml \
+		-f $airgapValuesFile \
+		-f $wnpValuesFile \
+		-f $PUSHGATEWAY_USER_YAML \
+		$chart2install
 
 fi
 
 if [ "$OPENSHIFT_CLUSTER" == "true" ]; then
-  # By default, do not validate monitors on OpenShift due to
-  # the older Prometheus Operator CRDs
-  VALIDATE_MONITORS=${VALIDATE_MONITORS:-false}
+	# By default, do not validate monitors on OpenShift due to
+	# the older Prometheus Operator CRDs
+	VALIDATE_MONITORS=${VALIDATE_MONITORS:-false}
 else
-  VALIDATE_MONITORS=${VALIDATE_MONITORS:-true}
+	VALIDATE_MONITORS=${VALIDATE_MONITORS:-true}
 fi
 if [ "$(kubectl get crd servicemonitors.monitoring.coreos.com -o name 2>/dev/null)" ]; then
-  log_info "Adding monitors for resources in the [$VIYA_NS] namespace..."
-  for f in monitoring/monitors/viya/serviceMonitor-*.yaml; do
-    kubectl apply -n $VIYA_NS -f "$f" --validate=$VALIDATE_MONITORS
-  done
-  for f in monitoring/monitors/viya/podMonitor-*.yaml; do
-    kubectl apply -n $VIYA_NS -f "$f" --validate=$VALIDATE_MONITORS
-  done
-  log_notice "Monitoring components successfully deployed into the [$VIYA_NS] namespace"
+	log_info "Adding monitors for resources in the [$VIYA_NS] namespace..."
+	for f in monitoring/monitors/viya/serviceMonitor-*.yaml; do
+		kubectl apply -n $VIYA_NS -f "$f" --validate=$VALIDATE_MONITORS
+	done
+	for f in monitoring/monitors/viya/podMonitor-*.yaml; do
+		kubectl apply -n $VIYA_NS -f "$f" --validate=$VALIDATE_MONITORS
+	done
+	log_notice "Monitoring components successfully deployed into the [$VIYA_NS] namespace"
 
-  # Temporary - Remove obsolete ServiceMonitors
-  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-java-services
-  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-go-services
-  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-deployment-operator
-  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-elasticsearch
-  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-opendistro
+	# Temporary - Remove obsolete ServiceMonitors
+	kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-java-services
+	kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-go-services
+	kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-deployment-operator
+	kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-elasticsearch
+	kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-opendistro
 else
-  log_warn "Prometheus Operator not found. Skipping deployment of ServiceMonitors."
+	log_warn "Prometheus Operator not found. Skipping deployment of ServiceMonitors."
 fi
 
 # If a deployment with the old name exists, remove it first
 if helm3ReleaseExists "v4m-viya" $VIYA_NS; then
-  log_verbose "Removing outdated SAS Viya Monitoring Helm chart release from [$VIYA_NS] namespace"
-  helm uninstall -n "$VIYA_NS" "v4m-viya"
+	log_verbose "Removing outdated SAS Viya Monitoring Helm chart release from [$VIYA_NS] namespace"
+	helm uninstall -n "$VIYA_NS" "v4m-viya"
 fi
 
 deployV4MInfo "$VIYA_NS" "v4m-metrics-viya"
-
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt -s -w filename


Copy link
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck -e SC1004' returned error 1 finding the following syntactical issues:

----------

In monitoring/bin/deploy_monitoring_viya.sh line 6:
cd "$(dirname $BASH_SOURCE)/../.."
              ^----------^ SC2128 (warning): Expanding an array without an index only gives the first element.
              ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
cd "$(dirname "$BASH_SOURCE")/../.."


In monitoring/bin/deploy_monitoring_viya.sh line 7:
source monitoring/bin/common.sh
       ^----------------------^ SC1091 (info): Not following: monitoring/bin/common.sh was not specified as input (see shellcheck -x).


In monitoring/bin/deploy_monitoring_viya.sh line 8:
source bin/openshift-include.sh
       ^----------------------^ SC1091 (info): Not following: bin/openshift-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/deploy_monitoring_viya.sh line 66:
      source bin/airgap-include.sh
             ^-------------------^ SC1091 (info): Not following: bin/airgap-include.sh was not specified as input (see shellcheck -x).


In monitoring/bin/deploy_monitoring_viya.sh line 72:
      airgapValuesFile=$updatedAirgapValuesFile
                       ^----------------------^ SC2154 (warning): updatedAirgapValuesFile is referenced but not assigned.


In monitoring/bin/deploy_monitoring_viya.sh line 77:
   if helm3ReleaseExists prometheus-pushgateway $VIYA_NS; then
                                                ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   if helm3ReleaseExists prometheus-pushgateway "$VIYA_NS"; then


In monitoring/bin/deploy_monitoring_viya.sh line 78:
      kubectl delete deployment -n $VIYA_NS prometheus-pushgateway --ignore-not-found
                                   ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      kubectl delete deployment -n "$VIYA_NS" prometheus-pushgateway --ignore-not-found


In monitoring/bin/deploy_monitoring_viya.sh line 79:
      svcClusterIP=$(kubectl get svc -n $VIYA_NS prometheus-pushgateway -o 'jsonpath={.spec.clusterIP}')
                                        ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
      svcClusterIP=$(kubectl get svc -n "$VIYA_NS" prometheus-pushgateway -o 'jsonpath={.spec.clusterIP}')


In monitoring/bin/deploy_monitoring_viya.sh line 83:
   helm2ReleaseCheck pushgateway-$VIYA_NS
                                 ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   helm2ReleaseCheck pushgateway-"$VIYA_NS"


In monitoring/bin/deploy_monitoring_viya.sh line 87:
   chart2install="$(get_helmchart_reference $PUSHGATEWAY_CHART_REPO $PUSHGATEWAY_CHART_NAME $PUSHGATEWAY_CHART_VERSION)"
                                            ^---------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                    ^---------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                                                            ^------------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   chart2install="$(get_helmchart_reference "$PUSHGATEWAY_CHART_REPO" "$PUSHGATEWAY_CHART_NAME" "$PUSHGATEWAY_CHART_VERSION")"


In monitoring/bin/deploy_monitoring_viya.sh line 90:
   helm $helmDebug upgrade --install prometheus-pushgateway \
        ^--------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
   helm "$helmDebug" upgrade --install prometheus-pushgateway \


In monitoring/bin/deploy_monitoring_viya.sh line 91:
        --namespace $VIYA_NS \
                    ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        --namespace "$VIYA_NS" \


In monitoring/bin/deploy_monitoring_viya.sh line 92:
        --version $PUSHGATEWAY_CHART_VERSION \
                  ^------------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        --version "$PUSHGATEWAY_CHART_VERSION" \


In monitoring/bin/deploy_monitoring_viya.sh line 93:
        --set service.clusterIP=$svcClusterIP \
                                ^-----------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        --set service.clusterIP="$svcClusterIP" \


In monitoring/bin/deploy_monitoring_viya.sh line 95:
        -f $airgapValuesFile \
           ^---------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        -f "$airgapValuesFile" \


In monitoring/bin/deploy_monitoring_viya.sh line 96:
        -f $wnpValuesFile \
           ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        -f "$wnpValuesFile" \


In monitoring/bin/deploy_monitoring_viya.sh line 97:
        -f $PUSHGATEWAY_USER_YAML \
           ^--------------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
        -f "$PUSHGATEWAY_USER_YAML" \


In monitoring/bin/deploy_monitoring_viya.sh line 98:
         $chart2install
         ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
         "$chart2install"


In monitoring/bin/deploy_monitoring_viya.sh line 112:
    kubectl apply -n $VIYA_NS -f "$f" --validate=$VALIDATE_MONITORS
                     ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^----------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl apply -n "$VIYA_NS" -f "$f" --validate="$VALIDATE_MONITORS"


In monitoring/bin/deploy_monitoring_viya.sh line 115:
    kubectl apply -n $VIYA_NS -f "$f" --validate=$VALIDATE_MONITORS
                     ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                 ^----------------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    kubectl apply -n "$VIYA_NS" -f "$f" --validate="$VALIDATE_MONITORS"


In monitoring/bin/deploy_monitoring_viya.sh line 120:
  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-java-services
                                                      ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
  kubectl delete --ignore-not-found ServiceMonitor -n "$VIYA_NS" sas-java-services


In monitoring/bin/deploy_monitoring_viya.sh line 121:
  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-go-services
                                                      ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
  kubectl delete --ignore-not-found ServiceMonitor -n "$VIYA_NS" sas-go-services


In monitoring/bin/deploy_monitoring_viya.sh line 122:
  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-deployment-operator
                                                      ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
  kubectl delete --ignore-not-found ServiceMonitor -n "$VIYA_NS" sas-deployment-operator


In monitoring/bin/deploy_monitoring_viya.sh line 123:
  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-elasticsearch
                                                      ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
  kubectl delete --ignore-not-found ServiceMonitor -n "$VIYA_NS" sas-elasticsearch


In monitoring/bin/deploy_monitoring_viya.sh line 129:
if helm3ReleaseExists "v4m-viya" $VIYA_NS; then
                                 ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
if helm3ReleaseExists "v4m-viya" "$VIYA_NS"; then

For more information:
  https://www.shellcheck.net/wiki/SC2128 -- Expanding an array without an ind...
  https://www.shellcheck.net/wiki/SC2154 -- updatedAirgapValuesFile is refere...
  https://www.shellcheck.net/wiki/SC1091 -- Not following: bin/airgap-include...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt -s' returned error 1 finding the following formatting issues:

----------
--- monitoring/bin/deploy_monitoring_viya.sh.orig
+++ monitoring/bin/deploy_monitoring_viya.sh
@@ -9,21 +9,21 @@
 
 # If openshift deployment, ensure user-workload monitoring is enabled
 if [ "$OPENSHIFT_CLUSTER" == "true" ]; then
-  if [ -n "$(kubectl get po -n openshift-user-workload-monitoring -o name 2>/dev/null)" ]; then
-    log_debug "User workload monitoring is enabled"
-  else
-    log_error "User workload monitoring pods not detected in the openshift-user-workload-monitoring namespace"
-    log_error "Ensure that user workload monitoring is enabled"
-    log_error "See more here: https://github.com/sassoftware/viya4-monitoring-kubernetes/blob/stable/monitoring/OpenShift.md#azure-red-hat-openshift-experimental"
-    exit 1
-  fi
+	if [ -n "$(kubectl get po -n openshift-user-workload-monitoring -o name 2>/dev/null)" ]; then
+		log_debug "User workload monitoring is enabled"
+	else
+		log_error "User workload monitoring pods not detected in the openshift-user-workload-monitoring namespace"
+		log_error "Ensure that user workload monitoring is enabled"
+		log_error "See more here: https://github.com/sassoftware/viya4-monitoring-kubernetes/blob/stable/monitoring/OpenShift.md#azure-red-hat-openshift-experimental"
+		exit 1
+	fi
 fi
 
 checkDefaultStorageClass
 
 HELM_DEBUG="${HELM_DEBUG:-false}"
 if [ "$HELM_DEBUG" == "true" ]; then
-  helmDebug="--debug"
+	helmDebug="--debug"
 fi
 
 helmRepoAdd prometheus-community https://prometheus-community.github.io/helm-charts
@@ -33,23 +33,23 @@
 
 PUSHGATEWAY_USER_YAML="${PUSHGATEWAY_USER_YAML:-$USER_DIR/monitoring/user-values-pushgateway.yaml}"
 if [ ! -f "$PUSHGATEWAY_USER_YAML" ]; then
-  log_debug "[$PUSHGATEWAY_USER_YAML] not found. Using $TMP_DIR/empty.yaml"
-  PUSHGATEWAY_USER_YAML=$TMP_DIR/empty.yaml
+	log_debug "[$PUSHGATEWAY_USER_YAML] not found. Using $TMP_DIR/empty.yaml"
+	PUSHGATEWAY_USER_YAML=$TMP_DIR/empty.yaml
 fi
 
 if [ "$VIYA_NS" == "" ]; then
-  log_error "VIYA_NS must be set to the namespace of an existing SAS Viya deployment"
-  exit 1
+	log_error "VIYA_NS must be set to the namespace of an existing SAS Viya deployment"
+	exit 1
 fi
 
 # Optional workload node placement support
 MON_NODE_PLACEMENT_ENABLE=${MON_NODE_PLACEMENT_ENABLE:-${NODE_PLACEMENT_ENABLE:-false}}
 if [ "$MON_NODE_PLACEMENT_ENABLE" == "true" ]; then
-  log_info "Enabling monitoring components for workload node placement"
-  wnpValuesFile="monitoring/node-placement/values-pushgateway-wnp.yaml"
+	log_info "Enabling monitoring components for workload node placement"
+	wnpValuesFile="monitoring/node-placement/values-pushgateway-wnp.yaml"
 else
-  log_debug "Workload node placement support is disabled"
-  wnpValuesFile="$TMP_DIR/empty.yaml"
+	log_debug "Workload node placement support is disabled"
+	wnpValuesFile="$TMP_DIR/empty.yaml"
 fi
 
 log_notice "Enabling the [$VIYA_NS] namespace for SAS Viya Monitoring"
@@ -61,75 +61,74 @@
 PUSHGATEWAY_ENABLED=${PUSHGATEWAY_ENABLED:-true}
 if [ "$PUSHGATEWAY_ENABLED" == "true" ]; then
 
-   ## Check for air gap deployment
-   if [ "$AIRGAP_DEPLOYMENT" == "true" ]; then
-      source bin/airgap-include.sh
+	## Check for air gap deployment
+	if [ "$AIRGAP_DEPLOYMENT" == "true" ]; then
+		source bin/airgap-include.sh
 
-      # Check for the image pull secret for the air gap environment and replace placeholders
-      checkForAirgapSecretInNamespace "$AIRGAP_IMAGE_PULL_SECRET_NAME" "$MON_NS"
-      replaceAirgapValuesInFiles "monitoring/airgap/airgap-values-pushgateway.yaml"
+		# Check for the image pull secret for the air gap environment and replace placeholders
+		checkForAirgapSecretInNamespace "$AIRGAP_IMAGE_PULL_SECRET_NAME" "$MON_NS"
+		replaceAirgapValuesInFiles "monitoring/airgap/airgap-values-pushgateway.yaml"
 
-      airgapValuesFile=$updatedAirgapValuesFile
-   else
-      airgapValuesFile=$TMP_DIR/empty.yaml
-   fi
+		airgapValuesFile=$updatedAirgapValuesFile
+	else
+		airgapValuesFile=$TMP_DIR/empty.yaml
+	fi
 
-   if helm3ReleaseExists prometheus-pushgateway $VIYA_NS; then
-      kubectl delete deployment -n $VIYA_NS prometheus-pushgateway --ignore-not-found
-      svcClusterIP=$(kubectl get svc -n $VIYA_NS prometheus-pushgateway -o 'jsonpath={.spec.clusterIP}')
-   fi
+	if helm3ReleaseExists prometheus-pushgateway $VIYA_NS; then
+		kubectl delete deployment -n $VIYA_NS prometheus-pushgateway --ignore-not-found
+		svcClusterIP=$(kubectl get svc -n $VIYA_NS prometheus-pushgateway -o 'jsonpath={.spec.clusterIP}')
+	fi
 
-   log_info "Installing the Prometheus Pushgateway to the [$VIYA_NS] namespace"
-   helm2ReleaseCheck pushgateway-$VIYA_NS
+	log_info "Installing the Prometheus Pushgateway to the [$VIYA_NS] namespace"
+	helm2ReleaseCheck pushgateway-$VIYA_NS
 
-   ## Get Helm Chart Name
-   log_debug "Prometheus Pushgateway Helm Chart: repo [$PUSHGATEWAY_CHART_REPO] name [$PUSHGATEWAY_CHART_NAME] version [$PUSHGATEWAY_CHART_VERSION]"
-   chart2install="$(get_helmchart_reference $PUSHGATEWAY_CHART_REPO $PUSHGATEWAY_CHART_NAME $PUSHGATEWAY_CHART_VERSION)"
-   log_debug "Installing Helm chart from artifact [$chart2install]"
+	## Get Helm Chart Name
+	log_debug "Prometheus Pushgateway Helm Chart: repo [$PUSHGATEWAY_CHART_REPO] name [$PUSHGATEWAY_CHART_NAME] version [$PUSHGATEWAY_CHART_VERSION]"
+	chart2install="$(get_helmchart_reference $PUSHGATEWAY_CHART_REPO $PUSHGATEWAY_CHART_NAME $PUSHGATEWAY_CHART_VERSION)"
+	log_debug "Installing Helm chart from artifact [$chart2install]"
 
-   helm $helmDebug upgrade --install prometheus-pushgateway \
-        --namespace $VIYA_NS \
-        --version $PUSHGATEWAY_CHART_VERSION \
-        --set service.clusterIP=$svcClusterIP \
-        -f monitoring/values-pushgateway.yaml \
-        -f $airgapValuesFile \
-        -f $wnpValuesFile \
-        -f $PUSHGATEWAY_USER_YAML \
-         $chart2install
+	helm $helmDebug upgrade --install prometheus-pushgateway \
+		--namespace $VIYA_NS \
+		--version $PUSHGATEWAY_CHART_VERSION \
+		--set service.clusterIP=$svcClusterIP \
+		-f monitoring/values-pushgateway.yaml \
+		-f $airgapValuesFile \
+		-f $wnpValuesFile \
+		-f $PUSHGATEWAY_USER_YAML \
+		$chart2install
 
 fi
 
 if [ "$OPENSHIFT_CLUSTER" == "true" ]; then
-  # By default, do not validate monitors on OpenShift due to
-  # the older Prometheus Operator CRDs
-  VALIDATE_MONITORS=${VALIDATE_MONITORS:-false}
+	# By default, do not validate monitors on OpenShift due to
+	# the older Prometheus Operator CRDs
+	VALIDATE_MONITORS=${VALIDATE_MONITORS:-false}
 else
-  VALIDATE_MONITORS=${VALIDATE_MONITORS:-true}
+	VALIDATE_MONITORS=${VALIDATE_MONITORS:-true}
 fi
 if [ "$(kubectl get crd servicemonitors.monitoring.coreos.com -o name 2>/dev/null)" ]; then
-  log_info "Adding monitors for resources in the [$VIYA_NS] namespace..."
-  for f in monitoring/monitors/viya/serviceMonitor-*.yaml; do
-    kubectl apply -n $VIYA_NS -f "$f" --validate=$VALIDATE_MONITORS
-  done
-  for f in monitoring/monitors/viya/podMonitor-*.yaml; do
-    kubectl apply -n $VIYA_NS -f "$f" --validate=$VALIDATE_MONITORS
-  done
-  log_notice "Monitoring components successfully deployed into the [$VIYA_NS] namespace"
+	log_info "Adding monitors for resources in the [$VIYA_NS] namespace..."
+	for f in monitoring/monitors/viya/serviceMonitor-*.yaml; do
+		kubectl apply -n $VIYA_NS -f "$f" --validate=$VALIDATE_MONITORS
+	done
+	for f in monitoring/monitors/viya/podMonitor-*.yaml; do
+		kubectl apply -n $VIYA_NS -f "$f" --validate=$VALIDATE_MONITORS
+	done
+	log_notice "Monitoring components successfully deployed into the [$VIYA_NS] namespace"
 
-  # Temporary - Remove obsolete ServiceMonitors
-  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-java-services
-  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-go-services
-  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-deployment-operator
-  kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-elasticsearch
+	# Temporary - Remove obsolete ServiceMonitors
+	kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-java-services
+	kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-go-services
+	kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-deployment-operator
+	kubectl delete --ignore-not-found ServiceMonitor -n $VIYA_NS sas-elasticsearch
 else
-  log_warn "Prometheus Operator not found. Skipping deployment of ServiceMonitors."
+	log_warn "Prometheus Operator not found. Skipping deployment of ServiceMonitors."
 fi
 
 # If a deployment with the old name exists, remove it first
 if helm3ReleaseExists "v4m-viya" $VIYA_NS; then
-  log_verbose "Removing outdated SAS Viya Monitoring Helm chart release from [$VIYA_NS] namespace"
-  helm uninstall -n "$VIYA_NS" "v4m-viya"
+	log_verbose "Removing outdated SAS Viya Monitoring Helm chart release from [$VIYA_NS] namespace"
+	helm uninstall -n "$VIYA_NS" "v4m-viya"
 fi
 
 deployV4MInfo "$VIYA_NS" "v4m-metrics-viya"
-
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt -s -w filename


Copy link
Member

@gsmith-sas gsmith-sas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@cumcke cumcke merged commit 7789e1c into main Jan 17, 2024
1 check failed
@cumcke cumcke deleted the rem-monitors branch January 17, 2024 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants