diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6843e998..9ca91ca4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -378,6 +378,18 @@ jobs: registry-password: ${{ secrets.GITHUB_TOKEN }} output-file: image-debian-sbom.spdx + - name: Generate JSON schema from container + timeout-minutes: 1 + # We don't want to fail the release if this fails since it's not critical and can be debugged after the fact if needed + continue-on-error: true + run: | + echo "Generating JSON schema from container image" + docker run --rm -t "${{ env.UBI_IMAGE_NAME }}:${{ env.TAG }}" -J > output/telemetry-forge-ubi-schema.json + docker run --rm -t "${{ env.DISTROLESS_IMAGE_NAME }}:${{ env.TAG }}" -J > output/telemetry-forge-debian-schema.json + # We use the UBI image schema as the main one since it has more metadata and we can link to the distroless one for reference + cp output/telemetry-forge-ubi-schema.json output/telemetry-forge-agent-schema.json + shell: bash + - name: Save image as tarball run: | mkdir -p output diff --git a/.github/workflows/call-test-containers.yaml b/.github/workflows/call-test-containers.yaml index 9aae16c4..95f74bb3 100644 --- a/.github/workflows/call-test-containers.yaml +++ b/.github/workflows/call-test-containers.yaml @@ -86,6 +86,13 @@ jobs: run: curl -sSfL https://github.com/shenwei356/rush/releases/download/v0.7.0/rush_linux_amd64.tar.gz | sudo tar xzf - -C /usr/local/bin shell: bash + - name: Ensure we use the right version during a release + if: startsWith(github.ref, 'refs/tags/v') + run: | + echo "TELEMETRY_FORGE_AGENT_VERSION=${{ inputs.image-tag }}" >> $GITHUB_ENV + echo "FLUENTDO_AGENT_VERSION=${{ inputs.image-tag }}" >> $GITHUB_ENV + shell: bash + - name: Run container integration tests run: ./testing/bats/run-container-integration-tests.sh shell: bash diff --git a/install.sh b/install.sh index 94a2732d..34162f4c 100755 --- a/install.sh +++ b/install.sh @@ -368,12 +368,33 @@ fetch_available_versions() { log_debug "Fetching page $page_count" fi - local versions_response - versions_response=$(curl -s -L "$url" 2>/dev/null || echo "") + local versions_response="" + local fetch_attempts=0 + local max_fetch_attempts=5 + local fetch_delay=10 + + while [ $fetch_attempts -lt $max_fetch_attempts ]; do + fetch_attempts=$((fetch_attempts + 1)) + versions_response=$(curl --max-time 60 -s -L "$url" 2>/dev/null || echo "") + + if [ -z "$versions_response" ]; then + log_debug "curl returned empty response (attempt $fetch_attempts/$max_fetch_attempts)" + elif echo "$versions_response" | grep -qi "just a moment"; then + # Cloudflare or similar CDN challenge page indicating not ready yet + log_debug "Received loading/challenge page (attempt $fetch_attempts/$max_fetch_attempts)" + versions_response="" + else + break + fi + + if [ $fetch_attempts -lt $max_fetch_attempts ]; then + log_warning "Server not ready, retrying in ${fetch_delay}s (attempt $fetch_attempts/$max_fetch_attempts)..." + sleep "$fetch_delay" + fi + done if [ -z "$versions_response" ]; then - log_error "Failed to fetch versions from $url" - log_debug "curl returned empty response" + log_error "Failed to fetch versions from $url after $max_fetch_attempts attempts" return 1 fi diff --git a/testing/bats/run-package-functional-tests.sh b/testing/bats/run-package-functional-tests.sh index 8c6dbfd6..495e5ef0 100755 --- a/testing/bats/run-package-functional-tests.sh +++ b/testing/bats/run-package-functional-tests.sh @@ -78,6 +78,8 @@ echo "INFO: running test container 'bats/test/$DISTRO'" -v "$DOWNLOAD_DIR:/downloads:ro" \ -e FLUENT_BIT_BINARY="$FLUENT_BIT_BINARY" \ -e TELEMETRY_FORGE_AGENT_PACKAGE_INSTALLED=true \ + -e TELEMETRY_FORGE_AGENT_VERSION="$TELEMETRY_FORGE_AGENT_VERSION" \ + -e TELEMETRY_FORGE_AGENT_URL="$TELEMETRY_FORGE_AGENT_URL" \ "bats/test/$DISTRO" echo "INFO: All tests complete" diff --git a/testing/bats/tests/functional/common/simple.bats b/testing/bats/tests/functional/common/simple.bats index 3a748d0c..676c906a 100644 --- a/testing/bats/tests/functional/common/simple.bats +++ b/testing/bats/tests/functional/common/simple.bats @@ -24,13 +24,13 @@ function teardown() { [[ "$TELEMETRY_FORGE_AGENT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] } -@test "verify version" { +@test "verify reporting $TELEMETRY_FORGE_AGENT_VERSION version" { run "$FLUENT_BIT_BINARY" --version [ "$status" -eq 0 ] [[ "$output" =~ Telemetry\ Forge\ Agent\ v$TELEMETRY_FORGE_AGENT_VERSION ]] } -@test "verify help" { +@test "verify help works for $FLUENT_BIT_BINARY" { run "$FLUENT_BIT_BINARY" --help [ "$status" -eq 0 ] } diff --git a/testing/bats/tests/integration/linux/integration-install-script.bats b/testing/bats/tests/integration/linux/integration-install-script.bats index f16fd393..4c033127 100644 --- a/testing/bats/tests/integration/linux/integration-install-script.bats +++ b/testing/bats/tests/integration/linux/integration-install-script.bats @@ -35,7 +35,7 @@ setupFile() { # Test that we can fetch the top-level index @test "integration: can access index at $TELEMETRY_FORGE_AGENT_URL/index.html" { - response=$(curl -s -o /dev/null -w "%{http_code}" "$TELEMETRY_FORGE_AGENT_URL/index.html") + response=$(curl --max-time 60 -s -o /dev/null -w "%{http_code}" "$TELEMETRY_FORGE_AGENT_URL/index.html") [ "$response" = "200" ] } diff --git a/testing/bats/tests/integration/linux/integration-install-targets.bats b/testing/bats/tests/integration/linux/integration-install-targets.bats index ceb20d20..da7bc277 100644 --- a/testing/bats/tests/integration/linux/integration-install-targets.bats +++ b/testing/bats/tests/integration/linux/integration-install-targets.bats @@ -44,7 +44,7 @@ setupFile() { local install_script="${repo_root}/install.sh" assert_file_exist "$install_script" run ${CONTAINER_RUNTIME:-docker} run --rm -t -v "${install_script}:/install.sh:ro" \ - almalinux:9 /bin/sh -c 'yum install -y epel-release && \ + almalinux:9 /bin/sh -c 'yum install -yq epel-release && \ /install.sh --debug' assert_success assert_output --partial 'Telemetry Forge Agent installation completed successfully!' @@ -56,7 +56,7 @@ setupFile() { local install_script="${repo_root}/install.sh" assert_file_exist "$install_script" run ${CONTAINER_RUNTIME:-docker} run --rm -t -v "${install_script}:/install.sh:ro" \ - almalinux:10 /bin/sh -c 'yum install -y epel-release && \ + almalinux:10 /bin/sh -c 'yum install -yq epel-release && \ /install.sh --debug' assert_success assert_output --partial 'Telemetry Forge Agent installation completed successfully!' @@ -68,7 +68,7 @@ setupFile() { local install_script="${repo_root}/install.sh" assert_file_exist "$install_script" run ${CONTAINER_RUNTIME:-docker} run --rm -t -v "${install_script}:/install.sh:ro" \ - ubuntu:22.04 /bin/sh -c 'apt-get update && apt-get install -y curl && /install.sh --debug' + ubuntu:22.04 /bin/sh -c 'apt-get update -qq && apt-get install -qqy curl && /install.sh --debug' assert_success assert_output --partial 'Telemetry Forge Agent installation completed successfully!' refute_output --partial '[ERROR]' @@ -79,7 +79,7 @@ setupFile() { local install_script="${repo_root}/install.sh" assert_file_exist "$install_script" run ${CONTAINER_RUNTIME:-docker} run --rm -t -v "${install_script}:/install.sh:ro" \ - ubuntu:24.04 /bin/sh -c 'apt-get update && apt-get install -y curl && /install.sh --debug' + ubuntu:24.04 /bin/sh -c 'apt-get update -qq && apt-get install -qqy curl && /install.sh --debug' assert_success assert_output --partial 'Telemetry Forge Agent installation completed successfully!' refute_output --partial '[ERROR]' @@ -90,7 +90,7 @@ setupFile() { local install_script="${repo_root}/install.sh" assert_file_exist "$install_script" run ${CONTAINER_RUNTIME:-docker} run --rm -t -v "${install_script}:/install.sh:ro" \ - debian:bookworm /bin/sh -c 'apt-get update && apt-get install -y curl && /install.sh --debug' + debian:bookworm /bin/sh -c 'apt-get update -qq && apt-get install -qqy curl && /install.sh --debug' assert_success assert_output --partial 'Telemetry Forge Agent installation completed successfully!' refute_output --partial '[ERROR]' @@ -101,7 +101,7 @@ setupFile() { local install_script="${repo_root}/install.sh" assert_file_exist "$install_script" run ${CONTAINER_RUNTIME:-docker} run --rm -t -v "${install_script}:/install.sh:ro" \ - debian:trixie /bin/sh -c 'apt-get update && apt-get install -y curl && /install.sh --debug' + debian:trixie /bin/sh -c 'apt-get update -qq && apt-get install -qqy curl && /install.sh --debug' assert_success assert_output --partial 'Telemetry Forge Agent installation completed successfully!' refute_output --partial '[ERROR]'