-
Notifications
You must be signed in to change notification settings - Fork 269
fix(roles): Handle issue with duplicate IDs cause 400
despite using existing resources
#2254
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
Conversation
In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically. |
400
despite using existing resources
This comment was marked as outdated.
This comment was marked as outdated.
🔧 Schema Update RequiredThis PR introduces changes that affect the Terraform provider schema. The issue templates need to be updated. 📋 Required ActionPlease run the generator to update templates: make generate-templates Then commit the updated files:
This comment was generated automatically because schema changes were detected. |
🔧 Schema Update RequiredThis PR introduces changes that affect the Terraform provider schema. The issue templates need to be updated. 📋 Required ActionPlease run the generator to update templates: make generate-templates Then commit the updated files:
This comment was generated automatically because schema changes were detected. |
🔧 Schema Update RequiredThis PR introduces changes that affect the Terraform provider schema. The issue templates need to be updated. 📋 Required ActionPlease run the generator to update templates: make generate-templates Then commit the updated files:
This comment was generated automatically because schema changes were detected. |
This comment was marked as outdated.
This comment was marked as outdated.
1 similar comment
This comment was marked as outdated.
This comment was marked as outdated.
🔧 Schema Update RequiredThis PR introduces changes that affect the Terraform provider schema. The issue templates need to be updated. 📋 Required ActionPlease run the generator to update templates: make generate-templates Then commit the updated files:
This comment was generated automatically because schema changes were detected. |
Related-To: https://github.com/grafana/support-escalations/issues/17189, https://github.com/grafana/grafana-enterprise/pull/9055
What?
Adds duplicate checking to
grafana_role_assignment_item
resource to prevent sending duplicate team/user/service account IDs in role assignment API requests.Create()
method inresource_role_assignment_item.go
to check for existing assignments before appending new onesTestAccRoleAssignmentItem_NoDuplicates
test case to verify the fixWhy?
When multiple
grafana_role_assignment_item
resources target the same role, the provider was appending assignments to existing ones without checking for duplicates. This caused API requests with duplicate IDs, resulting in 400 errors from Grafana. I opened a PR to gracefully handle duplicates but I'm not 100% whether this is how it should be done (See https://github.com/grafana/grafana-enterprise/pull/9055)Reproduce
This fails with
Failed to set role assignments: [PUT /access-control/roles/{roleUID}/assignments] setRoleAssignments (status 400): {}
The second assignment item would fetch existing assignments
[users: [15], teams: []]
, append team 2, but due to state inconsistencies could result in duplicate entries like[users: [15], teams: [2, 2]]
.We now check if assignment already exists before adding, preventing duplicates.