diff --git a/.chloggen/TEMPLATE.yaml b/.chloggen/TEMPLATE.yaml index 838782a0b4..75ca0c9231 100644 --- a/.chloggen/TEMPLATE.yaml +++ b/.chloggen/TEMPLATE.yaml @@ -1,15 +1,11 @@ # One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' change_type: - # The name of the component, or a single word describing the area of concern, (e.g. agent, cluster reciever, gateway, network explorer, operator, chart, other) component: - # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). note: - # One or more tracking issues related to the change issues: [] - # (Optional) One or more lines of additional information to render under the primary note. # These lines will be padded with 2 spaces and then inserted directly into the document. # Use pipe (|) for multiline entries. diff --git a/.chloggen/add-chloggen.yaml b/.chloggen/add-chloggen.yaml deleted file mode 100644 index c6c7be7c0d..0000000000 --- a/.chloggen/add-chloggen.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: enhancement - -# The name of the component, or a single word describing the area of concern, (e.g. agent, cluster reciever, gateway, network explorer, operator, chart, other) -component: chart - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Add support for OpenTelemetry CHANGELOG.md generator tool, see [chloggen](https://github.com/open-telemetry/opentelemetry-operator/tree/main/.chloggen) - -# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. -issues: [923] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: diff --git a/.chloggen/add-chloggen2.yaml b/.chloggen/add-chloggen2.yaml deleted file mode 100644 index 20bd39e4b2..0000000000 --- a/.chloggen/add-chloggen2.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: enhancement - -# The name of the component, or a single word describing the area of concern, (e.g. agent, cluster reciever, gateway, network explorer, operator, chart, other) -component: chart - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Add support for OpenTelemetry CHANGELOG.md generator tool, see [chloggen](https://github.com/open-telemetry/opentelemetry-operator/tree/main/.chloggen) - -# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. -issues: [923,924] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: diff --git a/.chloggen/add-chloggen3.yaml b/.chloggen/add-chloggen3.yaml deleted file mode 100644 index 2be957136b..0000000000 --- a/.chloggen/add-chloggen3.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' -change_type: enhancement - -# The name of the component, or a single word describing the area of concern, (e.g. agent, cluster reciever, gateway, network explorer, operator, chart, other) -component: chart - -# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: Add support for OpenTelemetry CHANGELOG.md generator tool, see [chloggen](https://github.com/open-telemetry/opentelemetry-operator/tree/main/.chloggen) - -# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. -issues: [923,924,925] - -# (Optional) One or more lines of additional information to render under the primary note. -# These lines will be padded with 2 spaces and then inserted directly into the document. -# Use pipe (|) for multiline entries. -subtext: diff --git a/.github/workflows/update_chart_dependencies.yaml b/.github/workflows/update_chart_dependencies.yaml index 8e273dcfc2..8bc5c25980 100644 --- a/.github/workflows/update_chart_dependencies.yaml +++ b/.github/workflows/update_chart_dependencies.yaml @@ -2,8 +2,8 @@ name: Check for new chart dependency updates on: schedule: - # Run every Monday at noon. - - cron: "0 12 * * 1" + # Run every 12 hrs on the 11th hour at 30 minutes past. + - cron: '30 11 */12 * *' workflow_dispatch: env: @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - # Currently this worfklow will update the listed dependencies in the Chart.yaml + # Currently, this workflow will update the listed dependencies in the Chart.yaml repo: ['cert-manager', 'opentelemetry-operator'] # Add other repos here steps: - uses: actions/checkout@v4 @@ -25,13 +25,14 @@ jobs: make repo-update # Fetch the latest version using helm search repo - LATEST_VER=$(helm search repo ${{ matrix.repo }} --versions | awk 'NR==2{print $2}') - echo "LATEST_VER=$LATEST_VER" >> $GITHUB_OUTPUT + LATEST_VERSION=$(helm search repo ${{ matrix.repo }} --versions | awk 'NR==2{print $2}') + echo "LATEST_VERSION=$LATEST_VERSION" >> GITHUB_OUTPUT # Retrieve the current version from chart.yaml - DEP_PATH=$(yq eval ".dependencies[] | select(.name == \"${{ matrix.repo }}\") | .version" $CHART_YAML) + CURRENT_VERSION=$(yq eval ".dependencies[] | select(.name == \"${{ matrix.repo }}\") | .version" ${{ env.CHART_YAML }}) + echo "CURRENT_VERSION=$CURRENT_VERSION" >> GITHUB_OUTPUT - echo "Current version of ${{ matrix.repo }} is $DEP_PATH, latest is $LATEST_VER" + echo "Current version of ${{ matrix.repo }} is $CURRENT_VERSION, latest is $LATEST_VERSION" if [ "$LATEST_VER" == "$DEP_PATH" ]; then echo We are already up to date. Nothing else to do. @@ -49,15 +50,36 @@ jobs: echo "Current git diff:" git --no-pager diff - fi - - name: PR the new version + - name: + id: create_pr if: ${{ steps.update_chart.outputs.NEED_UPDATE == 1 }} uses: peter-evans/create-pull-request@v5 with: - commit-message: Update ${{ matrix.repo }} chart version - title: Update ${{ matrix.repo }} chart version to ${{ steps.update_chart.outputs.LATEST_VER }} - body: Use the new version of the ${{ matrix.repo }} chart - branch: "update-${{ matrix.repo }}-${{ steps.update_chart.outputs.LATEST_VER }}" + commit-message: "Bump ${{ matrix.repo }} chart dependency from ${{ steps.update_chart.outputs.CURRENT_VERSION }} to ${{ steps.update_chart.outputs.LATEST_VERSION }}" + title: "Bump ${{ matrix.repo }} chart dependency from ${{ steps.update_chart.outputs.CURRENT_VERSION }} to ${{ steps.update_chart.outputs.LATEST_VERSION }}" + body: "Update to the new version of the ${{ matrix.repo }} chart dependency." + branch: "update-${{ matrix.repo }}" + base: main + delete-branch: true + modify-outputs: false + - name: Create changelog entry + if: ${{ steps.update_chart.outputs.NEED_UPDATE == 1 }} + run: | + # If a previous unreleased changelog entry already exist it is updated. + make chlog-new \ + CHANGE_TYPE=enhancement \ + COMPONENT=${{ matrix.repo }} \ + NOTE="Update ${{ matrix.repo }} chart dependency version from $CURRENT_VERSION to $LATEST_VERSION" \ + ISSUES="[${{ steps.create_pr.outputs.pull-request-number }}]" \ + FILENAME="update-${{ matrix.repo }}-chart" + - name: Update PR with CHANGELOG + if: ${{ steps.update_chart.outputs.NEED_UPDATE == 1 }} + uses: peter-evans/create-pull-request@v5 + with: + commit-message: "Add or update .chloggen/update-${{ matrix.repo }}-chart.yaml" + title: "Bump ${{ matrix.repo }} chart dependency from ${{ steps.update_chart.outputs.CURRENT_VERSION }} to ${{ steps.update_chart.outputs.LATEST_VERSION }}" + body: "Update to the new version of the ${{ matrix.repo }} chart dependency." + branch: "update-${{ matrix.repo }}" base: main delete-branch: true modify-outputs: false diff --git a/.github/workflows/update_instrumentation_dependencies.yaml b/.github/workflows/update_instrumentation_dependencies.yaml index 2adfe589b8..75fcb389d9 100644 --- a/.github/workflows/update_instrumentation_dependencies.yaml +++ b/.github/workflows/update_instrumentation_dependencies.yaml @@ -20,46 +20,68 @@ jobs: steps: - uses: actions/checkout@v4 - name: swizzle version - id: swizzle_version + id: update_instrumentation run: | + git config --global user.name 'GitHub Action' + git config --global user.email 'action@github.com' + REPO=ghcr.io/signalfx/splunk-otel-${{ matrix.language }}/splunk-otel-${{ matrix.language }} - LOCAL_VER=$(grep $REPO $VALUES_YAML | awk -F: '{print $2}' | tr -d ' "') - LATEST_VER=$(curl -qs -H "Accept: application/vnd.github+json" $(echo $LATEST_API | sed "s/{lang}/${{ matrix.language }}/g") | jq -r .tag_name) - echo "LATEST_VER=$LATEST_VER" >> $GITHUB_OUTPUT - echo "Current version of ${{ matrix.language }} is $LOCAL_VER, latest is $LATEST_VER" + CURRENT_VERSION=$(grep $REPO $VALUES_YAML | awk -F: '{print $2}' | tr -d ' "') + LATEST_VERSION=$(curl -qs -H "Accept: application/vnd.github+json" $(echo $LATEST_API | sed "s/{lang}/${{ matrix.language }}/g") | jq -r .tag_name) + echo "Current version of ${{ matrix.language }} is $CURRENT_VERSION, latest is $LATEST_VERSION" - if [ "$LATEST_VER" == "$LOCAL_VER" ]; then + if [ "$CURRENT_VERSION" == "$LATEST_VERSION"]; then echo We are already up to date. Nothing else to do. else + echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_OUTPUT + echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_OUTPUT + echo "NEED_UPDATE=1" >> $GITHUB_OUTPUT + echo 'Verifying that the image is pullable...' echo '(If this fails, the image version is out of sync with ghcr version)' - docker pull $REPO:$LATEST_VER + docker pull $REPO:$LATEST_VERSION echo 'Looks like we are good to update...' echo Updating to new version in values.yaml - echo "NEED_UPDATE=1" >> $GITHUB_OUTPUT VLINE=$(grep -n "${REPO}" $VALUES_YAML | cut -f1 -d:) echo "Line number for ${REPO} in ${VALUES_YAML} is: ${VLINE}" OLD_VER=$(sed -n "${VLINE}p" $VALUES_YAML | grep -oP 'v\K[0-9.]+') echo "Old version number is: ${OLD_VER}" - NEW_VER=${LATEST_VER#v} # removes 'v' from the start of the string - echo "New version number is: ${NEW_VER}" - echo "sed: ${VLINE}s/${OLD_VER}/${NEW_VER}/" - sed -i "${VLINE}s/${OLD_VER}/${NEW_VER}/" $VALUES_YAML + NEW_VERSION=${LATEST_VERSION#v} # removes 'v' from the start of the string + echo "New version number is: ${NEW_VERSION}" + echo "sed: ${VLINE}s/${OLD_VER}/${NEW_VERSION}/" + sed -i "${VLINE}s/${OLD_VER}/${NEW_VERSION}/" $VALUES_YAML - echo Render chart template + echo Updating rendered examples make render echo "Current git diff:" git --no-pager diff fi - - name: PR the new version - if: ${{ steps.swizzle_version.outputs.NEED_UPDATE == 1 }} + - name: + id: create_pr + if: ${{ steps.update_instrumentation.outputs.NEED_UPDATE == 1 }} uses: peter-evans/create-pull-request@v5 with: - commit-message: Update ${{ matrix.language }} instrumentation version - title: Update ${{ matrix.language }} instrumentation version to ${{ steps.swizzle_version.outputs.LATEST_VER }} - body: Use the new version of the ${{ matrix.language }} instrumentation - branch: "update-${{ matrix.language }}-${{ steps.swizzle_version.outputs.LATEST_VER }}" + commit-message: "Bump ${{ matrix.language }} instrumentation dependency from ${{ steps.update_instrumentation.outputs.CURRENT_VERSION }} to ${{ steps.update_instrumentation.outputs.LATEST_VERSION }}" + title: "Bump ${{ matrix.language }} instrumentation dependency from ${{ steps.update_instrumentation.outputs.CURRENT_VERSION }} to ${{ steps.update_instrumentation.outputs.LATEST_VERSION }}" + body: "Update to the new version of the ${{ matrix.language }} instrumentation dependency." + branch: "update-${{ matrix.language }}" base: main delete-branch: true modify-outputs: false + - name: Create changelog entry + if: ${{ steps.update_instrumentation.outputs.NEED_UPDATE == 1 }} + run: | + git fetch origin "update-${{ matrix.language }}" + git checkout "update-${{ matrix.language }}" + + make chlog-new \ + CHANGE_TYPE=enhancement \ + COMPONENT=operator \ + NOTE="Update ${{ matrix.language }} instrumentation version from ${{ steps.update_instrumentation.outputs.CURRENT_VERSION == 1 }} to ${{ steps.update_instrumentation.outputs.LATEST_VERSION == 1 }}" \ + ISSUES="[${{ steps.create_pr.outputs.pull-request-number }}]" \ + FILENAME="update-${{ matrix.language }}-instrumentation" + + git add . + git commit -m "Add changelog for updating ${{ matrix.language }} instrumentation" + git push origin "update-${{ matrix.language }}" diff --git a/CHANGELOG.md b/CHANGELOG.md index e334ac9b49..28ceea80db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [0.86.0] + +This Splunk OpenTelemetry Collector for Kubernetes release adopts the [Splunk OpenTelemetry Collector v0.84.0](https://github.com/signalfx/splunk-otel-collector/releases/tag/v0.84.0). + +### 💡 Enhancements 💡 + +- `chart`: Add support for OpenTelemetry CHANGELOG.md generator tool, see [chloggen](https://github.com/open-telemetry/opentelemetry-operator/tree/main/.chloggen) ([#923](https://github.com/signalfx/splunk-otel-collector-chart/pull/923)) +- `chart`: Add support for OpenTelemetry CHANGELOG.md generator tool, see [chloggen](https://github.com/open-telemetry/opentelemetry-operator/tree/main/.chloggen) ([#923](https://github.com/signalfx/splunk-otel-collector-chart/pull/923),[#924](https://github.com/signalfx/splunk-otel-collector-chart/pull/#924)) +- `chart`: Add support for OpenTelemetry CHANGELOG.md generator tool, see [chloggen](https://github.com/open-telemetry/opentelemetry-operator/tree/main/.chloggen) ([#923](https://github.com/signalfx/splunk-otel-collector-chart/pull/923),[#924](https://github.com/signalfx/splunk-otel-collector-chart/pull/#924),[#925](https://github.com/signalfx/splunk-otel-collector-chart/pull/#925)) + ## [0.84.0] - 2023-09-11 ### 💡 Enhancements 💡 @@ -281,7 +291,7 @@ This Splunk OpenTelemetry Collector for Kubernetes release adopts the [Splunk Op ### 🚀 New components 🚀 -- A way to provide a custom image for init container patching host log directories (#534, #535) +- A way to provide a custom image for init container patching host log directories ([#534](https://github.com/signalfx/splunk-otel-collector-chart/pull/534),[#535](https://github.com/signalfx/splunk-otel-collector-chart/pull/#535)) ### 💡 Enhancements 💡 @@ -421,7 +431,7 @@ This Splunk OpenTelemetry Collector for Kubernetes release adopts the [Splunk Op ### 💡 Enhancements 💡 -- Migrate filelog operators to follow opentelemetry-log-collection v0.29.0 changes (#436, #441) +- Migrate filelog operators to follow opentelemetry-log-collection v0.29.0 changes ([#436](https://github.com/signalfx/splunk-otel-collector-chart/pull/436),[#441](https://github.com/signalfx/splunk-otel-collector-chart/pull/#441)) - [BREAKING CHANGE] Several breaking changes were made that affect the filelog, syslog, tcplog, and journald receivers. Any use of the extraFileLogs config, logsCollection.containers.extraOperators config, @@ -481,7 +491,7 @@ This Splunk OpenTelemetry Collector for Kubernetes release adopts the [Splunk Op ### 🧰 Bug fixes 🧰 -- Bug where Prometheus errors out using default configuration on EKS and GKE (#401, #405) +- Bug where Prometheus errors out using default configuration on EKS and GKE ([#401](https://github.com/signalfx/splunk-otel-collector-chart/pull/401),[#405](https://github.com/signalfx/splunk-otel-collector-chart/pull/#405)) ## [0.44.1] - 2022-03-08 @@ -678,7 +688,7 @@ guidelines](https://github.com/signalfx/splunk-otel-collector-chart/blob/main/UP collection gets `container.id` attribute that allows container level correlation in Splunk Observability Cloud closing a feature parity gap with fluentd ([#238](https://github.com/signalfx/splunk-otel-collector-chart/pull/238)) -- Add strict values.yaml schema validation (#227, #234, #239) +- Add strict values.yaml schema validation ([#227](https://github.com/signalfx/splunk-otel-collector-chart/pull/227),[#234](https://github.com/signalfx/splunk-otel-collector-chart/pull/#234),[#239](https://github.com/signalfx/splunk-otel-collector-chart/pull/#239)) ### 💡 Enhancements 💡 @@ -690,8 +700,8 @@ guidelines](https://github.com/signalfx/splunk-otel-collector-chart/blob/main/UP - Change `run_id` log resource attribute to `k8s.container.restart_count` ([#226](https://github.com/signalfx/splunk-otel-collector-chart/pull/226)) - Use only `splunkPlatform.endpoint` and `splunkObservability.realm` parameters to identify which destination is enabled, remove default value for - `splunkObservability.realm` (#230, #233) -- Upgrade splunk-otel-collector image to 0.37.1 (#237, #249) + `splunkObservability.realm` ([#230](https://github.com/signalfx/splunk-otel-collector-chart/pull/230),[#233](https://github.com/signalfx/splunk-otel-collector-chart/pull/#233)) +- Upgrade splunk-otel-collector image to 0.37.1 ([#237](https://github.com/signalfx/splunk-otel-collector-chart/pull/237),[#249](https://github.com/signalfx/splunk-otel-collector-chart/pull/#249)) - Simplify configuration for switching to native OTel logs collection ([#246](https://github.com/signalfx/splunk-otel-collector-chart/pull/246)) ### 🧰 Bug fixes 🧰 diff --git a/Makefile b/Makefile index 16ad2aa66c..f0b5ca7ab1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ ##@ General # The general settings and variables for the project -# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) GOBIN=$(shell go env GOPATH)/bin else @@ -32,13 +31,10 @@ init: install-tools ## Initialize the environment # TODO: Add more execution steps here @echo "Initialization complete." -# install-tools: Set up dev environment -# Installs/Upgrades dev tools via Homebrew. Supports macOS/Linux. Also installs chloggen. -# Use OVERRIDE_OS_CHECK=true to skip OS check. OVERRIDE_OS_CHECK ?= false .PHONY: install-tools -install-tools: ## Install tools (macOS/Linux) - @OVERRIDE_OS_CHECK=$(OVERRIDE_OS_CHECK) LOCALBIN=$(LOCALBIN) ./ci_scripts/install-tools.sh +install-tools: $(LOCALBIN) ## Install tools (macOS/Linux) + @OVERRIDE_OS_CHECK=$(OVERRIDE_OS_CHECK) LOCALBIN=$(LOCALBIN) ./ci_scripts/install-tools.sh || exit 1 ##@ Build # Tasks related to building the Helm chart @@ -47,46 +43,45 @@ install-tools: ## Install tools (macOS/Linux) repo-update: ## Update Helm repositories to latest @{ \ if ! (helm repo list | grep -q open-telemetry) ; then \ - helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts ;\ + helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts || exit 1; \ fi ;\ if ! (helm repo list | grep -q jetstack) ; then \ - helm repo add jetstack https://charts.jetstack.io ;\ + helm repo add jetstack https://charts.jetstack.io || exit 1; \ fi ;\ - helm repo update open-telemetry jetstack ;\ + helm repo update open-telemetry jetstack || exit 1; \ } .PHONY: dep-build dep-build: ## Build the Helm chart with latest dependencies from the current Helm repositories @{ \ - OK=true ;\ - DIR=helm-charts/splunk-otel-collector ;\ - if ! helm dependencies list $$DIR | grep open-telemetry | grep -q ok ; then OK=false ; fi ;\ - if ! helm dependencies list $$DIR | grep jetstack | grep -q ok ; then OK=false ; fi ;\ - if ! $$OK ; then helm dependencies build $$DIR ; fi ;\ + DEP_OK=true ;\ + DIR=helm-charts/splunk-otel-collector ;\ + if ! helm dependencies list $$DIR | grep open-telemetry | grep -q ok ; then DEP_OK=false ; fi ;\ + if ! helm dependencies list $$DIR | grep jetstack | grep -q ok ; then DEP_OK=false ; fi ;\ + if [ "$$DEP_OK" = "false" ] ; then helm dependencies build $$DIR || exit 1; fi ;\ } .PHONY: render render: repo-update dep-build ## Render the Helm chart with the examples as input - bash ./examples/render-examples.sh + bash ./examples/render-examples.sh || exit 1 ##@ Test -# Tasks related to building the Helm chart +# Tasks related to testing the Helm chart .PHONY: lint lint: ## Lint the Helm chart with ct @echo "Linting Helm chart..." - ct lint --config=ct.yaml + ct lint --config=ct.yaml || exit 1 .PHONY: pre-commit pre-commit: ## Test the Helm chart with pre-commit @echo "Checking the Helm chart with pre-commit..." - pre-commit + pre-commit run --all-files || exit 1 ##@ Changelog # Tasks related to changelog management -# See: https://github.com/open-telemetry/opentelemetry-go-build-tools/tree/main/chloggen +CHLOGGEN_NEW_SCRIPT := ./ci_scripts/chloggen-new.sh -FILENAME?=$(shell git branch --show-current) .PHONY: chlog-available chlog-available: ## Validate the chloggen tool is available @if [ -z "$(CHLOGGEN)" ]; then \ @@ -95,28 +90,26 @@ chlog-available: ## Validate the chloggen tool is available fi .PHONY: chlog-new -chlog-new: chlog-available ## Creates a new YAML file under .chloggen to later be inserted into CHANGELOG.md for the next release - $(CHLOGGEN) new --filename $(FILENAME) - echo "Make sure to update the contents of ${FILENAME} with information about your changes." +chlog-new: chlog-available ## Creates or updates a YAML file under .chloggen + # Example Usage: + # make chlog-new + # make chlog-new CHANGE_TYPE=enhancement COMPONENT=agent NOTE="Add feature X" ISSUES='["4242"]' FILENAME=add-feature-x SUBTEXT="Supports Y" + @$(CHLOGGEN_NEW_SCRIPT) || exit 1 .PHONY: chlog-validate chlog-validate: chlog-available ## Validates all YAML files in .chloggen - $(CHLOGGEN) validate + $(CHLOGGEN) validate || exit 1 .PHONY: chlog-preview chlog-preview: chlog-available ## Provide a preview of the generated CHANGELOG.md file for a release - # Note: Issues will not be hyperlinked in the preview but will be when the actual update happens. - $(CHLOGGEN) update --dry + $(CHLOGGEN) update --dry || exit 1 .PHONY: chlog-update -chlog-update: chlog-available ## Updates the CHANGELOG.md file for a release. Example: make chlog-update VERSION=1.2.3 - # Validate the version format +chlog-update: chlog-available ## Creates a release CHANGELOG.md entry from content in .chloggen @if [[ ! "$(VERSION)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$$ ]]; then \ echo "Error: Invalid version. Try running something like 'make chlog-update VERSION=0.85.0'"; \ exit 1; \ fi - # Convert the version to the desired format @FORMATTED_VERSION="[$(VERSION)] - $$(date +'%Y-%m-%d')"; \ - $(CHLOGGEN) update --version $$FORMATTED_VERSION - # Update non-hyperlinked PR IDs in CHANGELOG.md - @./ci_scripts/update_changelog_links.sh + $(CHLOGGEN) update --version $$FORMATTED_VERSION || exit 1 + @./ci_scripts/update_changelog_links.sh || exit 1 diff --git a/ci_scripts/base_util.sh b/ci_scripts/base_util.sh new file mode 100755 index 0000000000..7ee8667294 --- /dev/null +++ b/ci_scripts/base_util.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# Base Utility Functions Library For CI/CD +# This script provides a set of utility functions for debugging, variable setting, +# and common CI/CD operations. It's designed to be sourced by other scripts to +# provide a standardized way of setting variables, debugging, and handling common +# tasks like fetching Helm chart resources. + +# Note: This utility sets "set -e", which will cause any script that sources it +# to exit if any command fails. Make sure your script is compatible with this behavior. +set -e + +# Paths for the Helm chart resources +CHART_FILE_PATH="$SCRIPT_DIR/../helm-charts/splunk-otel-collector/Chart.yaml" +VALUES_FILE_PATH="$SCRIPT_DIR/../helm-charts/splunk-otel-collector/values.yaml" + +# Set default OWNER to "signalfx" if not already set +: "${OWNER:=signalfx}" # Sets OWNER to "signalfx" if it is not already set + +# Debug mode is off by default but can be enabled with --debug +: "${DEBUG_MODE:=0}" # Sets DEBUG_MODE to 0 if it is not already set + +# Iterate over all arguments of the calling script +for arg in "$@"; do + if [[ "$arg" == "--debug" ]]; then + DEBUG_MODE=1 # Enable debug mode + # Remove --debug from arguments + for index in "${!@}"; do + if [[ "${!index}" == "--debug" ]]; then + unset "$index" + break + fi + done + # Re-index the arguments array + set -- "${@}" + fi +done + +# ---- Debug Methods ---- +# These methods provide functions for setting and debugging variables. +# To use this utility, source it in your script as shown in the example below: +# +# Example: +# ```bash +# #!/bin/bash +# # Source the utility script to get access to its functions and variables +# source /path/to/base_util.sh +# +# # Now you can use the utility functions and variables in this script +# DEBUG_MODE=1 # Turn on debug mode +# setd "my_var" "Hello, World!" +# debug "a string value" +# debug "$TEMP_FILE_WITH_CONTENT_PATH" +# ``` + +# Function: setd +# Description: Sets a variable and outputs a debug message. +# Usage: setd "variable_name" "value" +setd() { + eval "$1=\"$2\"" # Set a variable with the given name and value + debug "$1" # Call the debug function to output the variable +} + +# Function: debug +# Description: Outputs debug information based on the DEBUG_MODE setting. +# Supports variables, strings, and file paths for file content. +# Usage: debug "variable_name" +debug() { + if [[ $DEBUG_MODE -eq 1 ]]; then + local var_name="$1" + local var_value="${!var_name}" # Indirect reference to get the value + if [[ -f "$var_value" ]]; then + echo "[DEBUG] $var_name: Content of file $var_value:" + cat "$var_value" + else + echo "[DEBUG] $var_name: $var_value" + fi + fi +} + +# Function: emit_output +# Description: Outputs a given environment variable either to GitHub output or stdout. +# Usage: emit_output "VAR_NAME" +emit_output() { + local var_name="$1" + local var_value="${!var_name}" # Indirect reference to get the value + + if [ -n "$GITHUB_OUTPUT" ]; then + echo "${var_name}=${var_value}" >> "$GITHUB_OUTPUT" + else + echo "${var_name}=${var_value}" + fi +} diff --git a/ci_scripts/chloggen-new.sh b/ci_scripts/chloggen-new.sh new file mode 100755 index 0000000000..378749a07a --- /dev/null +++ b/ci_scripts/chloggen-new.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Description: This script creates or updates a changelog entry using 'make chlog-new`. +# Optional Parameters: CHANGE_TYPE, COMPONENT, NOTE, ISSUES, SUBCONTEXT, FILENAME + +# Validate input if FILENAME is not set +if [[ -z "$FILENAME" ]]; then + FILENAME=$(git branch --show-current | tr -d '[:space:][:punct:]') +fi + +# Check for the existence of TEMPLATE.yaml +if [ ! -f ".chloggen/TEMPLATE.yaml" ]; then + echo "Error: .chloggen/TEMPLATE.yaml not found. Ensure it exists." + exit 1 +fi + +# Check if a changelog entry with the given filename already exists +if [ -f ".chloggen/${FILENAME}.yaml" ]; then + echo "Changelog entry ${FILENAME}.yaml already exists. Updating." + # Extend the .issues field and update it + OLD_ISSUES=$(yq eval '.issues' ".chloggen/${FILENAME}.yaml") + # Combine the old and new issues and deduplicate them + NEW_ISSUES=$(echo $OLD_ISSUES $ISSUES | jq -s 'add | unique') + echo "Resulting issues: $NEW_ISSUES" + yq eval -i ".issues = $NEW_ISSUES | .issues style=\"flow\" " .chloggen/${FILENAME}.yaml +else + # Create a new changelog entry + echo "Creating new changelog entry ${FILENAME}.yaml." + cp .chloggen/TEMPLATE.yaml .chloggen/${FILENAME}.yaml +fi + +# Update fields only if the argument was passed +[[ ! -z "$CHANGE_TYPE" ]] && yq eval -i ".change_type = \"$CHANGE_TYPE\"" .chloggen/${FILENAME}.yaml +[[ ! -z "$COMPONENT" ]] && yq eval -i ".component = \"$COMPONENT\"" .chloggen/${FILENAME}.yaml +[[ ! -z "$NOTE" ]] && yq eval -i ".note = \"$NOTE\"" .chloggen/${FILENAME}.yaml +[[ ! -z "$SUBTEXT" ]] && yq eval -i ".subtext = \"$SUBTEXT\"" .chloggen/${FILENAME}.yaml + +echo "${FILENAME}.yaml has been created or updated." +exit 0 diff --git a/ci_scripts/install-tools.sh b/ci_scripts/install-tools.sh index 05c28f0436..2e2f0dee8a 100755 --- a/ci_scripts/install-tools.sh +++ b/ci_scripts/install-tools.sh @@ -5,6 +5,7 @@ # - Installs tools like kubectl, helm, pre-commit, go, and chloggen. # - Use OVERRIDE_OS_CHECK=true to bypass OS compatibility checks. # - This script is intended to be run via `make install-tools`. +# - Prompts the user for approval to install or update each tool. # # Example Usage: # Directly with bash: ./install-tools.sh [OVERRIDE_OS_CHECK=true] diff --git a/ci_scripts/update-images-operator-otel.sh b/ci_scripts/update-images-operator-otel.sh new file mode 100755 index 0000000000..00cc08afc7 --- /dev/null +++ b/ci_scripts/update-images-operator-otel.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# Purpose: Updates OpenTelemetry and Splunk images for auto-instrumentation. +# Notes: +# - OpenTelemetry images are centralized and may change with operator subchart updates. +# - Splunk images are decentralized and have a separate update mechanism and release cadence. +# +# Example Usage: +# ./update-images-operator-otel.sh +# ./update-images-operator-otel.sh --debug + +# Include the base utility functions for setting and debugging variables +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +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" + +# ---- Operator Subchart Version Extraction ---- +# Extract the version of the opentelemetry-operator subchart from the main Chart.yaml +# This version helps us fetch the corresponding appVersion and image versions. +SUBCHART_VERSION=$(yq eval '.dependencies[] | select(.name == "opentelemetry-operator") | .version' "$CHART_FILE_PATH") +echo "Opentelemetry Operator Subchart Version: $SUBCHART_VERSION" + +# ---- Fetching App Version ---- +# Fetch the appVersion corresponding to the Operator subchart Version. +# This is extracted from the subchart's definition in the Chart.yaml file. +SUBCHART_URL="https://raw.githubusercontent.com/open-telemetry/opentelemetry-helm-charts/opentelemetry-operator-$SUBCHART_VERSION/charts/opentelemetry-operator/Chart.yaml" +debug "Fetching: $SUBCHART_URL" +APP_VERSION=$(curl -s "$SUBCHART_URL" | grep 'appVersion:' | awk '{print $2}') +debug "Operator App Version: $APP_VERSION" + +# ---- 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. +VERSIONS_URL="https://raw.githubusercontent.com/open-telemetry/opentelemetry-operator/v$APP_VERSION/versions.txt" +debug "Fetching: $VERSIONS_URL" +curl -s "$VERSIONS_URL" > "$TEMP_VERSIONS" +debug "Values from Operator OpenTelemetry versions.txt file containing image tags" +debug "$TEMP_VERSIONS" + +# ---- Extract Subsection for Update ---- +# Extract the content between "# Auto-instrumentation Libraries (Start)" and "# Auto-instrumentation Libraries (End)" +awk '/# Auto-instrumentation Libraries \(Start\)/,/# Auto-instrumentation Libraries \(End\)/' "$VALUES_FILE_PATH" | grep -v "# Auto-instrumentation Libraries " > "$TEMP_VALUES_FILE" + +# ---- Update Image Information ---- +while IFS='=' read -r IMAGE_KEY VERSION; do + NEED_UPDATE="${NEED_UPDATE:-0}" # Sets NEED_UPDATE to its current value or 0 if not set + 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}" + + setd "REPOSITORY_LOCAL_PATH" "${INST_LIB_NAME}.repository" + setd "REPOSITORY_LOCAL" "$(yq eval ".${REPOSITORY_LOCAL_PATH}" "${TEMP_VALUES_FILE}")" + + if [[ -z "${REPOSITORY_LOCAL}" || "${REPOSITORY_LOCAL}" != *"splunk"* ]]; then + yq eval -i ".${REPOSITORY_LOCAL_PATH} = \"${REPOSITORY_UPSTREAM}\"" "${TEMP_VALUES_FILE}" + + 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 + else + debug "Retaining existing value for ${REPOSITORY_LOCAL}:${TAG_LOCAL}" + fi + else + # Splunk instrumentation libraries are updated in a different workflow. + debug "Skipping updating ${REPOSITORY_LOCAL}:${TAG_LOCAL}" + fi + fi +done < "${TEMP_VERSIONS}" + +# Emit the NEED_UPDATE variable to either GitHub output or stdout +emit_output "NEED_UPDATE" + +# Merge the updated subsection back into values.yaml +# This approach specifically updates only the subsection between the start and end tokens. +# By doing so, we avoid reformatting the entire file, thus preserving the original structure and comments. +awk ' + !p && !/# Auto-instrumentation Libraries \(Start\)/ && !/# Auto-instrumentation Libraries \(End\)/ { print $0; next } + /# Auto-instrumentation Libraries \(Start\)/ {p=1; print $0; next} + /# Auto-instrumentation Libraries \(End\)/ {p=0; while((getline line < "'$TEMP_VALUES_FILE'") > 0) printf " %s\n", line; print $0; next} +' "$VALUES_FILE_PATH" > "${VALUES_FILE_PATH}.updated" + +# 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" + +echo "Image update process completed successfully!" +exit 0 diff --git a/ci_scripts/update-images-operator-splunk.sh b/ci_scripts/update-images-operator-splunk.sh new file mode 100755 index 0000000000..d5a4e4f721 --- /dev/null +++ b/ci_scripts/update-images-operator-splunk.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# Purpose: Updates Splunk images for auto-instrumentation. +# Notes: +# - This script updates the instrumentation libraries from Splunk's repositories. +# - This script will always pull the latest version of a specific Splunk instrumentation library. +# - OpenTelemetry images are updated differently and are not handled by this script. +# Parameters: +# 1: Name of the instrumentation library (mandatory) +# --debug: Enable debug mode (optional) +# +# Example Usage: +# ./update-images-operator-splunk.sh java +# ./update-images-operator-splunk.sh nodejs --debug + +# Include the base utility functions for setting and debugging variables +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "$SCRIPT_DIR/base_util.sh" + +# ---- Validate Input Arguments ---- +# Check for command-line arguments +if [ "$#" -eq 0 ]; then + echo "Error: No arguments provided." + echo "Usage: $0 [--debug]" + exit 1 +fi + +# ---- Initialize Variables ---- +# Set the instrumentation library name +setd "INST_LIB_NAME" "$1" + +# Set repository-related variables +setd "REPO" "ghcr.io/${OWNER}/splunk-otel-${INST_LIB_NAME}/splunk-otel-${INST_LIB_NAME}" +setd "REPOSITORY_LOCAL_PATH" "operator.instrumentation.spec.${INST_LIB_NAME}.repository" +setd "REPOSITORY_LOCAL" "$(yq eval ".${REPOSITORY_LOCAL_PATH}" "${VALUES_FILE_PATH}")" +setd "TAG_LOCAL_PATH" "operator.instrumentation.spec.${INST_LIB_NAME}.tag" +setd "TAG_LOCAL" "$(yq eval ".${TAG_LOCAL_PATH}" "${VALUES_FILE_PATH}")" + +# ---- Fetch Latest Version ---- +# Fetch the latest version from GitHub +setd "LATEST_API" "https://api.github.com/repos/${OWNER}/splunk-otel-${INST_LIB_NAME}/releases/latest" +setd "LATEST_API_CURL" "curl -L -qs -H 'Accept: application/vnd.github+json' \"$LATEST_API\" | jq -r .tag_name" +setd "TAG_UPSTREAM" "$(eval $LATEST_API_CURL)" + +# ---- Display Version Information ---- +# Display current and latest versions +echo "${REPOSITORY_LOCAL} -> Local tag: ${TAG_LOCAL}, Latest tag: $TAG_UPSTREAM" + +# ---- Update Version Information ---- +# If needed, update the tag version in values.yaml +setd "NEED_UPDATE" "${NEED_UPDATE:-0}" # Sets NEED_UPDATE to its current value or 0 if not set +if [ "$TAG_UPSTREAM" == "$TAG_LOCAL" ]; then + echo "We are already up to date. Nothing else to do." +elif [[ -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\"" "${VALUES_FILE_PATH}" + setd "NEED_UPDATE" 1 # Setting NEED_UPDATE to 1 as an update is required +fi + +# Emit the NEED_UPDATE variable to either GitHub output or stdout +emit_output "NEED_UPDATE" + +echo "Image update process completed successfully!" +exit 0 diff --git a/ci_scripts/update_changelog_links.sh b/ci_scripts/update_changelog_links.sh index ad26d933b4..45f63b29a5 100755 --- a/ci_scripts/update_changelog_links.sh +++ b/ci_scripts/update_changelog_links.sh @@ -26,7 +26,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Create a temporary file to hold the updated CHANGELOG.md content TEMP_CHANGELOG="CHANGELOG.md.tmp" -# ---- Update PR Links in CHANGELOG.md ---- +# ---- Update CHANGELOG.md for Subcontext and PR Links ---- while IFS= read -r line; do if [[ $line =~ \(\#([0-9,# ]+)\)$ ]]; then pr_ids=${BASH_REMATCH[1]} @@ -51,7 +51,12 @@ while IFS= read -r line; do echo "$line" >> "$TEMP_CHANGELOG" fi done < "CHANGELOG.md" +mv "$TEMP_CHANGELOG" "CHANGELOG.md" +# Insert the line about the Splunk OpenTelemetry Collector version adopted in this Kubernetes release +appVersion=$(grep "appVersion:" helm-charts/splunk-otel-collector/Chart.yaml | awk '{print $2}') +insert_line="This Splunk OpenTelemetry Collector for Kubernetes release adopts the [Splunk OpenTelemetry Collector v${appVersion}](https://github.com/signalfx/splunk-otel-collector/releases/tag/v${appVersion}).\n" +awk -v n=11 -v s="$insert_line" 'NR == n {print s} {print}' CHANGELOG.md > $TEMP_CHANGELOG mv "$TEMP_CHANGELOG" "CHANGELOG.md" echo "Successfully updated PR links in CHANGELOG.md" diff --git a/helm-charts/splunk-otel-collector/Chart.yaml b/helm-charts/splunk-otel-collector/Chart.yaml index d48cca8b9f..9adf7b4e9e 100644 --- a/helm-charts/splunk-otel-collector/Chart.yaml +++ b/helm-charts/splunk-otel-collector/Chart.yaml @@ -27,7 +27,7 @@ dependencies: repository: https://charts.jetstack.io condition: certmanager.enabled - name: opentelemetry-operator - version: 0.37.0 + version: 0.36.0 alias: operator repository: https://open-telemetry.github.io/opentelemetry-helm-charts condition: operator.enabled