Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

yuri-tceretian
Copy link
Contributor

What is this feature?
This PR fixes state persister to populate the result fingerprint field introduced in #75189 and accidentally removed in #80384
Also, it updates the state manager to always update result fingerprint when it does not match the existing one and emit a log message.

Why do we need this feature?
PR #80384 introduced a regression, which resulted in ResultFingerprint not being saved to the storage. Therefore, if the Grafana restarts the current state is fetched from the database, and the state's fingerprint remains empty. During the lifetime of the state, the resulting fingerprint is not updated, which breaks recovery threshold functionality that relies on this hash: the state manager provides an empty hash to the evaluator, and that hash does not match anything. Therefore, all dimensions that are supposed to be considered "loaded", and therefore evaluated using the unloading threshold, are evaluated against the loading threshold.
The state remains empty because the state manager never updates the result fingerprint of the existing state.

Who is this feature for?
Users of recovery threshold.

Which issue(s) does this PR fix?:

Related to and potentially fixes #87226

@yuri-tceretian yuri-tceretian added type/bug add to changelog backport v10.4.x backport v11.0.x Mark PR for automatic backport to v11.0.x backport v11.1.x Mark PR for automatic backport to v11.1.x labels Jul 30, 2024
@yuri-tceretian yuri-tceretian self-assigned this Jul 30, 2024
@yuri-tceretian yuri-tceretian requested a review from a team as a code owner July 30, 2024 21:00
@github-actions github-actions bot added this to the 11.2.x milestone Jul 30, 2024
Copy link
Contributor

This PR must be merged before a backport PR will be created.

3 similar comments
Copy link
Contributor

This PR must be merged before a backport PR will be created.

Copy link
Contributor

This PR must be merged before a backport PR will be created.

Copy link
Contributor

This PR must be merged before a backport PR will be created.

@yuri-tceretian yuri-tceretian merged commit 537f1fb into main Jul 30, 2024
@yuri-tceretian yuri-tceretian deleted the yuri-tceretian/fix-result-fingerprint-save branch July 30, 2024 22:07
Copy link
Contributor

The backport to v10.4.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-91224-to-v10.4.x origin/v10.4.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 537f1fb857cdefabd0bef1d97f87a7966ead12e6

When the conflicts are resolved, stage and commit the changes:

git add . && git cherry-pick --continue

If you have the GitHub CLI installed:

# Push the branch to GitHub:
git push --set-upstream origin backport-91224-to-v10.4.x
# Create the PR body template
PR_BODY=$(gh pr view 91224 --json body --template 'Backport 537f1fb857cdefabd0bef1d97f87a7966ead12e6 from #91224{{ "\n\n---\n\n" }}{{ index . "body" }}')
# Create the PR on GitHub
echo "${PR_BODY}" | gh pr create --title '[v10.4.x] Alerting: Fix persisting result fingerprint that is used by recovery threshold' --body-file - --label 'type/bug' --label 'area/backend' --label 'add to changelog' --label 'backport' --base v10.4.x --milestone 10.4.x --web

Or, if you don't have the GitHub CLI installed (we recommend you install it!):

# Push the branch to GitHub:
git push --set-upstream origin backport-91224-to-v10.4.x

# Create a pull request where the `base` branch is `v10.4.x` and the `compare`/`head` branch is `backport-91224-to-v10.4.x`.

# Remove the local backport branch
git switch main
git branch -D backport-91224-to-v10.4.x

@grafana-delivery-bot grafana-delivery-bot bot added the backport-failed Failed to generate backport PR. Please resolve conflicts and create one manually. label Jul 30, 2024
Copy link
Contributor

The backport to v11.0.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-91224-to-v11.0.x origin/v11.0.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 537f1fb857cdefabd0bef1d97f87a7966ead12e6

When the conflicts are resolved, stage and commit the changes:

git add . && git cherry-pick --continue

If you have the GitHub CLI installed:

# Push the branch to GitHub:
git push --set-upstream origin backport-91224-to-v11.0.x
# Create the PR body template
PR_BODY=$(gh pr view 91224 --json body --template 'Backport 537f1fb857cdefabd0bef1d97f87a7966ead12e6 from #91224{{ "\n\n---\n\n" }}{{ index . "body" }}')
# Create the PR on GitHub
echo "${PR_BODY}" | gh pr create --title '[v11.0.x] Alerting: Fix persisting result fingerprint that is used by recovery threshold' --body-file - --label 'type/bug' --label 'area/backend' --label 'add to changelog' --label 'backport' --base v11.0.x --milestone 11.0.x --web

Or, if you don't have the GitHub CLI installed (we recommend you install it!):

# Push the branch to GitHub:
git push --set-upstream origin backport-91224-to-v11.0.x

# Create a pull request where the `base` branch is `v11.0.x` and the `compare`/`head` branch is `backport-91224-to-v11.0.x`.

# Remove the local backport branch
git switch main
git branch -D backport-91224-to-v11.0.x

Copy link
Contributor

The backport to v11.1.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-91224-to-v11.1.x origin/v11.1.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 537f1fb857cdefabd0bef1d97f87a7966ead12e6

When the conflicts are resolved, stage and commit the changes:

git add . && git cherry-pick --continue

If you have the GitHub CLI installed:

# Push the branch to GitHub:
git push --set-upstream origin backport-91224-to-v11.1.x
# Create the PR body template
PR_BODY=$(gh pr view 91224 --json body --template 'Backport 537f1fb857cdefabd0bef1d97f87a7966ead12e6 from #91224{{ "\n\n---\n\n" }}{{ index . "body" }}')
# Create the PR on GitHub
echo "${PR_BODY}" | gh pr create --title '[v11.1.x] Alerting: Fix persisting result fingerprint that is used by recovery threshold' --body-file - --label 'type/bug' --label 'area/backend' --label 'add to changelog' --label 'backport' --base v11.1.x --milestone 11.1.x --web

Or, if you don't have the GitHub CLI installed (we recommend you install it!):

# Push the branch to GitHub:
git push --set-upstream origin backport-91224-to-v11.1.x

# Create a pull request where the `base` branch is `v11.1.x` and the `compare`/`head` branch is `backport-91224-to-v11.1.x`.

# Remove the local backport branch
git switch main
git branch -D backport-91224-to-v11.1.x

yuri-tceretian added a commit that referenced this pull request Jul 31, 2024
…threshold (#91224)

(cherry picked from commit 537f1fb)

# Conflicts:
#	pkg/services/ngalert/state/persister_sync.go
yuri-tceretian added a commit that referenced this pull request Jul 31, 2024
…threshold (#91224)

(cherry picked from commit 537f1fb)

# Conflicts:
#	pkg/services/ngalert/state/persister_sync.go
yuri-tceretian added a commit that referenced this pull request Jul 31, 2024
…threshold (#91224)

(cherry picked from commit 537f1fb)

# Conflicts:
#	pkg/services/ngalert/state/persister_sync.go
yuri-tceretian added a commit that referenced this pull request Jul 31, 2024
… recovery threshold (#91290)

Alerting: Fix persisting result fingerprint that is used by recovery threshold (#91224)

(cherry picked from commit 537f1fb)

# Conflicts:
#	pkg/services/ngalert/state/persister_sync.go
yuri-tceretian added a commit that referenced this pull request Jul 31, 2024
… recovery threshold (#91328)

Alerting: Fix persisting result fingerprint that is used by recovery threshold (#91224)

(cherry picked from commit 537f1fb)

# Conflicts:
#	pkg/services/ngalert/state/persister_sync.go
yuri-tceretian added a commit that referenced this pull request Jul 31, 2024
… recovery threshold (#91331)

Alerting: Fix persisting result fingerprint that is used by recovery threshold (#91224)

(cherry picked from commit 537f1fb)

# Conflicts:
#	pkg/services/ngalert/state/persister_sync.go
giorgioatmerqury pushed a commit to cybermerqury/grafana that referenced this pull request Aug 21, 2024
…threshold (grafana#91224)

* fix persister to save result fingerprint

* revert change

* fmt
@aangelisc aangelisc modified the milestones: 11.2.x, 11.2.0 Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/backend backport v10.4.x backport v11.0.x Mark PR for automatic backport to v11.0.x backport v11.1.x Mark PR for automatic backport to v11.1.x backport-failed Failed to generate backport PR. Please resolve conflicts and create one manually. type/bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Alert rule > Threshold expression > Custom recovery threshold > "stop alerting when" condition does not work
4 participants