Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service accounts: Creation logic simplification #63884

Merged
merged 4 commits into from Mar 1, 2023

Conversation

IevaVasiljeva
Copy link
Contributor

@IevaVasiljeva IevaVasiljeva commented Feb 28, 2023

What is this feature?

Simplify the creation logic:

  • remove one DB transaction to avoid nested transactions;
  • add service account to org through CreateServiceAccount method in the user store;
  • remove a bunch of code that is not relevant for service accounts;
  • move errors to service account model.go;
  • use errutil.Error for errors.

Why do we need this feature?

Nested transactions caused issues with instances that have a limit on the number of DB sessions.

Other changes are mainly to simplify the code and make it easier to maintain.

Special notes for your reviewer:

Enterprise PR (a one line change): https://github.com/grafana/grafana-enterprise/pull/4712

@sakjur
Copy link
Contributor

sakjur commented Mar 1, 2023

remove one DB transaction to avoid nested transactions

FWIW, you shouldn't have to do that, if there's a transaction on the context object, Grafana should reuse that.

@IevaVasiljeva IevaVasiljeva changed the title Service accounts: Creation logic simplification and performance improvements Service accounts: Creation logic simplification Mar 1, 2023
Copy link
Contributor

@eleijonmarck eleijonmarck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@IevaVasiljeva IevaVasiljeva merged commit 3fb1894 into main Mar 1, 2023
5 checks passed
@IevaVasiljeva IevaVasiljeva deleted the improve-sa-creation branch March 1, 2023 16:31
@grafanabot
Copy link
Contributor

The backport to v9.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-63884-to-v9.4.x origin/v9.4.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 3fb1894739f0d9344065e4d8b61f5fb896f4c933
# Push it to GitHub
git push --set-upstream origin backport-63884-to-v9.4.x
git switch main
# Remove the local backport branch
git branch -D backport-63884-to-v9.4.x

Then, create a pull request where the base branch is v9.4.x and the compare/head branch is backport-63884-to-v9.4.x.

@grafanabot grafanabot added the backport-failed Failed to generate backport PR. Please resolve conflicts and create one manually. label Mar 1, 2023
@IevaVasiljeva IevaVasiljeva added no-backport Skip backport of PR and removed backport v9.4.x Mark PR for automatic backport to v9.4.x labels Mar 1, 2023
@IevaVasiljeva IevaVasiljeva modified the milestones: 9.4.2, 9.5.0 Mar 1, 2023
@IevaVasiljeva IevaVasiljeva removed the backport-failed Failed to generate backport PR. Please resolve conflicts and create one manually. label Mar 1, 2023
ryantxu pushed a commit that referenced this pull request Mar 2, 2023
* SA creation improvements

* PR feedback - put salt and rand back in and remove an unneeded line:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants