diff --git a/.github/workflows/update_chart_dependencies.yaml b/.github/workflows/update_chart_dependencies.yaml index e08df5f83..4e91fbe82 100644 --- a/.github/workflows/update_chart_dependencies.yaml +++ b/.github/workflows/update_chart_dependencies.yaml @@ -47,6 +47,11 @@ jobs: make update-chart-dep CHART_PATH=${{ matrix.yaml_file_path }} SUBCHART_NAME='${{ matrix.dependency_name }}' DEBUG_MODE=$DEBUG_MODE + - name: Install Skopeo + run: | + sudo apt-get update + sudo apt-get install -y skopeo + - name: Open PR for Version Update id: open_pr if: ${{ steps.check_for_update.outputs.NEED_UPDATE == 1 }} diff --git a/ci_scripts/install-tools.sh b/ci_scripts/install-tools.sh index 0b6cbd07b..5bd0c07b1 100755 --- a/ci_scripts/install-tools.sh +++ b/ci_scripts/install-tools.sh @@ -98,7 +98,7 @@ install_helm_plugin() { } # install brew-based tools -for tool in kubectl helm chart-testing pre-commit go; do +for tool in chart-testing go helm kubectl pre-commit skopeo; do install "$tool" brew done diff --git a/ci_scripts/update-images-operator-otel.sh b/ci_scripts/update-images-operator-otel.sh index 00cc08afc..4d36154d1 100755 --- a/ci_scripts/update-images-operator-otel.sh +++ b/ci_scripts/update-images-operator-otel.sh @@ -14,9 +14,11 @@ source "$SCRIPT_DIR/base_util.sh" # ---- Initialize Temporary Files ---- # Create a temporary file to hold a subsection of the values.yaml file -setd "TEMP_VALUES_FILE" "$SCRIPT_DIR/temp_values_subsection.yaml" -# Create a temporary file to store version information -setd "TEMP_VERSIONS" "$SCRIPT_DIR/versions.txt" +setd "TEMP_VALUES_FILE" "$SCRIPT_DIR/temp_values_subsection.out" +# Create a temporary file to store operator main.go code containing docker image repository information +setd "TEMP_MAIN_FILE" "$SCRIPT_DIR/temp_main.out" +# Create a temporary file to store docker image version information +setd "TEMP_VERSIONS" "$SCRIPT_DIR/temp_versions.out" # ---- Operator Subchart Version Extraction ---- # Extract the version of the opentelemetry-operator subchart from the main Chart.yaml @@ -32,6 +34,14 @@ debug "Fetching: $SUBCHART_URL" APP_VERSION=$(curl -s "$SUBCHART_URL" | grep 'appVersion:' | awk '{print $2}') debug "Operator App Version: $APP_VERSION" +# ---- Fetch Docker Repository Information ---- +# Fetch the code containing information about what instrumentation language uses what docker repository. +MAIN_URL="https://raw.githubusercontent.com/open-telemetry/opentelemetry-operator/v$APP_VERSION/main.go" +debug "Fetching: $MAIN_URL" +curl -s "$MAIN_URL" > "$TEMP_MAIN_FILE" +debug "Extracted main.go of the operator:" +debug "$TEMP_MAIN_FILE" + # ---- Fetch Version Mapping ---- # Fetch the version mappings from versions.txt for the fetched appVersion. # This gives us a mapping of image keys to their corresponding version tags. @@ -51,9 +61,19 @@ while IFS='=' read -r IMAGE_KEY VERSION; do if [[ "$IMAGE_KEY" =~ ^autoinstrumentation-.* ]]; then # Upstream Operator Values setd "INST_LIB_NAME" "${IMAGE_KEY#autoinstrumentation-}" - setd "REPOSITORY_UPSTREAM" "ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-${INST_LIB_NAME}" setd "TAG_UPSTREAM" "${VERSION}" + # Find the proper docker repository for the instrumentation library by scraping the main.go file of the operator + INST_LIB_REPO=$(grep "auto-instrumentation-${INST_LIB_NAME}-image" "$TEMP_MAIN_FILE" | grep -o 'ghcr.io/[a-zA-Z0-9_-]*/[a-zA-Z0-9_-]*/autoinstrumentation-[a-zA-Z0-9_-]*' | sort | uniq ) + if [ -n "$INST_LIB_REPO" ]; then + # Set the REPOSITORY_UPSTREAM variable + setd "REPOSITORY_UPSTREAM" "$INST_LIB_REPO" + debug "Set REPOSITORY_UPSTREAM to ${INST_LIB_REPO}" + else + echo "Failed to find repository for ${INST_LIB_NAME}" + exit 1 + fi + setd "REPOSITORY_LOCAL_PATH" "${INST_LIB_NAME}.repository" setd "REPOSITORY_LOCAL" "$(yq eval ".${REPOSITORY_LOCAL_PATH}" "${TEMP_VALUES_FILE}")" @@ -63,9 +83,17 @@ while IFS='=' read -r IMAGE_KEY VERSION; do setd "TAG_LOCAL_PATH" "${INST_LIB_NAME}.tag" setd "TAG_LOCAL" "$(yq eval ".${TAG_LOCAL_PATH}" "${TEMP_VALUES_FILE}")" if [[ -z "${TAG_LOCAL}" || "${TAG_LOCAL}" == "null" || "${TAG_LOCAL}" != "$TAG_UPSTREAM" ]]; then - debug "Upserting value for ${REPOSITORY_LOCAL}:${TAG_LOCAL}" - yq eval -i ".${TAG_LOCAL_PATH} = \"${TAG_UPSTREAM}\"" "${TEMP_VALUES_FILE}" - setd "NEED_UPDATE" 1 + IMAGE="${REPOSITORY_UPSTREAM}:${TAG_UPSTREAM}" + # Skopeo validates the existence of the Docker images no matter the current host architecture used + if skopeo inspect --retry-times 3 --raw "docker://$IMAGE" &>/dev/null; then + echo "Image $IMAGE exists." + echo "Upserting value for ${REPOSITORY_LOCAL}:${TAG_UPSTREAM}" + yq eval -i ".${TAG_LOCAL_PATH} = \"${TAG_UPSTREAM}\"" "${TEMP_VALUES_FILE}" + setd "NEED_UPDATE" 1 + else + echo "Failed to find Docker image $IMAGE. Check image repository and tag." + exit 1 + fi else debug "Retaining existing value for ${REPOSITORY_LOCAL}:${TAG_LOCAL}" fi @@ -91,8 +119,7 @@ awk ' # Replace the original values.yaml with the updated version mv "${VALUES_FILE_PATH}.updated" "$VALUES_FILE_PATH" # Cleanup temporary files -rm "$TEMP_VALUES_FILE" -rm "$TEMP_VERSIONS" +rm "$TEMP_MAIN_FILE" "$TEMP_VERSIONS" "$TEMP_VALUES_FILE" echo "Image update process completed successfully!" exit 0 diff --git a/examples/enable-operator-and-auto-instrumentation/rendered_manifests/operator/instrumentation.yaml b/examples/enable-operator-and-auto-instrumentation/rendered_manifests/operator/instrumentation.yaml index 0b51fbfa8..733477552 100644 --- a/examples/enable-operator-and-auto-instrumentation/rendered_manifests/operator/instrumentation.yaml +++ b/examples/enable-operator-and-auto-instrumentation/rendered_manifests/operator/instrumentation.yaml @@ -62,10 +62,10 @@ spec: - name: OTEL_RESOURCE_ATTRIBUTES value: splunk.zc.method=splunk-otel-java:v1.31.0 nginx: - image: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-nginx:1.0.4 + image: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-apache-httpd:1.0.4 env: - name: OTEL_RESOURCE_ATTRIBUTES - value: splunk.zc.method=autoinstrumentation-nginx:1.0.4 + value: splunk.zc.method=autoinstrumentation-apache-httpd:1.0.4 nodejs: image: ghcr.io/signalfx/splunk-otel-js/splunk-otel-js:v2.7.1 env: diff --git a/helm-charts/splunk-otel-collector/values.yaml b/helm-charts/splunk-otel-collector/values.yaml index 03e517d43..3b1f729ab 100644 --- a/helm-charts/splunk-otel-collector/values.yaml +++ b/helm-charts/splunk-otel-collector/values.yaml @@ -1216,7 +1216,7 @@ operator: repository: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-python tag: 0.44b0 nginx: - repository: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-nginx + repository: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-apache-httpd tag: 1.0.4 # Auto-instrumentation Libraries (End) admissionWebhooks: