Skip to content
Draft
Show file tree
Hide file tree
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
12 changes: 7 additions & 5 deletions Dockerfile.ubi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi9:9.7 AS base-builder
FROM registry.access.redhat.com/ubi10:10.1 AS base-builder

# hadolint ignore=DL3041
RUN dnf update -y && \
Expand Down Expand Up @@ -95,6 +95,7 @@ RUN cmake -DCMAKE_BUILD_TYPE=Release \
-DFLUENTDO_AGENT_VERSION="$FLUENTDO_AGENT_VERSION" \
-DFLB_LOG_NO_CONTROL_CHARS=On \
-DFLB_CORO_STACK_SIZE=131072 \
-DFLB_PREFER_SYSTEM_LIB_ZSTD=On \
${CMAKE_EXTRA_ARGS} \
..

Expand All @@ -108,10 +109,10 @@ RUN [ -n "$MAKE_EXTRA_ARGS" ] && make ${MAKE_EXTRA_ARGS} || make -j "$(getconf _
install bin/fluent-bit /fluent-bit/bin/fluent-bit

# The release image now
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.7 AS production
FROM registry.access.redhat.com/ubi10/ubi-minimal:10.1 AS production

# hadolint ignore=DL3041
RUN microdnf update -y && microdnf install -y openssl libyaml cyrus-sasl && microdnf clean all
RUN microdnf update -y && microdnf install -y openssl libyaml cyrus-sasl zstd && microdnf clean all

EXPOSE 2020

Expand All @@ -125,8 +126,9 @@ COPY README.md /help.1
COPY --from=builder /fluent-bit /fluent-bit

# Copy libgit2 and libssh2 runtime libraries from builder
COPY --from=builder /usr/local/lib64/libgit2.so* /usr/local/lib64/
COPY --from=builder /usr/local/lib/libssh2.so* /usr/local/lib/
COPY --from=builder /usr/local/lib64/libgit2.so.*.*.* /usr/local/lib64/
COPY --from=builder /usr/local/lib/libssh2.so.*.*.* /usr/local/lib/
# Set up ldconfig and symlinks for the libraries
RUN echo "/usr/local/lib64" > /etc/ld.so.conf.d/local-libs.conf && \
echo "/usr/local/lib" >> /etc/ld.so.conf.d/local-libs.conf && \
ldconfig
Expand Down
20 changes: 20 additions & 0 deletions build-and-test-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -euo pipefail

# Simple script to build and test the agent image in a KIND cluster

SOURCE=${BASH_SOURCE[0]}
while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
SCRIPT_DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
SOURCE=$(readlink "$SOURCE")
# if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
[[ $SOURCE != /* ]] && SOURCE=$SCRIPT_DIR/$SOURCE
done
SCRIPT_DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )

# Set this to /ubi to build UBI image, otherwise Debian image is built
export FLUENTDO_AGENT_IMAGE=${FLUENTDO_AGENT_IMAGE:-ghcr.io/fluentdo/agent/ubi}
# Set this to `local` to build and use a local image
export FLUENTDO_AGENT_TAG=${FLUENTDO_AGENT_TAG:-local}

"$SCRIPT_DIR"/testing/bats/run-k8s-integration-tests.sh
File renamed without changes.
38 changes: 29 additions & 9 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ fi
# Any additional options to pass to the package manager
INSTALL_ADDITIONAL_PARAMETERS=${INSTALL_ADDITIONAL_PARAMETERS:-}

# Override package manager and format (detected automatically otherwise)
PKG_MANAGER=${PKG_MANAGER:-}
PKG_FORMAT=${PKG_FORMAT:-}

# ============================================================================
# Prerequisites Check
# ============================================================================
Expand Down Expand Up @@ -289,34 +293,50 @@ detect_distro() {
esac

log_debug "Mapping DISTRO_ID=$DISTRO_ID to package format"
local detected_pkg_manager=""
local detected_pkg_format=""
case "$DISTRO_ID" in
ubuntu|debian)
PKG_MANAGER="apt-get"
PKG_FORMAT="deb"
detected_pkg_manager="apt-get"
detected_pkg_format="deb"
log_debug "Mapped to: PKG_MANAGER=apt-get, PKG_FORMAT=deb"
;;
fedora|rhel|centos|rocky|almalinux|amazonlinux)
PKG_MANAGER="yum"
PKG_FORMAT="rpm"
detected_pkg_manager="yum"
detected_pkg_format="rpm"
log_debug "Mapped to: PKG_MANAGER=yum, PKG_FORMAT=rpm"
;;
opensuse-leap|suse|sles|opensuse)
PKG_MANAGER="zypper"
PKG_FORMAT="rpm"
detected_pkg_manager="zypper"
detected_pkg_format="rpm"
log_debug "Mapped to: PKG_MANAGER=zypper, PKG_FORMAT=rpm"
;;
alpine)
PKG_MANAGER="apk"
PKG_FORMAT="apk"
detected_pkg_manager="apk"
detected_pkg_format="apk"
log_debug "Mapped to: PKG_MANAGER=apk, PKG_FORMAT=apk"
;;
*)
log_warning "Unsupported distribution: $DISTRO_ID"
log_debug "No mapping found for DISTRO_ID=$DISTRO_ID, using generic format"
PKG_FORMAT="generic"
detected_pkg_format="generic"
;;
esac

if [[ -n "${PKG_MANAGER:-}" ]]; then
log_debug "Using overridden package manager: $PKG_MANAGER"
else
PKG_MANAGER="$detected_pkg_manager"
log_debug "Using detected package manager: $PKG_MANAGER"
fi

if [[ -n "${PKG_FORMAT:-}" ]]; then
log_debug "Using overridden package format: $PKG_FORMAT"
else
PKG_FORMAT="$detected_pkg_format"
log_debug "Using detected package format: $PKG_FORMAT"
fi

log_success "Detected distribution: $DISTRO_ID $DISTRO_VERSION (format: $PKG_FORMAT)"
}

Expand Down
25 changes: 19 additions & 6 deletions testing/bats/run-k8s-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
[[ $SOURCE != /* ]] && SOURCE=$SCRIPT_DIR/$SOURCE
done
SCRIPT_DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
REPO_ROOT=${REPO_ROOT:-"$SCRIPT_DIR/../.."}

# Set up KIND and load the image then run tests
# Set up KIND and build/load the image then run tests

# Allow overriding container runtime, default to docker
export CONTAINER_RUNTIME=${CONTAINER_RUNTIME:-docker}

export FLUENTDO_AGENT_IMAGE=${FLUENTDO_AGENT_IMAGE:-ghcr.io/fluentdo/agent/ubi}
# Set this to `local` to build and use a local image
export FLUENTDO_AGENT_TAG=${FLUENTDO_AGENT_TAG:-main}
export CONTAINER_RUNTIME=${CONTAINER_RUNTIME:-docker}

CONTAINER_IMAGE="${FLUENTDO_AGENT_IMAGE}:${FLUENTDO_AGENT_TAG}"
KIND_CLUSTER_NAME=${KIND_CLUSTER_NAME:-kind}
Expand All @@ -28,12 +32,21 @@ echo "INFO: Using container image: $CONTAINER_IMAGE"
echo "INFO: Using KIND cluster name: $KIND_CLUSTER_NAME"
echo "INFO: Using KIND node image: $KIND_NODE_IMAGE"

# Always pull the latest image
if ! "$CONTAINER_RUNTIME" pull "$CONTAINER_IMAGE"; then
echo "ERROR: Image does not exist"
# Always attempt to pull the latest image unless we are using a local image
if [[ "$FLUENTDO_AGENT_TAG" == "local" ]]; then
# Build the local image if needed, assume if FLUENTDO_AGENT_IMAGE ends in "ubi" we build the Dockerfile.ubi
if [[ "$FLUENTDO_AGENT_IMAGE" == *"ubi" ]]; then
echo "INFO: Building local UBI image"
"$CONTAINER_RUNTIME" build -t "$CONTAINER_IMAGE" -f "$REPO_ROOT"/Dockerfile.ubi "$REPO_ROOT"
else
echo "INFO: Building local Debian image"
"$CONTAINER_RUNTIME" build -t "$CONTAINER_IMAGE" -f "$REPO_ROOT"/Dockerfile.debian "$REPO_ROOT"
fi
elif ! "$CONTAINER_RUNTIME" pull "$CONTAINER_IMAGE"; then
echo "ERROR: Remote image does not exist"
exit 1
else
echo "INFO: Image exists"
echo "INFO: Remote image exists and latest version pulled"
fi

if ! command -v bats &> /dev/null ; then
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bats
load "$HELPERS_ROOT/test-helpers.bash"

ensure_variables_set BATS_SUPPORT_ROOT BATS_ASSERT_ROOT BATS_FILE_ROOT FLUENTDO_AGENT_VERSION

load "$BATS_SUPPORT_ROOT/load.bash"
load "$BATS_ASSERT_ROOT/load.bash"
load "$BATS_FILE_ROOT/load.bash"

CONTAINER_RUNTIME=${CONTAINER_RUNTIME:-docker}

# bats file_tags=integration,containers

setup() {
skipIfNotContainer
}

@test "integration: verify we can run systemd input plugin with no issues" {
local journal_dir="/var/log/journal"
if [[ ! -d "$journal_dir" ]]; then
skip "Systemd journal directory does not exist, skipping test"
fi

# Ensure we do not trigger a segfault or errors when running the systemd input plugin
run "$CONTAINER_RUNTIME" run --rm -t \
--user=0 \
-v "$journal_dir":"$journal_dir":ro \
"${FLUENTDO_AGENT_IMAGE}:${FLUENTDO_AGENT_TAG}" \
-v -i systemd --prop="path=$journal_dir" -o stdout -o exit --prop="time_count=10"
assert_success
refute_output --partial "SIGSEGV"
refute_output --partial "[error]"
refute_output --partial "[warn]"
}
Loading