Skip to content
Merged
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
17 changes: 10 additions & 7 deletions .github/workflows/update-kube-stack-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Run update script
id: update-script
run: |
echo "Running kube-stack-version update script..."
echo "Running version update script (kube-stack-version and helm-version)..."
python scripts/update_kube_stack_version.py
echo "Script completed successfully"

Expand All @@ -60,19 +60,22 @@ jobs:
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore: update kube-stack-version'
title: 'chore: update kube-stack-version'
commit-message: 'chore: update kube-stack-version and helm-version'
title: 'chore: update kube-stack-version and helm-version'
body: |
This PR automatically updates the `kube-stack-version` in `docset.yml` based on the latest version from the elastic-agent repository.
This PR automatically updates the `kube-stack-version` and `helm-version` in `docset.yml` based on the latest versions from the Kibana and Elastic Agent repositories.

**Changes:**
- Updated `kube-stack-version` to the latest value from elastic-agent repository
- Updated `kube-stack-version` to the latest value from the Kibana repository
- Updated `helm-version` to the latest value from the Elastic Agent repository

**Generated by:** [Update Kube Stack Version workflow](https://github.com/${{ github.repository }}/actions/workflows/update-kube-stack-version.yml)

This is an automated update. Please review the changes before merging.
branch: update-kube-stack-version
delete-branch: true
team-reviewers: |
ingest-docs
labels: |
automated
chore
Expand All @@ -91,7 +94,7 @@ jobs:
git diff HEAD -- docset.yml >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
else
echo "ℹ️ **No changes needed** - kube-stack-version is already up to date" >> $GITHUB_STEP_SUMMARY
echo "ℹ️ **No changes needed** - kube-stack-version and helm-version are already up to date" >> $GITHUB_STEP_SUMMARY
fi

- name: Summary
Expand All @@ -102,5 +105,5 @@ jobs:
if [ "${{ steps.check-changes.outputs.has_changes }}" == "true" ]; then
echo "✅ **PR Created** - Changes detected and pull request created" >> $GITHUB_STEP_SUMMARY
else
echo "ℹ️ **No changes needed** - kube-stack-version is already up to date" >> $GITHUB_STEP_SUMMARY
echo "ℹ️ **No changes needed** - kube-stack-version and helm-version are already up to date" >> $GITHUB_STEP_SUMMARY
fi
2 changes: 2 additions & 0 deletions docset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ subs:
models-app: "Trained Models"
agent-builder: "Elastic Agent Builder"
kube-stack-version: 0.10.5
helm-version: 3.15.4
ece-docker-images-8: 8.18.8
ece-docker-images-9: 9.0.8


129 changes: 122 additions & 7 deletions scripts/update_kube_stack_version.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env python3
"""
Script to update the kube-stack-version in docset.yml based on the version
from the Kibana repository.
Script to update the kube-stack-version and helm-version in docset.yml based on
versions from the Kibana and Elastic Agent repositories.

This script:
1. Retrieves the latest semver from the Kibana repository
2. Reads the constants.ts file from that Kibana version
3. Extracts the OTEL_KUBE_STACK_VERSION value
4. Updates the kube-stack-version in docset.yml
4. Fetches the go.mod file from the Elastic Agent repository
5. Extracts the Helm version from go.mod
6. Updates both kube-stack-version and helm-version in docset.yml
"""

import re
Expand Down Expand Up @@ -143,6 +145,64 @@ def extract_kube_stack_version(content: str) -> str:
return version


def fetch_elastic_agent_gomod() -> str:
"""
Fetch the content of the go.mod file from the Elastic Agent repository with retry logic.

Returns:
str: The content of the go.mod file

Raises:
Exception: If unable to fetch the file content after retries
"""
url = "https://raw.githubusercontent.com/elastic/elastic-agent/refs/heads/main/go.mod"
max_retries = 3
retry_delay = 2 # seconds

for attempt in range(max_retries):
try:
print(f"Fetching go.mod from Elastic Agent repository (attempt {attempt + 1}/{max_retries})")
response = requests.get(url, timeout=30)
response.raise_for_status()

print("Successfully fetched go.mod from Elastic Agent repository")
return response.text

except requests.RequestException as e:
if attempt < max_retries - 1:
print(f"Attempt {attempt + 1} failed: {e}")
print(f"Retrying in {retry_delay} seconds...")
time.sleep(retry_delay)
retry_delay *= 2 # Exponential backoff
else:
raise Exception(f"Failed to fetch go.mod file after {max_retries} attempts: {e}")


def extract_helm_version(content: str) -> str:
"""
Extract the Helm version from the go.mod file content.

Args:
content (str): The content of the go.mod file

Returns:
str: The Helm version (e.g., '3.15.4')

Raises:
Exception: If the Helm version pattern is not found
"""
# Pattern to match helm.sh/helm/v3 vX.Y.Z
pattern = r'helm\.sh/helm/v3\s+v([\d.]+)'

match = re.search(pattern, content)
if not match:
raise Exception("Helm version pattern not found in go.mod file")

version = match.group(1)
print(f"Extracted Helm version: {version}")
return version


def update_docset_yml(kube_stack_version: str, docset_path: Path) -> None:
"""
Update the kube-stack-version in the docset.yml file.
Expand Down Expand Up @@ -184,10 +244,51 @@ def update_docset_yml(kube_stack_version: str, docset_path: Path) -> None:
raise Exception(f"Failed to update docset.yml: {e}")


def update_helm_version(helm_version: str, docset_path: Path) -> None:
"""
Update the helm-version in the docset.yml file.

Args:
helm_version (str): The new version to set
docset_path (Path): Path to the docset.yml file

Raises:
Exception: If unable to update the file
"""
try:
# Read the current docset.yml content
with open(docset_path, 'r', encoding='utf-8') as file:
content = file.read()

# Pattern to match helm-version: <value> (with 2 spaces at the beginning)
pattern = r'( helm-version:\s*)([^\s\n]+)'

# Replace the version
new_content = re.sub(pattern, rf'\g<1>{helm_version}', content)

if new_content == content:
# Check if the version is already correct
current_match = re.search(pattern, content)
if current_match and current_match.group(2) == helm_version:
print(f"helm-version is already set to {helm_version}")
return
else:
raise Exception("helm-version pattern not found in docset.yml")

# Write the updated content back to the file
with open(docset_path, 'w', encoding='utf-8') as file:
file.write(new_content)

print(f"Successfully updated helm-version to {helm_version} in docset.yml")

except Exception as e:
raise Exception(f"Failed to update docset.yml: {e}")


def main():
"""Main function to orchestrate the update process."""
try:
print("Starting kube-stack-version update process...")
print("Starting version update process...")

# Get the script directory and project root
script_dir = Path(__file__).parent
Expand All @@ -210,11 +311,25 @@ def main():
print("\n3. Extracting OTEL_KUBE_STACK_VERSION...")
kube_stack_version = extract_kube_stack_version(constants_content)

# Step 4: Update docset.yml
print("\n4. Updating docset.yml...")
# Step 4: Fetch go.mod content from Elastic Agent repository
print("\n4. Fetching go.mod file content from Elastic Agent repository...")
gomod_content = fetch_elastic_agent_gomod()

# Step 5: Extract Helm version
print("\n5. Extracting Helm version...")
helm_version = extract_helm_version(gomod_content)

# Step 6: Update docset.yml with kube-stack-version
print("\n6. Updating kube-stack-version in docset.yml...")
update_docset_yml(kube_stack_version, docset_path)

print(f"\n✅ Successfully updated kube-stack-version to {kube_stack_version}")
# Step 7: Update docset.yml with helm-version
print("\n7. Updating helm-version in docset.yml...")
update_helm_version(helm_version, docset_path)

print(f"\n✅ Successfully updated:")
print(f" - kube-stack-version to {kube_stack_version}")
print(f" - helm-version to {helm_version}")

except Exception as e:
print(f"\n❌ Error: {e}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Learn how to set up the EDOT Collector and EDOT SDKs in a Kubernetes environment
:::{include} ../../_snippets/guided-instructions.md
:::

## Prerequisites

To use the OpenTelemetry Kube Stack Chart, you need Helm version 3.9+ up to and including {{helm-version}}.

## Manual installation

Follow these steps to deploy the EDOT Collector and EDOT OTel SDKs in Kubernetes with ECH.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Learn how to set up the EDOT Collector and EDOT SDKs in a Kubernetes environment
:::{include} ../../_snippets/guided-instructions.md
:::

## Prerequisites

To use the OpenTelemetry Kube Stack Chart, you need Helm version 3.9+ up to and including {{helm-version}}.

## Manual installation

Follow these steps to deploy the EDOT Collector and EDOT OTel SDKs in Docker.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Learn how to set up the EDOT Collector and EDOT SDKs in a Kubernetes environment
:::{include} ../../_snippets/guided-instructions.md
:::

## Prerequisites

To use the OpenTelemetry Kube Stack Chart, you need Helm version 3.9+ up to and including {{helm-version}}.

## Manual installation

Follow these steps to deploy the EDOT Collector and EDOT OTel SDKs in Kubernetes.
Expand Down
Loading