From ebb45c6a3b35e2893bc41ef1b7885138054af9bc Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Fri, 15 Dec 2023 03:18:01 +0100 Subject: [PATCH] [SEMANTIC CONVENTIONS] Code generation script fails on SELINUX (#2455) --- buildscripts/semantic-convention/generate.sh | 25 +++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/buildscripts/semantic-convention/generate.sh b/buildscripts/semantic-convention/generate.sh index 401e6daf60..1994869439 100755 --- a/buildscripts/semantic-convention/generate.sh +++ b/buildscripts/semantic-convention/generate.sh @@ -38,6 +38,19 @@ git fetch origin "$SPEC_VERSION" git reset --hard FETCH_HEAD cd ${SCRIPT_DIR} +# SELINUX +# https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-label + +USE_MOUNT_OPTION="" + +if [ -x "$(command -v getenforce)" ]; then + SELINUXSTATUS=$(getenforce); + if [ "${SELINUXSTATUS}" == "Enforcing" ]; then + echo "Detected SELINUX" + USE_MOUNT_OPTION=":z" + fi; +fi + # echo "Help ..." # docker run --rm otel/semconvgen:$GENERATOR_VERSION -h @@ -45,9 +58,9 @@ cd ${SCRIPT_DIR} echo "Generating semantic conventions for traces ..." docker run --rm \ - -v ${SCRIPT_DIR}/tmp-semconv/model:/source \ - -v ${SCRIPT_DIR}/templates:/templates \ - -v ${ROOT_DIR}/api/include/opentelemetry/trace/:/output \ + -v ${SCRIPT_DIR}/tmp-semconv/model:/source${USE_MOUNT_OPTION} \ + -v ${SCRIPT_DIR}/templates:/templates${USE_MOUNT_OPTION} \ + -v ${ROOT_DIR}/api/include/opentelemetry/trace/:/output${USE_MOUNT_OPTION} \ otel/semconvgen:$GENERATOR_VERSION \ --only span,event,attribute_group,scope \ -f /source code \ @@ -62,9 +75,9 @@ docker run --rm \ echo "Generating semantic conventions for resources ..." docker run --rm \ - -v ${SCRIPT_DIR}/tmp-semconv/model:/source \ - -v ${SCRIPT_DIR}/templates:/templates \ - -v ${ROOT_DIR}/sdk/include/opentelemetry/sdk/resource/:/output \ + -v ${SCRIPT_DIR}/tmp-semconv/model:/source${USE_MOUNT_OPTION} \ + -v ${SCRIPT_DIR}/templates:/templates${USE_MOUNT_OPTION} \ + -v ${ROOT_DIR}/sdk/include/opentelemetry/sdk/resource/:/output${USE_MOUNT_OPTION} \ otel/semconvgen:$GENERATOR_VERSION \ --only resource \ -f /source code \