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

restore script can't recreate membership of deleted team #237

Open
valafon opened this issue Aug 3, 2023 · 0 comments
Open

restore script can't recreate membership of deleted team #237

valafon opened this issue Aug 3, 2023 · 0 comments

Comments

@valafon
Copy link

valafon commented Aug 3, 2023

If we delete the team and recreate it by script, team members don't restore. As I see, membership is restored through the ID of a team. But when the team is recreated by script, it has a new ID. So the script has 500 errors in the logs

[DEBUG] resp body: {'id': 1, 'email': 'admin@localhost', 'name': '', 'login': 'admin', 'theme': '', 'orgId': 1, 'isGrafanaAdmin': True, 'isDisabled': False, 'isExternal': False, 'authLabels': None, 'updatedAt': '2023-08-03T04:44:51Z', 'createdAt': '2023-07-28T09:49:47Z', 'avatarUrl': ''}
[DEBUG] resp status: 500
[DEBUG] resp body: {'message': 'Failed to add Member to Team', 'traceID': ''}
create team member: , status: 500, msg: {'message': 'Failed to add Member to Team', 'traceID': ''}
restoring team_member: /tmp/tmpey6gbt25/_OUTPUT_/team_members/202308030620/7_9.team_member

I think the main root cause is that Grafana doesn't recreate a team with an ID specified -

curl -X POST -H "Content-Type: application/json" -H "Authorization: Basic *****" -d '{"id": "9","name": "test-issue"}' http://grafana_url.com/api/teams
{"message":"Team created","teamId":13}

So when the script tried to recreate a team with the same ID, actually Grafana creates it with another, so restoring membership also doesn't work.

Steps to reproduce: create a team, and add some members to it. Back up Grafana with grafana backup tool, then delete the team and try to restore Grafana. You will see the team is recreated, but there are no members and 500 errors in logs related to adding members to the team. Permissions to folders for teams also don't restore when team is recreated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant