From c99503d988a7e075bf1dcbc5c601a3469f8c043f Mon Sep 17 00:00:00 2001 From: xeniape Date: Thu, 2 May 2024 10:59:35 +0200 Subject: [PATCH 01/11] add script to process logs from opa --- opa/Dockerfile | 27 +++++++-- opa/stackable/bin/process-logs | 108 +++++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+), 4 deletions(-) create mode 100755 opa/stackable/bin/process-logs diff --git a/opa/Dockerfile b/opa/Dockerfile index ebaa0ebd3..3075ddb19 100644 --- a/opa/Dockerfile +++ b/opa/Dockerfile @@ -10,7 +10,18 @@ ARG BUNDLE_BUILDER_VERSION # Update image and install everything needed for Rustup & Rust RUN microdnf update --disablerepo=* --enablerepo=ubi-8-appstream-rpms --enablerepo=ubi-8-baseos-rpms -y \ && rm -rf /var/cache/yum \ - && microdnf install --disablerepo=* --enablerepo=ubi-8-appstream-rpms --enablerepo=ubi-8-baseos-rpms curl findutils gcc gcc-c++ git make cmake openssl-devel pkg-config systemd-devel unzip -y \ + && microdnf install --disablerepo=* --enablerepo=ubi-8-appstream-rpms --enablerepo=ubi-8-baseos-rpms -y \ + curl \ + findutils \ + gcc \ + gcc-c++ \ + git \ + make \ + cmake \ + openssl-devel \ + pkg-config \ + systemd-devel \ + unzip \ && rm -rf /var/cache/yum WORKDIR / @@ -60,8 +71,12 @@ LABEL name="Open Policy Agent" \ description="This image is deployed by the Stackable Operator for OPA." RUN microdnf update && \ - microdnf install tar gzip && \ - microdnf clean all + microdnf install \ + tar \ + gzip \ + # Required for filtering logs + jq \ + && microdnf clean all COPY opa/licenses /licenses @@ -76,4 +91,8 @@ RUN curl --fail -L "https://repo.stackable.tech/repository/packages/opa/opa_${TA COPY --from=opa-bundle-builder --chown=stackable:stackable /opa-bundle-builder/target/release/stackable-opa-bundle-builder /stackable/opa-bundle-builder COPY --from=multilog-builder --chown=stackable:stackable /daemontools/admin/daemontools/command/multilog /stackable/multilog -CMD ["./opa", "run", "-s"] +COPY --chown=stackable:stackable opa/stackable/bin /stackable/opa/bin + +ENV PATH="${PATH}":/stackable/opa:/stackable/opa/bin + +CMD ["opa", "run", "-s"] diff --git a/opa/stackable/bin/process-logs b/opa/stackable/bin/process-logs new file mode 100755 index 000000000..93e51cbd5 --- /dev/null +++ b/opa/stackable/bin/process-logs @@ -0,0 +1,108 @@ +#!/usr/bin/env bash +# +# This file was created by the Stackable developers. +# +# Usage: process-logs +# Options: +# --console-log-level +# --file-log-level +# --decision-log-level +# --server-log-level +# --help +# +# Processes incoming log messages. Log messages are filtered by the set log levels +# and forwarded to the output destinations console and/or file. +# + +# inputs +CONSOLE_LEVEL="info" +FILE_LEVEL="info" +SERVER_LEVEL="info" +DECISION_LEVEL="info" + +# inputs forwarded to /stackable/multilog script +OPA_ROLLING_LOG_FILE_SIZE_BYTES=5000000 +OPA_ROLLING_LOG_FILES=2 +STACKABLE_LOG_DIR=/stackable/log +CONTAINER_NAME=opa + +parse_args() { + while true; do + case $1 in + --console-log-level) + shift + CONSOLE_LEVEL=$1 + ;; + --file-log-level) + shift + FILE_LEVEL=$1 + ;; + --decision-log-level) + shift + DECISION_LEVEL=$1 + ;; + --server-log-level) + shift + SERVER_LEVEL=$1 + ;; + --opa-rolling-log-file-size-bytes) + shift + OPA_ROLLING_LOG_FILE_SIZE_BYTES=$1 + ;; + --opa-rolling-log-files) + shift + OPA_ROLLING_LOG_FILES=$1 + ;; + --stackable-log-dir) + shift + STACKABLE_LOG_DIR=$1 + ;; + --container-name) + shift + CONTAINER_NAME=$1 + ;; + *) + break + ;; + esac + shift + done +} + +get_levels() { + case $1 in + fatal) + echo '["fatal"]' ;; + error) + echo '["error","fatal"]' ;; + warn) + echo '["warn","error","fatal"]' ;; + info) + echo '["info","warn","error","fatal"]' ;; + debug) + echo '["debug","info","warn","error","fatal"]' ;; + trace) + echo '["trace","debug","info","warn","error","fatal"]' ;; + *) + echo '[""]' ;; + esac +} + +main() { + parse_args $@ + + local DECISION_LEVELS=$(get_levels $DECISION_LEVEL) + local SERVER_LEVELS=$(get_levels $SERVER_LEVEL) + local CONSOLE_LEVELS=$(get_levels $CONSOLE_LEVEL) + local FILE_LEVELS=$(get_levels $FILE_LEVEL) + + jq -c --unbuffered 'if .decision_id then .logger = "decision" else .logger = "server" end' | + jq -c --unbuffered --arg decision_levels $DECISION_LEVELS --arg server_levels $SERVER_LEVELS \ + 'select(((.logger == "decision") and (.level | inside($decision_levels))) or + ((.logger == "server") and (.level | inside($server_levels))))' | + tee >(jq -c --unbuffered --arg file_levels $FILE_LEVELS 'select(.level | inside($file_levels))' \ + > >(/stackable/multilog s$OPA_ROLLING_LOG_FILE_SIZE_BYTES n$OPA_ROLLING_LOG_FILES $STACKABLE_LOG_DIR/$CONTAINER_NAME)) | + jq -c --unbuffered --arg console_levels $CONSOLE_LEVELS 'select(.level | inside($console_levels))' +} + +main $@ From 7158e868f573e1f63224d6922c0b1e4bd1ab0776 Mon Sep 17 00:00:00 2001 From: xeniape Date: Thu, 23 May 2024 15:22:59 +0200 Subject: [PATCH 02/11] exit with error if parameters are not set --- opa/Dockerfile | 2 +- opa/stackable/bin/process-logs | 57 ++++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/opa/Dockerfile b/opa/Dockerfile index 3075ddb19..f4c705328 100644 --- a/opa/Dockerfile +++ b/opa/Dockerfile @@ -93,6 +93,6 @@ COPY --from=multilog-builder --chown=stackable:stackable /daemontools/admin/daem COPY --chown=stackable:stackable opa/stackable/bin /stackable/opa/bin -ENV PATH="${PATH}":/stackable/opa:/stackable/opa/bin +ENV PATH="${PATH}:/stackable/opa:/stackable/opa/bin" CMD ["opa", "run", "-s"] diff --git a/opa/stackable/bin/process-logs b/opa/stackable/bin/process-logs index 93e51cbd5..b976c3747 100755 --- a/opa/stackable/bin/process-logs +++ b/opa/stackable/bin/process-logs @@ -8,24 +8,15 @@ # --file-log-level # --decision-log-level # --server-log-level -# --help +# --opa-rolling-log-file-size-bytes +# --opa-rolling-log-files +# --stackable-log-dir +# --container-name # # Processes incoming log messages. Log messages are filtered by the set log levels # and forwarded to the output destinations console and/or file. # -# inputs -CONSOLE_LEVEL="info" -FILE_LEVEL="info" -SERVER_LEVEL="info" -DECISION_LEVEL="info" - -# inputs forwarded to /stackable/multilog script -OPA_ROLLING_LOG_FILE_SIZE_BYTES=5000000 -OPA_ROLLING_LOG_FILES=2 -STACKABLE_LOG_DIR=/stackable/log -CONTAINER_NAME=opa - parse_args() { while true; do case $1 in @@ -67,6 +58,46 @@ parse_args() { esac shift done + + if [ -z "${CONSOLE_LEVEL}" ]; then + echo "ERROR: parameter --console-log-level cannot be empty" + exit 1 + fi + + if [ -z "${FILE_LEVEL}" ]; then + echo "ERROR: parameter --file-log-level cannot be empty" + exit 1 + fi + + if [ -z "${DECISION_LEVEL}" ]; then + echo "ERROR: parameter --decision-log-level cannot be empty" + exit 1 + fi + + if [ -z "${SERVER_LEVEL}" ]; then + echo "ERROR: parameter --server-log-level cannot be empty" + exit 1 + fi + + if [ -z "${OPA_ROLLING_LOG_FILE_SIZE_BYTES}" ]; then + echo "ERROR: parameter --opa-rolling-log-file-size-bytes cannot be empty" + exit 1 + fi + + if [ -z "${OPA_ROLLING_LOG_FILES}" ]; then + echo "ERROR: parameter --opa-rolling-log-files cannot be empty" + exit 1 + fi + + if [ -z "${STACKABLE_LOG_DIR}" ]; then + echo "ERROR: parameter --stackable-log-dir cannot be empty" + exit 1 + fi + + if [ -z "${CONTAINER_NAME}" ]; then + echo "ERROR: parameter --container-name cannot be empty" + exit 1 + fi } get_levels() { From 1f0481c46b6fe0c5c46e662bb318caabf32a4b57 Mon Sep 17 00:00:00 2001 From: xeniape Date: Thu, 23 May 2024 15:39:19 +0200 Subject: [PATCH 03/11] jq for log filtering --- opa/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/opa/Dockerfile b/opa/Dockerfile index 46e217f5b..c8515dfb7 100644 --- a/opa/Dockerfile +++ b/opa/Dockerfile @@ -109,6 +109,9 @@ LABEL name="Open Policy Agent" \ description="This image is deployed by the Stackable Operator for OPA." RUN microdnf update && \ + microdnf install \ + # Required for filtering logs + jq && \ microdnf clean all && \ rm -rf /var/cache/yum From feaf6c5ffc524f89edbcd4795e8ac64c85f7f7e5 Mon Sep 17 00:00:00 2001 From: xeniape Date: Mon, 27 May 2024 08:41:11 +0200 Subject: [PATCH 04/11] add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cba6558c0..1c382de3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ All notable changes to this project will be documented in this file. - stackable-base: Mitigate CVE-2023-37920 by removing e-Tugra root certificates ([#673]). - hdfs: Exclude unused jars and mitigate snappy-java CVEs by bumping dependency ([#682]). - druid: Build from source ([#684]). +- opa: Add log processing script to opa for decision logging ([#695]) ### Changed @@ -87,6 +88,7 @@ All notable changes to this project will be documented in this file. [#684]: https://github.com/stackabletech/docker-images/pull/684 [#685]: https://github.com/stackabletech/docker-images/pull/685 [#688]: https://github.com/stackabletech/docker-images/pull/688 +[#695]: https://github.com/stackabletech/docker-images/pull/695 ## [24.3.0] - 2024-03-20 From d48f08e55679047f483affe44df33ca8d7c5f5bb Mon Sep 17 00:00:00 2001 From: xeniape Date: Mon, 27 May 2024 13:53:46 +0200 Subject: [PATCH 05/11] security fixes --- opa/stackable/bin/process-logs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/opa/stackable/bin/process-logs b/opa/stackable/bin/process-logs index b976c3747..df91b027c 100755 --- a/opa/stackable/bin/process-logs +++ b/opa/stackable/bin/process-logs @@ -17,6 +17,8 @@ # and forwarded to the output destinations console and/or file. # +set -euo pipefail + parse_args() { while true; do case $1 in @@ -122,18 +124,18 @@ get_levels() { main() { parse_args $@ - local DECISION_LEVELS=$(get_levels $DECISION_LEVEL) - local SERVER_LEVELS=$(get_levels $SERVER_LEVEL) - local CONSOLE_LEVELS=$(get_levels $CONSOLE_LEVEL) - local FILE_LEVELS=$(get_levels $FILE_LEVEL) + local DECISION_LEVELS=$(get_levels "$DECISION_LEVEL") + local SERVER_LEVELS=$(get_levels "$SERVER_LEVEL") + local CONSOLE_LEVELS=$(get_levels "$CONSOLE_LEVEL") + local FILE_LEVELS=$(get_levels "$FILE_LEVEL") jq -c --unbuffered 'if .decision_id then .logger = "decision" else .logger = "server" end' | - jq -c --unbuffered --arg decision_levels $DECISION_LEVELS --arg server_levels $SERVER_LEVELS \ + jq -c --unbuffered --arg decision_levels "$DECISION_LEVELS" --arg server_levels "$SERVER_LEVELS" \ 'select(((.logger == "decision") and (.level | inside($decision_levels))) or ((.logger == "server") and (.level | inside($server_levels))))' | - tee >(jq -c --unbuffered --arg file_levels $FILE_LEVELS 'select(.level | inside($file_levels))' \ - > >(/stackable/multilog s$OPA_ROLLING_LOG_FILE_SIZE_BYTES n$OPA_ROLLING_LOG_FILES $STACKABLE_LOG_DIR/$CONTAINER_NAME)) | - jq -c --unbuffered --arg console_levels $CONSOLE_LEVELS 'select(.level | inside($console_levels))' + tee >(jq -c --unbuffered --arg file_levels "$FILE_LEVELS" 'select(.level | inside($file_levels))' \ + > >(/stackable/multilog s"$OPA_ROLLING_LOG_FILE_SIZE_BYTES" n"$OPA_ROLLING_LOG_FILES" "$STACKABLE_LOG_DIR"/"$CONTAINER_NAME")) | + jq -c --unbuffered --arg console_levels "$CONSOLE_LEVELS" 'select(.level | inside($console_levels))' } main $@ From 92ed079a5600751ba3724c16277b2fc41ee1e149 Mon Sep 17 00:00:00 2001 From: xeniape Date: Mon, 27 May 2024 14:03:47 +0200 Subject: [PATCH 06/11] shellcheck linting --- opa/stackable/bin/process-logs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/opa/stackable/bin/process-logs b/opa/stackable/bin/process-logs index df91b027c..ff985bb76 100755 --- a/opa/stackable/bin/process-logs +++ b/opa/stackable/bin/process-logs @@ -122,12 +122,16 @@ get_levels() { } main() { - parse_args $@ + parse_args "$@" - local DECISION_LEVELS=$(get_levels "$DECISION_LEVEL") - local SERVER_LEVELS=$(get_levels "$SERVER_LEVEL") - local CONSOLE_LEVELS=$(get_levels "$CONSOLE_LEVEL") - local FILE_LEVELS=$(get_levels "$FILE_LEVEL") + local DECISION_LEVELS + DECISION_LEVELS=$(get_levels "$DECISION_LEVEL") + local SERVER_LEVELS + SERVER_LEVELS=$(get_levels "$SERVER_LEVEL") + local CONSOLE_LEVELS + CONSOLE_LEVELS=$(get_levels "$CONSOLE_LEVEL") + local FILE_LEVELS + FILE_LEVELS=$(get_levels "$FILE_LEVEL") jq -c --unbuffered 'if .decision_id then .logger = "decision" else .logger = "server" end' | jq -c --unbuffered --arg decision_levels "$DECISION_LEVELS" --arg server_levels "$SERVER_LEVELS" \ @@ -138,4 +142,4 @@ main() { jq -c --unbuffered --arg console_levels "$CONSOLE_LEVELS" 'select(.level | inside($console_levels))' } -main $@ +main "$@" From 160528fe3b3df769285dd69ec4c87b2c16dcc6ab Mon Sep 17 00:00:00 2001 From: xeniape Date: Mon, 27 May 2024 15:46:12 +0200 Subject: [PATCH 07/11] fix changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c382de3c..d856d3609 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ All notable changes to this project will be documented in this file. - stackable-base: Mitigate CVE-2023-37920 by removing e-Tugra root certificates ([#673]). - hdfs: Exclude unused jars and mitigate snappy-java CVEs by bumping dependency ([#682]). - druid: Build from source ([#684]). -- opa: Add log processing script to opa for decision logging ([#695]) +- opa: Add log processing script to opa for decision logging ([#695]). ### Changed From b5533dbf5b94a8ae8b52bdc43a36a2bc44fcf3bf Mon Sep 17 00:00:00 2001 From: xeniape Date: Tue, 28 May 2024 11:29:47 +0200 Subject: [PATCH 08/11] add errorhandling for jq command --- opa/stackable/bin/process-logs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/opa/stackable/bin/process-logs b/opa/stackable/bin/process-logs index ff985bb76..a2ba39d69 100755 --- a/opa/stackable/bin/process-logs +++ b/opa/stackable/bin/process-logs @@ -17,42 +17,42 @@ # and forwarded to the output destinations console and/or file. # -set -euo pipefail +set -eo pipefail parse_args() { while true; do case $1 in --console-log-level) shift - CONSOLE_LEVEL=$1 + CONSOLE_LEVEL="$1" ;; --file-log-level) shift - FILE_LEVEL=$1 + FILE_LEVEL="$1" ;; --decision-log-level) shift - DECISION_LEVEL=$1 + DECISION_LEVEL="$1" ;; --server-log-level) shift - SERVER_LEVEL=$1 + SERVER_LEVEL="$1" ;; --opa-rolling-log-file-size-bytes) shift - OPA_ROLLING_LOG_FILE_SIZE_BYTES=$1 + OPA_ROLLING_LOG_FILE_SIZE_BYTES="$1" ;; --opa-rolling-log-files) shift - OPA_ROLLING_LOG_FILES=$1 + OPA_ROLLING_LOG_FILES="$1" ;; --stackable-log-dir) shift - STACKABLE_LOG_DIR=$1 + STACKABLE_LOG_DIR="$1" ;; --container-name) shift - CONTAINER_NAME=$1 + CONTAINER_NAME="$1" ;; *) break @@ -133,10 +133,9 @@ main() { local FILE_LEVELS FILE_LEVELS=$(get_levels "$FILE_LEVEL") - jq -c --unbuffered 'if .decision_id then .logger = "decision" else .logger = "server" end' | - jq -c --unbuffered --arg decision_levels "$DECISION_LEVELS" --arg server_levels "$SERVER_LEVELS" \ - 'select(((.logger == "decision") and (.level | inside($decision_levels))) or - ((.logger == "server") and (.level | inside($server_levels))))' | + jq -R -c --unbuffered --arg decision_levels "$DECISION_LEVELS" --arg server_levels "$SERVER_LEVELS" \ + 'try (fromjson | if .decision_id then .logger = "decision" else .logger = "server" end | select(((.logger == "decision") and (.level | inside($decision_levels))) or + ((.logger == "server") and (.level | inside($server_levels))))) catch {"level":"warn","msg":"Could not process log message"}' | tee >(jq -c --unbuffered --arg file_levels "$FILE_LEVELS" 'select(.level | inside($file_levels))' \ > >(/stackable/multilog s"$OPA_ROLLING_LOG_FILE_SIZE_BYTES" n"$OPA_ROLLING_LOG_FILES" "$STACKABLE_LOG_DIR"/"$CONTAINER_NAME")) | jq -c --unbuffered --arg console_levels "$CONSOLE_LEVELS" 'select(.level | inside($console_levels))' From 554675f718ba2d7c5f526e83f3fed75b72e4f839 Mon Sep 17 00:00:00 2001 From: xeniape Date: Wed, 29 May 2024 08:47:21 +0200 Subject: [PATCH 09/11] small code improvements --- opa/stackable/bin/process-logs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opa/stackable/bin/process-logs b/opa/stackable/bin/process-logs index a2ba39d69..c9cdfb30a 100755 --- a/opa/stackable/bin/process-logs +++ b/opa/stackable/bin/process-logs @@ -17,10 +17,11 @@ # and forwarded to the output destinations console and/or file. # -set -eo pipefail +set -euo pipefail parse_args() { while true; do + [ $# -eq 0 ] && break case $1 in --console-log-level) shift @@ -117,7 +118,7 @@ get_levels() { trace) echo '["trace","debug","info","warn","error","fatal"]' ;; *) - echo '[""]' ;; + echo '[]' ;; esac } From a2e0adcd26b5ed6dcc1235a083f79ae24c7ee20c Mon Sep 17 00:00:00 2001 From: xeniape Date: Wed, 29 May 2024 13:25:35 +0200 Subject: [PATCH 10/11] add information to catch output --- opa/stackable/bin/process-logs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opa/stackable/bin/process-logs b/opa/stackable/bin/process-logs index c9cdfb30a..d9c46dc7a 100755 --- a/opa/stackable/bin/process-logs +++ b/opa/stackable/bin/process-logs @@ -136,10 +136,11 @@ main() { jq -R -c --unbuffered --arg decision_levels "$DECISION_LEVELS" --arg server_levels "$SERVER_LEVELS" \ 'try (fromjson | if .decision_id then .logger = "decision" else .logger = "server" end | select(((.logger == "decision") and (.level | inside($decision_levels))) or - ((.logger == "server") and (.level | inside($server_levels))))) catch {"level":"warn","msg":"Could not process log message"}' | + ((.logger == "server") and (.level | inside($server_levels))))) catch {"time":(now | todate),"level":"info","msg":"Could not process log message","error":true}' | tee >(jq -c --unbuffered --arg file_levels "$FILE_LEVELS" 'select(.level | inside($file_levels))' \ > >(/stackable/multilog s"$OPA_ROLLING_LOG_FILE_SIZE_BYTES" n"$OPA_ROLLING_LOG_FILES" "$STACKABLE_LOG_DIR"/"$CONTAINER_NAME")) | jq -c --unbuffered --arg console_levels "$CONSOLE_LEVELS" 'select(.level | inside($console_levels))' + } main "$@" From cf1de10e8ed7f437e4535563c446b93c6441c931 Mon Sep 17 00:00:00 2001 From: xeniape Date: Wed, 29 May 2024 17:08:43 +0200 Subject: [PATCH 11/11] read from env vars directly --- opa/stackable/bin/process-logs | 138 ++++++++++----------------------- 1 file changed, 40 insertions(+), 98 deletions(-) diff --git a/opa/stackable/bin/process-logs b/opa/stackable/bin/process-logs index d9c46dc7a..75de8c6a5 100755 --- a/opa/stackable/bin/process-logs +++ b/opa/stackable/bin/process-logs @@ -2,106 +2,51 @@ # # This file was created by the Stackable developers. # -# Usage: process-logs -# Options: -# --console-log-level -# --file-log-level -# --decision-log-level -# --server-log-level -# --opa-rolling-log-file-size-bytes -# --opa-rolling-log-files -# --stackable-log-dir -# --container-name -# # Processes incoming log messages. Log messages are filtered by the set log levels # and forwarded to the output destinations console and/or file. # set -euo pipefail -parse_args() { - while true; do - [ $# -eq 0 ] && break - case $1 in - --console-log-level) - shift - CONSOLE_LEVEL="$1" - ;; - --file-log-level) - shift - FILE_LEVEL="$1" - ;; - --decision-log-level) - shift - DECISION_LEVEL="$1" - ;; - --server-log-level) - shift - SERVER_LEVEL="$1" - ;; - --opa-rolling-log-file-size-bytes) - shift - OPA_ROLLING_LOG_FILE_SIZE_BYTES="$1" - ;; - --opa-rolling-log-files) - shift - OPA_ROLLING_LOG_FILES="$1" - ;; - --stackable-log-dir) - shift - STACKABLE_LOG_DIR="$1" - ;; - --container-name) - shift - CONTAINER_NAME="$1" - ;; - *) - break - ;; - esac - shift - done - - if [ -z "${CONSOLE_LEVEL}" ]; then - echo "ERROR: parameter --console-log-level cannot be empty" - exit 1 - fi - - if [ -z "${FILE_LEVEL}" ]; then - echo "ERROR: parameter --file-log-level cannot be empty" - exit 1 - fi - - if [ -z "${DECISION_LEVEL}" ]; then - echo "ERROR: parameter --decision-log-level cannot be empty" - exit 1 - fi - - if [ -z "${SERVER_LEVEL}" ]; then - echo "ERROR: parameter --server-log-level cannot be empty" - exit 1 - fi - - if [ -z "${OPA_ROLLING_LOG_FILE_SIZE_BYTES}" ]; then - echo "ERROR: parameter --opa-rolling-log-file-size-bytes cannot be empty" - exit 1 - fi - - if [ -z "${OPA_ROLLING_LOG_FILES}" ]; then - echo "ERROR: parameter --opa-rolling-log-files cannot be empty" - exit 1 - fi - - if [ -z "${STACKABLE_LOG_DIR}" ]; then - echo "ERROR: parameter --stackable-log-dir cannot be empty" - exit 1 - fi - - if [ -z "${CONTAINER_NAME}" ]; then - echo "ERROR: parameter --container-name cannot be empty" - exit 1 - fi -} +if [ -z "${CONSOLE_LEVEL}" ]; then + echo "ERROR: env variable CONSOLE_LEVEL cannot be empty" + exit 1 +fi + +if [ -z "${FILE_LEVEL}" ]; then + echo "ERROR: env variable FILE_LEVEL cannot be empty" + exit 1 +fi + +if [ -z "${DECISION_LEVEL}" ]; then + echo "ERROR: env variable DECISION_LEVEL cannot be empty" + exit 1 +fi + +if [ -z "${SERVER_LEVEL}" ]; then + echo "ERROR: env variable SERVER_LEVEL cannot be empty" + exit 1 +fi + +if [ -z "${OPA_ROLLING_LOG_FILE_SIZE_BYTES}" ]; then + echo "ERROR: env variable OPA_ROLLING_LOG_FILE_SIZE_BYTES cannot be empty" + exit 1 +fi + +if [ -z "${OPA_ROLLING_LOG_FILES}" ]; then + echo "ERROR: env variable OPA_ROLLING_LOG_FILES cannot be empty" + exit 1 +fi + +if [ -z "${STACKABLE_LOG_DIR}" ]; then + echo "ERROR: env variable STACKABLE_LOG_DIR cannot be empty" + exit 1 +fi + +if [ -z "${CONTAINER_NAME}" ]; then + echo "ERROR: env variable CONTAINER_NAME cannot be empty" + exit 1 +fi get_levels() { case $1 in @@ -123,8 +68,6 @@ get_levels() { } main() { - parse_args "$@" - local DECISION_LEVELS DECISION_LEVELS=$(get_levels "$DECISION_LEVEL") local SERVER_LEVELS @@ -140,7 +83,6 @@ main() { tee >(jq -c --unbuffered --arg file_levels "$FILE_LEVELS" 'select(.level | inside($file_levels))' \ > >(/stackable/multilog s"$OPA_ROLLING_LOG_FILE_SIZE_BYTES" n"$OPA_ROLLING_LOG_FILES" "$STACKABLE_LOG_DIR"/"$CONTAINER_NAME")) | jq -c --unbuffered --arg console_levels "$CONSOLE_LEVELS" 'select(.level | inside($console_levels))' - } -main "$@" +main