Skip to content
Snippets Groups Projects
Commit dbf53866 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

added debug infos

parent 6404bee9
No related branches found
No related tags found
1 merge request!233Docker checks: remove emoji icons; handle "null" in license info; show rootless or not
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
. $(dirname $0)/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions
_is_docker_rootless=0
_is_docker_detected=0
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# FUNCTIONS # FUNCTIONS
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -32,19 +35,33 @@ function _filterJson(){ ...@@ -32,19 +35,33 @@ function _filterJson(){
# param string json data # param string json data
# param string jq filter # param string jq filter
function _getString(){ function _getString(){
_filterJson "$1" "$2" | tr -d '"' _filterJson "$1" "$2" | tr -d '"' | sed "s#^null\$##"
} }
# if DOCKER_HOST is not set we try to detect the user running "containerd" # if DOCKER_HOST is not set we try to detect the user running "containerd"
# create an env var DOCKER_HOST="unix:///run/user/<ID>/docker.sock" # create an env var DOCKER_HOST="unix:///run/user/<ID>/docker.sock"
function _detectDockerenv(){ function _detectDockerenv(){
local dockeruid=
if [ -z "$DOCKER_HOST" ]; then if [ -z "$DOCKER_HOST" ]; then
_is_docker_detected=1
dockeruid=$( ps -ef | grep containerd | grep -Eo "/run/user/([0-9]*)/" | head -1 | cut -f 4 -d '/' ) dockeruid=$( ps -ef | grep containerd | grep -Eo "/run/user/([0-9]*)/" | head -1 | cut -f 4 -d '/' )
test -n "$dockeruid" && export DOCKER_HOST="unix:///run/user/$dockeruid/docker.sock" test -n "$dockeruid" && export DOCKER_HOST="unix:///run/user/$dockeruid/docker.sock"
# Don't abort - it is allowed that the variable DOCKER_HOST is missing # Don't abort - it is allowed that the variable DOCKER_HOST is missing
fi fi
if grep "/run/user/[0-9]*" <<< "$DOCKER_HOST" >/dev/null; then
_is_docker_rootless=1
fi
} }
# show some debug infos to be shown if needed.
function _debugInfos(){
echo
echo "DEBUG INFOS:"
echo "DOCKER_HOST = $DOCKER_HOST"
test "$_is_docker_detected" -eq 0 && echo "It was set in the environment."
test "$_is_docker_detected" -eq 1 && echo "It was detected from process list."
echo
}
# detect error after dicker command. It stops if # detect error after dicker command. It stops if
# - no content was fetched # - no content was fetched
# - content contains key "ServerErrors" # - content contains key "ServerErrors"
...@@ -57,6 +74,7 @@ function _detectDockererror(){ ...@@ -57,6 +74,7 @@ function _detectDockererror(){
ph.exit ph.exit
fi fi
local sSrvErrror;
sSrvErrror=$( _filterJson "$data" ".ServerErrors" ) sSrvErrror=$( _filterJson "$data" ".ServerErrors" )
if [ "$sSrvErrror" != "null" ] ; then if [ "$sSrvErrror" != "null" ] ; then
ph.setStatus unknown ph.setStatus unknown
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment