-
Notifications
You must be signed in to change notification settings - Fork 765
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
[BUG]: team membership flaps constantly after release 6.4.0 apparently due to #2420 #2470
Comments
I have the exact same issue. |
Another "me too" comment. |
+1 |
Take a look at the hoops I've had to jump through to convert team slugs into ids for a bunch of repos defined in human-curated json files, and tell me again how great it is that the provider uses fewer API requests:
|
Concur with the above. I see what we /could/ do, but if you look at the example in the other comment, we're effectively asked to implement all the logic that should be in a provider, on top of the provider in the resource definition. At the topmost abstraction, the resource definition layer (our terraform code) lookups of foundational references should be invisible... and the contested provider code clearly shows this behavior (but flipped from invisibly looking up one thing to invisibly looking up some other thing instead) |
@robinbowes @JCY-Alchemy I've just re-checked my notes and this is a defect as I'd intended to not churn on slugs. There are no automated acceptance tests here (I'm working on it) and I don't work at GitHub so don't have easy access to test infrastructure. I've got a PR open to work on this resource so I'll figure out why this isn't working and add a fix. FYI the reason the number of API call matter is that prior to the refactor this resource was unusable at anything approaching scale. |
Anyone able to work on the PR referenced here? This bug is causing serious churn (and causing API rate limiting) for us. |
@devopsrick there are a number of PRs outstanding tha haven't even had a review. The following code might be more efficient than defining each team as a data lookup, and it should have a minimal impact on your actual code. The number of GitHub API calls will be comparable or fewer than by passing the slug directly into the resource. data "github_organization_teams" "all" {
summary_only = true
}
locals {
teams = {
"my-team" = "pull"
"my-admin-team" = "admin"
}
team_id_lookup = { for t in data.github_organization_teams.all.teams : t.slug => t.id }
}
resource "github_repository_collaborators" "example" {
repository = var.repo_name
dynamic "team" {
for_each = local.teams
content {
permission = team.value
team_id = local.team_id_lookup[team.key]
}
}
} But if you do want to define each team the same pattern also works. data "github_team" "lookup" {
for_each = local.teams
slug = each.key
summary_only = true
}
locals {
teams = {
"my-team" = "pull"
"my-admin-team" = "admin"
}
team_id_lookup = { for t in data.github_organization_teams.lookup : t.slug => t.id }
}
resource "github_repository_collaborators" "example" {
repository = var.repo_name
dynamic "team" {
for_each = local.teams
content {
permission = team.value
team_id = local.team_id_lookup[team.key]
}
}
} |
@stevehipwell Thank you for the suggestion but unfortunately that pattern will not work for us as we use modules to create repos and manage permissions and we pass the team slug to the module. If we add data sources to look up the id of each team within the modules this will exponentially increase the API calls made as each module will refresh its own data sources resulting in hundreds of duplicate calls. For context we manage 760 repositories and 193 teams accessing various. The volume of access across repositories makes it a very delicate process to update more than a few repository collaborator lists at any time. The churn of replacing every repository permission list every time is causing pretty bad issues for us. The other option is to rework our code entirely to pass team ids instead of slugs but that also require retraining every member who works with our codebase (quite a few) and that isn't really an option. |
@devopsrick the code behind the contributors makes a significant number of API calls if you're using slugs but I guess this only happens when there are changes. After my current in flight PRs are merged, so there are acceptance tests as part of a PR, I plan on refactoring the codebase to use team slugs directly. I can do this for collaborators in the current pending PR, but that doesn't help without a review. Sorry, but I don't have an easy solution for you. |
@devopsrick you might be able to use the second pattern from above with a |
Steve, What I do as a workaround is:
Something like this:
|
Expected Behavior
github_repository_collaborators
should be recognized in plans and applys, or changed implicitly to ID if necessaryActual Behavior
terraform apply
with the plan succeedsTerraform Version
Terraform v1.8.3
on darwin_arm64
version = "~> 6.2"
in the provider)See #2420 for the change that seems to drive this.
Affected Resource(s)
Terraform Configuration Files
Steps to Reproduce
notes
configure
plan
Debug Output
No response
Panic Output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: