Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 37 additions & 7 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ readonly LOG_FILE="/tmp/sg_runner.log"
readonly COMMANDS=( "jq" "crontab" )
# readonly CONTAINER_ORCHESTRATORS=( "docker" "podman" )
readonly CONTAINER_ORCHESTRATORS=( "docker" )
readonly FLUENTBIT_IMAGE="fluent/fluent-bit:2.2.0"
FLUENTBIT_IMAGE="fluent/fluent-bit:2.2.0"

# source .env if exists
# overrides [main] environment variables
Expand Down Expand Up @@ -1095,19 +1095,49 @@ fetch_organization_info() { #{{{
# This portion checks whether the STORAGE_BACKEND_TYPE is
# aws_s3 or azure_blob and runs the container accordingly.
########################################
pull_fluentbit_image(){
images=("public.ecr.aws/d4h1t0h5/private-runner/fluentbit:2.2.0" "fluent/fluent-bit:2.2.0")

for image in "${images}"; do
image_exists="$($CONTAINER_ORCHESTRATOR images -q -f reference="$FLUENTBIT_IMAGE")"

# return true if image is found
if [[ -n "$image_exists" ]]; then
FLUENTBIT_IMAGE="${image}"
return 0
fi
done

$CONTAINER_ORCHESTRATOR pull "${images[0]}" >> "$LOG_FILE" 2>&1
image_pulled=$?

FLUENTBIT_IMAGE="${images[0]}"

if [[ $image_pulled -gt 0 ]]; then
debug "failed to pull from public.ecr.aws"
$CONTAINER_ORCHESTRATOR pull "${images[1]}" >> "$LOG_FILE" 2>&1
image_pulled=$?
fi
FLUENTBIT_IMAGE="${images[1]}"

return $image_pulled
}

configure_fluentbit() { #{{{
local running
local exists
local image

image="$($CONTAINER_ORCHESTRATOR images -q -f reference="$FLUENTBIT_IMAGE")"
if [[ -z "$image" ]]; then
info "Fluentbit image:" "$FLUENTBIT_IMAGE"
$CONTAINER_ORCHESTRATOR pull "$FLUENTBIT_IMAGE" >> "$LOG_FILE" 2>&1 &
spinner "$!" "Pulling image"
spinner_wait "Configuring fluentbit agent for workflow log collection.."
if ! pull_fluentbit_image; then
err "Failed to pull fluentbit image. Check if public.ecr.aws or *.docker.io is accessible"
exit 1
fi
spinner_msg "Configuring fluentbit agent for workflow log collection.." 0
if [[ "${FLUENTBIT_IMAGE}" == "fluent/fluent-bit:2.2.0" ]]; then
info "WARNING: pulling from docker hub will be deprecated in the future"
fi

spinner_wait "Configuring fluentbit agent for workflow log collection.."
# TODO: Identify --network host use-case
docker_run_command="$CONTAINER_ORCHESTRATOR run -d \
--name fluentbit-agent \
Expand Down