Skip to content

Commit

Permalink
Merge branch 'main' into feat/parameterize-mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
alex5517 authored Oct 2, 2024
2 parents 9b3c5df + 30528c9 commit 859636f
Show file tree
Hide file tree
Showing 99 changed files with 19,665 additions and 4,066 deletions.
1 change: 0 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ Fixes #<issue number>
- [ ] Title matches the required conventional commits format, see [here](https://www.conventionalcommits.org/en/v1.0.0/)
- **Note** that Promtail is considered to be feature complete, and future development for logs collection will be in [Grafana Alloy](https://github.com/grafana/alloy). As such, `feat` PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
- [ ] Changes that require user attention or interaction to upgrade are documented in `docs/sources/setup/upgrade/_index.md`
- [ ] For Helm chart changes bump the Helm chart version in `production/helm/loki/Chart.yaml` and update `production/helm/loki/CHANGELOG.md` and `production/helm/loki/README.md`. [Example PR](https://github.com/grafana/loki/commit/d10549e3ece02120974929894ee333d07755d213)
- [ ] If the change is deprecating or removing a configuration option, update the `deprecated-config.yaml` and `deleted-config.yaml` files respectively in the `tools/deprecated-config-checker` directory. [Example PR](https://github.com/grafana/loki/pull/10840/commits/0d4416a4b03739583349934b96f272fb4f685d15)
2 changes: 1 addition & 1 deletion .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
metricsWriteAPIKey: ${{secrets.GRAFANA_MISC_STATS_API_KEY}}
token: ${{ steps.get_github_app_token.outputs.token }}
labelsToAdd: "backport"
title: "chore: [{{base}}] {{originalTitle}}"
title: "{{originalTitle}} (backport {{base}})"
11 changes: 2 additions & 9 deletions .github/workflows/helm-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
paths:
- "production/helm/**"
- ".github/workflows/helm-ci.yml"

env:
CT_CONFIGFILE: production/helm/ct.yaml
Expand All @@ -27,14 +28,6 @@ jobs:
- name: Lint Yaml
run: make helm-lint

- id: "get_github_app_token"
name: "Get Github app token"
uses: "actions/create-github-app-token@v1"
with:
app-id: "${{ secrets.APP_ID }}"
owner: "${{ github.repository_owner }}"
private-key: "${{ secrets.APP_PRIVATE_KEY }}"

- name: Lint Code Base
uses: docker://github/super-linter:v3.12.0
env:
Expand All @@ -45,7 +38,7 @@ jobs:
VALIDATE_YAML: false
VALIDATE_GO: false
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ steps.get_github_app_token.outputs.token }}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
call-test:
name: Test Helm Chart
runs-on: ubuntu-latest
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/helm-release.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
name: helm-release

on:
push:
branches:
- main
- helm-5.48
paths:
- 'production/helm/loki/Chart.yaml'
workflow_dispatch: # must be invoked manually

jobs:
call-update-helm-repo:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/helm-tagged-release-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: helm-weekly-release-pr

on:
release:
types:
- released

jobs:
weekly-release-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- id: "get_github_app_token"
name: "get github app token"
uses: "actions/create-github-app-token@v1"
with:
app-id: "${{ secrets.APP_ID }}"
owner: "${{ github.repository_owner }}"
private-key: "${{ secrets.APP_PRIVATE_KEY }}"

- name: Update/regenerate files
id: update
run: bash .github/workflows/scripts/helm-tagged-release.sh ${{ github.event.release.tag_name }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ steps.get_github_app_token.outputs.token }}
title: Release loki Helm chart ${{ steps.update.outputs.new_chart_version }}
body: Automated PR created by [helm-tagged-release-pr.yaml](https://github.com/grafana/loki/blob/main/.github/workflows/helm-tagged-release-pr.yaml)
commit-message: Update loki chart to ${{ steps.update.outputs.new_chart_version }}
branch: helm-chart-tagged-${{ steps.update.outputs.new_chart_version }}
base: main
labels: helm
37 changes: 37 additions & 0 deletions .github/workflows/helm-weekly-release-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: helm-weekly-release-pr

on:
schedule:
- cron: '0 10 * * 1-5' # 10 UTC on weekdays; if we miss published images one day, they should align the day after

workflow_dispatch: # for manual testing

jobs:
weekly-release-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: imjasonh/[email protected]

- id: "get_github_app_token"
name: "get github app token"
uses: "actions/create-github-app-token@v1"
with:
app-id: "${{ secrets.APP_ID }}"
owner: "${{ github.repository_owner }}"
private-key: "${{ secrets.APP_PRIVATE_KEY }}"

- name: Update/regenerate files
id: update
run: bash .github/workflows/scripts/helm-weekly-release.sh

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ steps.get_github_app_token.outputs.token }}
title: Release loki Helm chart ${{ steps.update.outputs.new_chart_version }}
body: Automated PR created by [helm-weekly-release-pr.yaml](https://github.com/grafana/loki/blob/main/.github/workflows/helm-weekly-release-pr.yaml)
commit-message: Update loki chart to ${{ steps.update.outputs.new_chart_version }}
branch: helm-chart-weekly-${{ steps.update.outputs.new_chart_version }}
base: main
labels: helm
45 changes: 45 additions & 0 deletions .github/workflows/scripts/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

set -exo pipefail

# This generates a new file where the yaml node is updated.
# The problem is that yq strips new lines when you update the file.
# So we use a workaround from https://github.com/mikefarah/yq/issues/515 which:
# generates the new file, diffs it with the original, removes all non-whitespace changes, and applies that to the original file.
update_yaml_node() {
local filename=$1
local yaml_node=$2
local new_value=$3
patch "${filename}" <<<"$(diff -U0 -w -b --ignore-blank-lines "${filename}" <(yq eval "${yaml_node} = \"${new_value}\"" "${filename}"))"
}

get_yaml_node() {
local filename=$1
local yaml_node=$2
yq "${yaml_node}" "${filename}"
}

# Increments the part of the semver string
# $1: version itself
# $2: number of part: 0 – major, 1 – minor, 2 – patch
increment_semver() {
local delimiter=.
local array=("$(echo "$1" | tr "${delimiter}" '\n')")
array[$2]=$((array[$2] + 1))
echo "$(
local IFS=${delimiter}
echo "${array[*]}"
)"
}

# Sets the patch segment of a semver to 0
# $1: version itself
set_semver_patch_to_zero() {
local delimiter=.
local array=("$(echo "$1" | tr "${delimiter}" '\n')")
array[2]="0"
echo "$(
local IFS=${delimiter}
echo "${array[*]}"
)"
}
54 changes: 54 additions & 0 deletions .github/workflows/scripts/helm-tagged-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: AGPL-3.0-only

set -exo pipefail

script_dir=$(cd "$(dirname "$0")" && pwd)
# shellcheck disable=SC2250,SC1091
source "${script_dir}/common.sh"

calculate_next_chart_version() {
local current_chart_version=$1

local current_chart_semver
current_chart_semver="$(echo "${current_chart_version}" | grep -P -o '^(\d+.){2}\d+')"
local new_chart_semver="${current_chart_semver}"
new_chart_semver=$(increment_semver "${current_chart_semver}" 1)
new_chart_semver=$(set_semver_patch_to_zero "${new_chart_semver}")
echo "${new_chart_semver}"
}

validate_version_update() {
local new_chart_version=$1
local current_chart_version=$2
local latest_loki_tag=$3

if [[ "${new_chart_version}" == "${current_chart_version}" ]]; then
echo "New chart version (${new_chart_version}) is the same as current version (${current_chart_version}); not submitting PR"
exit 1
fi
}

latest_loki_tag=$(sed -E "s/v(.*)/\1/g" <<<"$1")

values_file=production/helm/loki/values.yaml
chart_file=production/helm/loki/Chart.yaml

current_chart_version=$(get_yaml_node "${chart_file}" .version)
new_chart_version=$(calculate_next_chart_version "${current_chart_version}")

validate_version_update "${new_chart_version}" "${current_chart_version}" "${latest_loki_tag}"

update_yaml_node "${values_file}" .loki.image.tag "${latest_loki_tag}"

update_yaml_node "${values_file}" .enterprise.image.tag "${latest_loki_tag}"
update_yaml_node "${chart_file}" .appVersion "${latest_loki_tag}"
update_yaml_node "${chart_file}" .version "${new_chart_version}"

sed --in-place \
--regexp-extended \
"s/(.*\<AUTOMATED_UPDATES_LOCATOR\>.*)/\1\n\n## ${new_chart_version}\n\n- \[CHANGE\] Changed version of Grafana Loki to ${latest_loki_tag}/g" production/helm/loki/CHANGELOG.md

make TTY='' helm-docs

echo "::set-output name=new_chart_version::${new_chart_version}"
84 changes: 84 additions & 0 deletions .github/workflows/scripts/helm-weekly-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: AGPL-3.0-only

set -exo pipefail

script_dir=$(cd "$(dirname "$0")" && pwd)
# shellcheck disable=SC2250,SC1091
source "${script_dir}/common.sh"

# Uses docker hub image tags to figure out what is the latest image tag
find_latest_image_tag() {
local docker_hub_repo=$1
local regExp="^(k|weekly-k)\d+-[a-z0-9]+"
crane ls "${docker_hub_repo}" | grep -P "${regExp}" | sed -E "s/([weekly-]*k[[:digit:]]*)-([^-]*).*/\1-\2/g" | uniq | sort -Vur | head -1
}

# takes k197-abcdef and returns r197, k197-abcdef-arm64 and returns k197, weekly-k197-abcdef and returns k197
extract_k_version() {
sed -E "s/[weekly-]*(k[[:digit:]]*).*/\1/g" <<<"$1"
}

calculate_next_chart_version() {
local current_chart_version=$1
local latest_image_tag=$2

local current_chart_semver
current_chart_semver=$(echo "${current_chart_version}" | grep -P -o '^(\d+.){2}\d+')
local new_chart_weekly
new_chart_weekly=$(extract_k_version "${latest_image_tag}" | grep -P -o '\d+')
local new_chart_semver="${current_chart_semver}"
if [[ "${current_chart_version}" != *weekly* ]]; then
# If previous version was not a weekly, then it was a stable release.
# _This_ weekly release should have a semver that's one above the stable release.
new_chart_semver=$(increment_semver "${current_chart_semver}" 1)
# Also reset the patch release number to 0.
new_chart_semver=$(set_semver_patch_to_zero "${new_chart_semver}")
fi
echo "${new_chart_semver}-weekly.${new_chart_weekly}"
}

validate_version_update() {
local new_chart_version=$1
local current_chart_version=$2
local latest_gel_tag=$3
local latest_loki_tag=$4

if [[ "${new_chart_version}" == "${current_chart_version}" ]]; then
echo "New chart version (${new_chart_version}) is the same as current version (${current_chart_version}); not submitting weekly PR"
exit 1
fi

local gel_weekly_version
gel_weekly_version=$(extract_k_version "${latest_gel_tag}")
local loki_weekly_version
loki_weekly_version=$(extract_k_version "${latest_loki_tag}")
echo "Comparing GEL weekly version (${gel_weekly_version}) with Loki weekly version (${loki_weekly_version})"
if [[ "${gel_weekly_version}" != "${loki_weekly_version}" ]]; then
echo "GEL weekly version (${gel_weekly_version}) does not match Loki weekly version (${loki_weekly_version}); not submitting PR"
exit 1
fi
}

values_file=production/helm/loki/values.yaml
chart_file=production/helm/loki/Chart.yaml

latest_loki_tag=$(find_latest_image_tag grafana/loki)
latest_gel_tag=$(find_latest_image_tag grafana/enterprise-logs)
current_chart_version=$(get_yaml_node "${chart_file}" .version)
new_chart_version=$(calculate_next_chart_version "${current_chart_version}" "${latest_loki_tag}")

validate_version_update "${new_chart_version}" "${current_chart_version}" "${latest_gel_tag}" "${latest_loki_tag}"

update_yaml_node "${values_file}" .loki.image.tag "${latest_loki_tag}"
update_yaml_node "${values_file}" .enterprise.image.tag "${latest_gel_tag}"
update_yaml_node "${chart_file}" .appVersion "$(extract_k_version "${latest_loki_tag}")"
update_yaml_node "${chart_file}" .version "${new_chart_version}"

sed --in-place \
--regexp-extended \
"s/(.*\<AUTOMATED_UPDATES_LOCATOR\>.*)/\1\n\n## ${new_chart_version}\n\n- \[CHANGE\] Changed version of Grafana Loki to ${latest_loki_tag}\n- \[CHANGE\] Changed version of Grafana Enterprise Logs to ${latest_gel_tag}/g" production/helm/loki/CHANGELOG.md

make TTY='' helm-docs

echo "::set-output name=new_chart_version::${new_chart_version}"
52 changes: 0 additions & 52 deletions .github/workflows/verify-drone.yml

This file was deleted.

4 changes: 2 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
/docs/ @grafana/docs-logs @grafana/loki-team

# Loki operator
/operator/ @grafana/loki-team @periklis @xperimental
/.github/workflows/operator* @grafana/loki-team @periklis @xperimental
/operator/ @grafana/loki-team @periklis @xperimental @JoaoBraveCoding
/.github/workflows/operator* @grafana/loki-team @periklis @xperimental @JoaoBraveCoding

# Logql grammar
# The observability logs team is listed as co-codeowner for grammar file. This is to receive notifications about updates, so these can be implemented in https://github.com/grafana/lezer-logql
Expand Down
2 changes: 1 addition & 1 deletion clients/cmd/fluentd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.3.4 AS build
FROM ruby:3.3.5 AS build

ENV DEBIAN_FRONTEND=noninteractive

Expand Down
Loading

0 comments on commit 859636f

Please sign in to comment.