Skip to content

Commit 601386f

Browse files
committed
reran shfmt for 4 space indentation
1 parent bfe33f5 commit 601386f

7 files changed

+188
-188
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
env:
1212
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1313
SHELLCHECK_OPTS: -e SC1004 # exclude some shellcheck warnings.
14-
SHFMT_OPTS: -s -i 2 -bn -sr -ln bash # shfmt: simplify (s), 2-space indentation (-i 2), braces on same line (-bn), space after redirects (-sr), bash dialect (-ln bash)
14+
SHFMT_OPTS: -s -i 4 -bn -sr -ln bash # shfmt: simplify (s), 4-space indentation (-i 4), braces on same line (-bn), space after redirects (-sr), bash dialect (-ln bash)
1515
with:
1616
sh_checker_only_diff: true # only run against files that were updated
1717
sh_checker_comment: true # include results as github comment

logging/bin/deploy_fluentbit_azmonitor.sh

Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ log_debug "Script [$this_script] has started [$(date)]"
1515
FLUENT_BIT_ENABLED=${FLUENT_BIT_ENABLED:-true}
1616

1717
if [ "$FLUENT_BIT_ENABLED" != "true" ]; then
18-
log_info "Environment variable [FLUENT_BIT_ENABLED] is not set to 'true'; existing WITHOUT deploying Fluent Bit"
19-
exit 0
18+
log_info "Environment variable [FLUENT_BIT_ENABLED] is not set to 'true'; existing WITHOUT deploying Fluent Bit"
19+
exit 0
2020
fi
2121

2222
set -e
2323

2424
HELM_DEBUG="${HELM_DEBUG:-false}"
2525
helmDebug=""
2626
if [ "$HELM_DEBUG" == "true" ]; then
27-
helmDebug="--debug"
27+
helmDebug="--debug"
2828
fi
2929

3030
# Address SC2154: Ensure variables from common.sh are available or defined
@@ -38,8 +38,8 @@ helmRepoAdd fluent https://fluent.github.io/helm-charts
3838

3939
# Confirm namespace exists
4040
if [ "$(kubectl get ns "$LOG_NS" -o name 2> /dev/null)" == "" ]; then
41-
log_error "The specified namespace [$LOG_NS] does not exist."
42-
exit 1
41+
log_error "The specified namespace [$LOG_NS] does not exist."
42+
exit 1
4343
fi
4444

4545
log_info "Deploying Fluent Bit (Azure Monitor)"
@@ -55,68 +55,68 @@ generateImageKeysFile "$FB_INITCONTAINER_FULL_IMAGE" "logging/fb/fb_initcontaine
5555
# Fluent Bit user customizations
5656
FB_AZMONITOR_USER_YAML="${FB_AZMONITOR_USER_YAML:-$USER_DIR/logging/user-values-fluent-bit-azmonitor.yaml}"
5757
if [ ! -f "$FB_AZMONITOR_USER_YAML" ]; then
58-
log_debug "[$FB_AZMONITOR_USER_YAML] not found. Using $TMP_DIR/empty.yaml"
59-
FB_AZMONITOR_USER_YAML="$TMP_DIR/empty.yaml"
58+
log_debug "[$FB_AZMONITOR_USER_YAML] not found. Using $TMP_DIR/empty.yaml"
59+
FB_AZMONITOR_USER_YAML="$TMP_DIR/empty.yaml"
6060
fi
6161

6262
if [ -f "$USER_DIR/logging/fluent-bit_config.configmap_azmonitor.yaml" ]; then
63-
# use copy in USER_DIR
64-
FB_CONFIGMAP="$USER_DIR/logging/fluent-bit_config.configmap_azmonitor.yaml"
63+
# use copy in USER_DIR
64+
FB_CONFIGMAP="$USER_DIR/logging/fluent-bit_config.configmap_azmonitor.yaml"
6565
else
66-
# use copy in repo
67-
FB_CONFIGMAP="logging/fb/fluent-bit_config.configmap_azmonitor.yaml"
66+
# use copy in repo
67+
FB_CONFIGMAP="logging/fb/fluent-bit_config.configmap_azmonitor.yaml"
6868
fi
6969
log_info "Using FB ConfigMap: $FB_CONFIGMAP"
7070

7171
# Check/Create Connection Info Secret
7272
if [ "$(kubectl -n "$LOG_NS" get secret connection-info-azmonitor -o name 2> /dev/null)" == "" ]; then
7373

74-
export AZMONITOR_CUSTOMER_ID="${AZMONITOR_CUSTOMER_ID:-NotProvided}"
75-
export AZMONITOR_SHARED_KEY="${AZMONITOR_SHARED_KEY:-NotProvided}"
74+
export AZMONITOR_CUSTOMER_ID="${AZMONITOR_CUSTOMER_ID:-NotProvided}"
75+
export AZMONITOR_SHARED_KEY="${AZMONITOR_SHARED_KEY:-NotProvided}"
7676

77-
if [ "$AZMONITOR_CUSTOMER_ID" != "NotProvided" ] && [ "$AZMONITOR_SHARED_KEY" != "NotProvided" ]; then
78-
log_info "Creating secret [connection-info-azmonitor] in [$LOG_NS] namespace to hold Azure connection information."
79-
kubectl -n "$LOG_NS" create secret generic connection-info-azmonitor --from-literal=customer_id="$AZMONITOR_CUSTOMER_ID" --from-literal=shared_key="$AZMONITOR_SHARED_KEY"
80-
else
81-
log_error "Unable to create secret [$LOG_NS/connection-info-azmonitor] because missing required information: [AZMONITOR_CUSTOMER_ID: $AZMONITOR_CUSTOMER_ID ; AZMONITOR_SHARED_KEY: $AZMONITOR_SHARED_KEY]."
82-
log_error "You must provide this information via environment variables or create the secret [connection-info-azmonitor] before running this script."
83-
exit 1
84-
fi
77+
if [ "$AZMONITOR_CUSTOMER_ID" != "NotProvided" ] && [ "$AZMONITOR_SHARED_KEY" != "NotProvided" ]; then
78+
log_info "Creating secret [connection-info-azmonitor] in [$LOG_NS] namespace to hold Azure connection information."
79+
kubectl -n "$LOG_NS" create secret generic connection-info-azmonitor --from-literal=customer_id="$AZMONITOR_CUSTOMER_ID" --from-literal=shared_key="$AZMONITOR_SHARED_KEY"
80+
else
81+
log_error "Unable to create secret [$LOG_NS/connection-info-azmonitor] because missing required information: [AZMONITOR_CUSTOMER_ID: $AZMONITOR_CUSTOMER_ID ; AZMONITOR_SHARED_KEY: $AZMONITOR_SHARED_KEY]."
82+
log_error "You must provide this information via environment variables or create the secret [connection-info-azmonitor] before running this script."
83+
exit 1
84+
fi
8585
else
86-
log_info "Obtaining connection information from existing secret [$LOG_NS/connection-info-azmonitor]"
87-
# Fix SC2155: Declare and assign separately
88-
AZMONITOR_CUSTOMER_ID=$(kubectl -n "$LOG_NS" get secret connection-info-azmonitor -o=jsonpath="{.data.customer_id}" | base64 --decode)
89-
export AZMONITOR_CUSTOMER_ID
90-
AZMONITOR_SHARED_KEY=$(kubectl -n "$LOG_NS" get secret connection-info-azmonitor -o=jsonpath="{.data.shared_key}" | base64 --decode)
91-
export AZMONITOR_SHARED_KEY
86+
log_info "Obtaining connection information from existing secret [$LOG_NS/connection-info-azmonitor]"
87+
# Fix SC2155: Declare and assign separately
88+
AZMONITOR_CUSTOMER_ID=$(kubectl -n "$LOG_NS" get secret connection-info-azmonitor -o=jsonpath="{.data.customer_id}" | base64 --decode)
89+
export AZMONITOR_CUSTOMER_ID
90+
AZMONITOR_SHARED_KEY=$(kubectl -n "$LOG_NS" get secret connection-info-azmonitor -o=jsonpath="{.data.shared_key}" | base64 --decode)
91+
export AZMONITOR_SHARED_KEY
9292
fi
9393

9494
# Check for an existing Helm release of stable/fluent-bit
9595
if helm3ReleaseExists fbaz "$LOG_NS"; then
96-
log_info "Removing an existing release of deprecated stable/fluent-bit Helm chart from from the [$LOG_NS] namespace [$(date)]"
97-
helm "$helmDebug" delete -n "$LOG_NS" fbaz
98-
99-
# Fix SC2155: Declare and assign separately
100-
num_service_monitors_v2=$(kubectl get servicemonitors -A | grep -c fluent-bit-v2 || true)
101-
if [ "$num_service_monitors_v2" -ge 1 ]; then
102-
log_debug "Updated serviceMonitor [fluent-bit-v2] appears to be deployed."
103-
else
104-
num_service_monitors=$(kubectl get servicemonitors -A | grep -c fluent-bit || true)
105-
if [ "$num_service_monitors" -ge 1 ]; then
106-
log_warn "You appear to have an obsolete service monitor in place for monitoring Fluent Bit."
107-
log_warn "Run monitoring/bin/deploy_monitoring_cluster.sh to deploy the current set of service monitors."
96+
log_info "Removing an existing release of deprecated stable/fluent-bit Helm chart from from the [$LOG_NS] namespace [$(date)]"
97+
helm "$helmDebug" delete -n "$LOG_NS" fbaz
98+
99+
# Fix SC2155: Declare and assign separately
100+
num_service_monitors_v2=$(kubectl get servicemonitors -A | grep -c fluent-bit-v2 || true)
101+
if [ "$num_service_monitors_v2" -ge 1 ]; then
102+
log_debug "Updated serviceMonitor [fluent-bit-v2] appears to be deployed."
103+
else
104+
num_service_monitors=$(kubectl get servicemonitors -A | grep -c fluent-bit || true)
105+
if [ "$num_service_monitors" -ge 1 ]; then
106+
log_warn "You appear to have an obsolete service monitor in place for monitoring Fluent Bit."
107+
log_warn "Run monitoring/bin/deploy_monitoring_cluster.sh to deploy the current set of service monitors."
108+
fi
108109
fi
109-
fi
110110
else
111-
log_debug "No existing release of the deprecated stable/fluent-bit Helm chart was found"
111+
log_debug "No existing release of the deprecated stable/fluent-bit Helm chart was found"
112112
fi
113113

114114
# Multiline parser setup
115115
LOG_MULTILINE_ENABLED="${LOG_MULTILINE_ENABLED:-true}"
116116
if [ "$LOG_MULTILINE_ENABLED" == "true" ]; then
117-
LOG_MULTILINE_PARSER="docker, cri"
117+
LOG_MULTILINE_PARSER="docker, cri"
118118
else
119-
LOG_MULTILINE_PARSER=""
119+
LOG_MULTILINE_PARSER=""
120120
fi
121121

122122
# Create ConfigMap containing Fluent Bit configuration
@@ -129,55 +129,55 @@ kubectl -n "$LOG_NS" create configmap fbaz-viya-parsers --from-file=logging/fb/v
129129
TRACING_ENABLE="${TRACING_ENABLE:-false}"
130130
tracingValuesFile=""
131131
if [ "$TRACING_ENABLE" == "true" ]; then
132-
# Create ConfigMap containing tracing config
133-
kubectl -n "$LOG_NS" delete configmap fbaz-viya-tracing --ignore-not-found
134-
kubectl -n "$LOG_NS" create configmap fbaz-viya-tracing --from-file=logging/fb/viya-tracing.conf
132+
# Create ConfigMap containing tracing config
133+
kubectl -n "$LOG_NS" delete configmap fbaz-viya-tracing --ignore-not-found
134+
kubectl -n "$LOG_NS" create configmap fbaz-viya-tracing --from-file=logging/fb/viya-tracing.conf
135135

136-
tracingValuesFile="logging/fb/fluent-bit_helm_values_tracing.yaml"
136+
tracingValuesFile="logging/fb/fluent-bit_helm_values_tracing.yaml"
137137
else
138-
# Create empty ConfigMap for tracing since it is expected to exist in main config
139-
kubectl -n "$LOG_NS" delete configmap fbaz-viya-tracing --ignore-not-found
140-
kubectl -n "$LOG_NS" create configmap fbaz-viya-tracing --from-file="$TMP_DIR"/empty.yaml
138+
# Create empty ConfigMap for tracing since it is expected to exist in main config
139+
kubectl -n "$LOG_NS" delete configmap fbaz-viya-tracing --ignore-not-found
140+
kubectl -n "$LOG_NS" create configmap fbaz-viya-tracing --from-file="$TMP_DIR"/empty.yaml
141141

142-
tracingValuesFile="$TMP_DIR/empty.yaml"
142+
tracingValuesFile="$TMP_DIR/empty.yaml"
143143
fi
144144

145145
# Check for Kubernetes container runtime log format info
146146
KUBERNETES_RUNTIME_LOGFMT="${KUBERNETES_RUNTIME_LOGFMT:-}"
147147
if [ -z "$KUBERNETES_RUNTIME_LOGFMT" ]; then
148-
# Fix SC2155: Declare and assign separately
149-
somenode=$(kubectl get nodes | awk 'NR==2 { print $1 }')
150-
runtime=$(kubectl get node "$somenode" -o "jsonpath={.status.nodeInfo.containerRuntimeVersion}" | awk -F: '{print $1}')
151-
log_debug "Kubernetes container runtime [$runtime] found on node [$somenode]"
152-
case $runtime in
153-
docker)
154-
KUBERNETES_RUNTIME_LOGFMT="docker"
155-
;;
156-
containerd | cri-o)
157-
KUBERNETES_RUNTIME_LOGFMT="criwithlog"
158-
;;
159-
*)
160-
log_warn "Unrecognized Kubernetes container runtime [$runtime]; using default parser"
161-
KUBERNETES_RUNTIME_LOGFMT="docker"
162-
;;
163-
esac
148+
# Fix SC2155: Declare and assign separately
149+
somenode=$(kubectl get nodes | awk 'NR==2 { print $1 }')
150+
runtime=$(kubectl get node "$somenode" -o "jsonpath={.status.nodeInfo.containerRuntimeVersion}" | awk -F: '{print $1}')
151+
log_debug "Kubernetes container runtime [$runtime] found on node [$somenode]"
152+
case $runtime in
153+
docker)
154+
KUBERNETES_RUNTIME_LOGFMT="docker"
155+
;;
156+
containerd | cri-o)
157+
KUBERNETES_RUNTIME_LOGFMT="criwithlog"
158+
;;
159+
*)
160+
log_warn "Unrecognized Kubernetes container runtime [$runtime]; using default parser"
161+
KUBERNETES_RUNTIME_LOGFMT="docker"
162+
;;
163+
esac
164164
fi
165165

166166
MON_NS="${MON_NS:-monitoring}"
167167

168168
# Create ConfigMap containing Kubernetes container runtime log format
169169
kubectl -n "$LOG_NS" delete configmap fbaz-env-vars --ignore-not-found
170170
kubectl -n "$LOG_NS" create configmap fbaz-env-vars \
171-
--from-literal=KUBERNETES_RUNTIME_LOGFMT="$KUBERNETES_RUNTIME_LOGFMT" \
172-
--from-literal=LOG_MULTILINE_PARSER="${LOG_MULTILINE_PARSER}" \
173-
--from-literal=MON_NS="${MON_NS}"
171+
--from-literal=KUBERNETES_RUNTIME_LOGFMT="$KUBERNETES_RUNTIME_LOGFMT" \
172+
--from-literal=LOG_MULTILINE_PARSER="${LOG_MULTILINE_PARSER}" \
173+
--from-literal=MON_NS="${MON_NS}"
174174

175175
kubectl -n "$LOG_NS" label configmap fbaz-env-vars managed-by=v4m-es-script
176176

177177
# Check to see if we are upgrading from earlier version requiring root access
178178
if [ "$(kubectl -n "$LOG_NS" get configmap fbaz-dbmigrate-script -o name --ignore-not-found)" != "configmap/fbaz-dbmigrate-script" ]; then
179-
log_debug "Removing FB pods (if they exist) to allow migration."
180-
kubectl -n "$LOG_NS" delete daemonset v4m-fbaz --ignore-not-found
179+
log_debug "Removing FB pods (if they exist) to allow migration."
180+
kubectl -n "$LOG_NS" delete daemonset v4m-fbaz --ignore-not-found
181181
fi
182182

183183
# Create ConfigMap containing Fluent Bit database migration script
@@ -194,14 +194,14 @@ log_debug "Installing Helm chart from artifact [$chart2install]"
194194

195195
# Deploy Fluent Bit via Helm chart
196196
helm "$helmDebug" upgrade --install v4m-fbaz --namespace "$LOG_NS" \
197-
"$versionstring" \
198-
--values "$TMP_DIR/fb_imagekeysfile.yaml" \
199-
--values "$imageKeysFile" \
200-
--values logging/fb/fluent-bit_helm_values_azmonitor.yaml \
201-
--values "$FB_AZMONITOR_USER_YAML" \
202-
--values "$tracingValuesFile" \
203-
--set fullnameOverride=v4m-fbaz \
204-
"$chart2install"
197+
"$versionstring" \
198+
--values "$TMP_DIR/fb_imagekeysfile.yaml" \
199+
--values "$imageKeysFile" \
200+
--values logging/fb/fluent-bit_helm_values_azmonitor.yaml \
201+
--values "$FB_AZMONITOR_USER_YAML" \
202+
--values "$tracingValuesFile" \
203+
--set fullnameOverride=v4m-fbaz \
204+
"$chart2install"
205205

206206
# pause to allow migration script to complete (if necessary)
207207
sleep 20

logging/bin/deploy_fluentbit_k8sevents_opensearch.sh

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ log_debug "Script [$this_script] has started [$(date)]"
1515
FLUENT_BIT_EVENTS_ENABLED=${FLUENT_BIT_EVENTS_ENABLED:-true}
1616

1717
if [ "$FLUENT_BIT_EVENTS_ENABLED" != "true" ]; then
18-
log_info "Environment variable [FLUENT_BIT_EVENTS_ENABLED] is not set to 'true'; exiting WITHOUT deploying Fluent Bit deployment"
19-
exit 0
18+
log_info "Environment variable [FLUENT_BIT_EVENTS_ENABLED] is not set to 'true'; exiting WITHOUT deploying Fluent Bit deployment"
19+
exit 0
2020
fi
2121

2222
set -e
@@ -31,38 +31,38 @@ log_info "Deploying Fluent Bit for collecting Kubernetes Events..."
3131
# Remove an existing Event Routher deployment?
3232
REMOVE_EVENTROUTER=${REMOVE_EVENTROUTER:-true}
3333
if [ "$REMOVE_EVENTROUTER" == "true" ]; then
34-
if [ "$(kubectl get deployment -n "$LOG_NS" -o name -l app=eventrouter 2> /dev/null)" == "" ]; then
35-
log_debug "No existing instance of Event Router found in namespace [$LOG_NS]."
36-
else
37-
log_debug "Removing an existing instance of Event Router found in namespace [$LOG_NS]."
38-
logging/bin/remove_eventrouter.sh
39-
fi
34+
if [ "$(kubectl get deployment -n "$LOG_NS" -o name -l app=eventrouter 2> /dev/null)" == "" ]; then
35+
log_debug "No existing instance of Event Router found in namespace [$LOG_NS]."
36+
else
37+
log_debug "Removing an existing instance of Event Router found in namespace [$LOG_NS]."
38+
logging/bin/remove_eventrouter.sh
39+
fi
4040
fi
4141

4242
# check for pre-reqs
4343
# Confirm namespace exists
4444
if [ "$(kubectl get ns "$LOG_NS" -o name 2> /dev/null)" == "" ]; then
45-
log_error "Namespace [$LOG_NS] does NOT exist."
46-
exit 1
45+
log_error "Namespace [$LOG_NS] does NOT exist."
46+
exit 1
4747
fi
4848

4949
# get credentials
5050
if [ "$(kubectl -n "$LOG_NS" get secret internal-user-logcollector -o name 2> /dev/null)" == "" ]; then
51-
export ES_LOGCOLLECTOR_PASSWD=${ES_LOGCOLLECTOR_PASSWD}
52-
create_user_secret internal-user-logcollector logcollector "$ES_LOGCOLLECTOR_PASSWD" managed-by=v4m-es-script
51+
export ES_LOGCOLLECTOR_PASSWD=${ES_LOGCOLLECTOR_PASSWD}
52+
create_user_secret internal-user-logcollector logcollector "$ES_LOGCOLLECTOR_PASSWD" managed-by=v4m-es-script
5353
else
54-
get_credentials_from_secret logcollector
55-
rc=$?
56-
if [ "$rc" != "0" ]; then
57-
log_debug "RC=$rc"
58-
exit "$rc"
59-
fi
54+
get_credentials_from_secret logcollector
55+
rc=$?
56+
if [ "$rc" != "0" ]; then
57+
log_debug "RC=$rc"
58+
exit "$rc"
59+
fi
6060
fi
6161

6262
HELM_DEBUG="${HELM_DEBUG:-false}"
6363
helmDebug=""
6464
if [ "$HELM_DEBUG" == "true" ]; then
65-
helmDebug="--debug"
65+
helmDebug="--debug"
6666
fi
6767

6868
helmRepoAdd fluent https://fluent.github.io/helm-charts
@@ -73,17 +73,17 @@ generateImageKeysFile "$FB_FULL_IMAGE" "logging/fb/fb_container_image.template"
7373
# Fluent Bit user customizations
7474
FB_EVENTS_USER_YAML="${FB_EVENTS_USER_YAML:-$USER_DIR/logging/user-values-fluent-bit-events.yaml}"
7575
if [ ! -f "$FB_EVENTS_USER_YAML" ]; then
76-
log_debug "[$FB_EVENTS_USER_YAML] not found. Using $TMP_DIR/empty.yaml"
77-
FB_EVENTS_USER_YAML=$TMP_DIR/empty.yaml
76+
log_debug "[$FB_EVENTS_USER_YAML] not found. Using $TMP_DIR/empty.yaml"
77+
FB_EVENTS_USER_YAML=$TMP_DIR/empty.yaml
7878
fi
7979

8080
# Point to OpenShift response file or dummy as appropriate
8181
openshiftValuesFile="$TMP_DIR/empty.yaml"
8282
if [ "$OPENSHIFT_CLUSTER" == "true" ]; then
83-
log_info "Deploying Fluent Bit on OpenShift cluster"
84-
openshiftValuesFile="logging/openshift/values-fluent-bit-events.yaml"
83+
log_info "Deploying Fluent Bit on OpenShift cluster"
84+
openshiftValuesFile="logging/openshift/values-fluent-bit-events.yaml"
8585
else
86-
log_debug "Fluent Bit is NOT being deployed on OpenShift cluster"
86+
log_debug "Fluent Bit is NOT being deployed on OpenShift cluster"
8787
fi
8888

8989
## Get Helm Chart Name
@@ -97,13 +97,13 @@ log_debug "Installing Helm chart from artifact [$chart2install]"
9797
#shellcheck disable=SC2154
9898
#imagekeysfile is generated in generateImageKeysFile
9999
helm $helmDebug upgrade --install --namespace "$LOG_NS" v4m-fb-events \
100-
"$versionstring" \
101-
--values "$imageKeysFile" \
102-
--values logging/fb/fluent-bit_helm_values_events.yaml \
103-
--values "$openshiftValuesFile" \
104-
--values "$FB_EVENTS_USER_YAML" \
105-
--set fullnameOverride=v4m-fb-events \
106-
"$chart2install"
100+
"$versionstring" \
101+
--values "$imageKeysFile" \
102+
--values logging/fb/fluent-bit_helm_values_events.yaml \
103+
--values "$openshiftValuesFile" \
104+
--values "$FB_EVENTS_USER_YAML" \
105+
--set fullnameOverride=v4m-fb-events \
106+
"$chart2install"
107107

108108
#Container Security: Disable Token Automounting at ServiceAccount; enable for Pod
109109
disable_sa_token_automount "$LOG_NS" v4m-fb-events

0 commit comments

Comments
 (0)