[fix #17] Implement Immediate Exit fix UID issue and container args issue for compatibility with grafana-operator. (#18)

* Added an error code to catch the exception for grafana-operator when it is used as an grafana Plugin Init image

* Fixed issues with the grafana image and the grafana-operator

* Fixed the issues with the additional grafana user

* Added a fix which check is the first provided command is executable or not

* Remove hardcoded uid from image building

* Update Dockerfile

* Fixed the grafana image to use the correct uid and also work with OpenShift random uids

* Added somewhat correct error code handling for the immediate exit

* Update 8/debian-10/rootfs/opt/bitnami/scripts/grafana/entrypoint.sh

Co-authored-by: Marcos Bjoerkelund <marcosbc@users.noreply.github.com>

* Update 8/debian-10/rootfs/opt/bitnami/scripts/grafana/entrypoint.sh

Co-authored-by: Marcos Bjoerkelund <marcosbc@users.noreply.github.com>

* Update 8/debian-10/rootfs/opt/bitnami/scripts/grafana/entrypoint.sh

Co-authored-by: Marcos Bjoerkelund <marcosbc@users.noreply.github.com>

* Added cleaner execution path for conditional check

* Use --system again

Co-authored-by: Marcos Bjoerkelund <marcosbc@users.noreply.github.com>
This commit is contained in:
Marcel Fest 2021-12-27 14:40:57 +01:00 committed by GitHub
parent def5b4851f
commit d266d270f8
2 changed files with 25 additions and 3 deletions

View File

@ -14,13 +14,35 @@ set -o pipefail
. /opt/bitnami/scripts/libbitnami.sh
. /opt/bitnami/scripts/liblog.sh
function is_exec() {
# This checks if the first provided argument is executable or if only args was used
exec_in_path=$(builtin type -P "$1" 2> /dev/null)
if [[ -f "$1" && -x $(realpath "$1" 2> /dev/null) || -x $(realpath "$exec_in_path" 2> /dev/null) ]]; then
true;
else
false;
fi;
}
print_welcome_page
if [[ "$1" = "/opt/bitnami/scripts/grafana/run.sh" ]]; then
/opt/bitnami/scripts/grafana/setup.sh
# This catches the error-code from libgrafana.sh for the immediate exit when the grafana-operator is used. And ensure that the exit code is kept silently.
/opt/bitnami/scripts/grafana/setup.sh || GRAFANA_OPERATOR_IMMEDIATE_EXIT=$?
if [[ "${GRAFANA_OPERATOR_IMMEDIATE_EXIT:-0}" -eq 255 ]]; then
exit 0
elif [[ "${GRAFANA_OPERATOR_IMMEDIATE_EXIT:-0}" -ne 0 ]]; then
exit "$GRAFANA_OPERATOR_IMMEDIATE_EXIT"
fi
/post-init.sh
info "** Grafana setup finished! **"
fi
echo ""
exec "$@"
if is_exec "$1"; then
exec "$@"
else
exec "/opt/bitnami/scripts/grafana/run.sh" "$@"
fi

View File

@ -102,7 +102,7 @@ grafana_initialize() {
else
warn "There are no plugins to install"
fi
return
return 255
fi
# Recover plugins installed when building the image