diff --git a/.github/workflows/update_chart_dependencies.yaml b/.github/workflows/update_chart_dependencies.yaml index 2dfb8a6bec..fb0b273f29 100644 --- a/.github/workflows/update_chart_dependencies.yaml +++ b/.github/workflows/update_chart_dependencies.yaml @@ -5,8 +5,9 @@ name: Check for new chart dependency updates # Specifically, it: # 1. Checks for new versions of (subchart) dependencies listed in chart.yaml. # 2. Updates chart.yaml with new versions where applicable. -# 3. If the 'opentelemetry-operator' subchart is updated in chart.yaml, it also updates related -# image tags in values.yaml. +# 3. Updates related values.yaml defaults when a subchart version bump requires it. +# 4. If the 'opentelemetry-operator' subchart is updated in chart.yaml, it also updates related +# image tags in values.yaml and CRD assets when needed. on: schedule: @@ -35,6 +36,10 @@ jobs: component: 'operator' yaml_file_path: 'helm-charts/splunk-otel-collector/Chart.yaml' dependency_name: 'opentelemetry-operator' + - name: 'obi' + component: 'chart' + yaml_file_path: 'helm-charts/splunk-otel-collector/Chart.yaml' + dependency_name: 'opentelemetry-ebpf-instrumentation' env: DEBUG_MODE: ${{ github.event.inputs.DEBUG_MODE }} steps: @@ -59,6 +64,7 @@ jobs: make update-operator-crds DEBUG_MODE="$DEBUG_MODE" - name: Install Skopeo + if: ${{ matrix.name == 'operator' }} run: | sudo apt-get update sudo apt-get install -y skopeo diff --git a/ci_scripts/update-chart-dependency.sh b/ci_scripts/update-chart-dependency.sh index 4b6626de29..08d012b085 100755 --- a/ci_scripts/update-chart-dependency.sh +++ b/ci_scripts/update-chart-dependency.sh @@ -38,6 +38,66 @@ update_operator_images() { $SCRIPT_DIR/update-images-operator-otel.sh } +# Function: update_obi_image_tag +# Description: Keeps the parent chart's default OBI image tag aligned with the subchart version. +update_obi_image_tag() { + local values_file="$VALUES_FILE_PATH" + local normalized_ver="${LATEST_VER#v}" # Strip leading 'v' if present + local target_tag="v$normalized_ver" + local current_tag + + current_tag=$(yq eval '.obi.image.tag' "$values_file") + echo "Current OBI image tag in values.yaml is $current_tag" + + if [ "$current_tag" != "$target_tag" ]; then + echo "Updating OBI image tag to $target_tag in values.yaml" + if ( + updated_file=$(mktemp "${values_file}.XXXXXX") + trap 'if [ -n "$updated_file" ] && [ -f "$updated_file" ]; then rm -f "$updated_file"; fi' EXIT + + if awk -v target_tag="$target_tag" ' + BEGIN { + in_obi=0 + in_image=0 + updated=0 + image_indent="" + } + /^obi:/ { in_obi=1 } + in_obi && /^[^[:space:]][^:]*:/ && !/^obi:/ { in_obi=0; in_image=0 } + in_obi && match($0, /^[[:space:]]+image:/) { + in_image=1 + image_indent=substr($0, RSTART, RLENGTH - length("image:")) + } + in_image && $0 ~ ("^" image_indent "[^[:space:]][^:]*:") && $0 !~ ("^" image_indent "image:") { in_image=0 } + in_image && $0 ~ ("^" image_indent "[[:space:]]+tag: ") { + print image_indent " tag: \"" target_tag "\"" + updated=1 + in_image=0 + next + } + { print } + END { + if (!updated) { + exit 1 + } + } + ' "$values_file" > "$updated_file"; then + mv "$updated_file" "$values_file" + updated_file="" + else + echo "Error: Failed to update obi.image.tag in $values_file; expected to find obi.image.tag and rewrite it to $target_tag." >&2 + exit 1 + fi + ); then + : + else + return 1 + fi + else + echo "OBI image tag is already up to date in values.yaml" + fi +} + # Function: maybe_update_chart_dependency_version # Description: Updates the chart dependency version if a newer version is available. maybe_update_chart_dependency_version() { @@ -61,6 +121,8 @@ maybe_update_chart_dependency_version() { if [ "$SUBCHART_NAME" == "opentelemetry-operator" ]; then update_operator_images + elif [ "$SUBCHART_NAME" == "opentelemetry-ebpf-instrumentation" ]; then + update_obi_image_tag fi emit_output "NEED_UPDATE"