Lerentis / terraform-provider-gitea

Terraform Provider for your Gitea Instance
https://registry.terraform.io/providers/Lerentis/gitea/latest
MIT License
22 stars 11 forks source link

gitea_team - Error: Plugin did not respond #51

Open jlec opened 1 year ago

jlec commented 1 year ago

Describe the bug Crash at apply. Although the team is created, but with no permissions.

To Reproduce Steps to reproduce the behavior:

resource "gitea_team" "grafana_admin" {
  name                     = "admin"
  organisation             = "grafana"
  description              = "Grafana Admins"
  permission               = "owner"
  members                  = [gitea_user.justin.username]
  include_all_repositories = true
}

Expected behavior successful apply

Log Output

gitea_team.grafana_admin: Creating...
╷
│ Error: Plugin did not respond
│
│   with gitea_team.grafana_admin,
│   on gitea.tf line 30, in resource "gitea_team" "grafana_admin":
│   30: resource "gitea_team" "grafana_admin" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-gitea_v0.16.0 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x1051b0f80]

goroutine 42 [running]:
git.uploadfilter24.eu/terraform-provider-gitea/gitea.setTeamResourceData(0x140000a6960, 0x1053a1186?, {0x10564f640?, 0x14000318630?})
    git.uploadfilter24.eu/terraform-provider-gitea/gitea/resource_gitea_team.go:234 +0xb0
git.uploadfilter24.eu/terraform-provider-gitea/gitea.resourceTeamCreate(0x0?, {0x10564f640?, 0x14000318630})
    git.uploadfilter24.eu/terraform-provider-gitea/gitea/resource_gitea_team.go:115 +0x954
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x10565ba00?, {0x10565ba00?, 0x1400060ef60?}, 0xd?, {0x10564f640?, 0x14000318630?})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/resource.go:721 +0x138
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x1400043c9a0, {0x10565ba00, 0x1400060ef60}, 0x140005025b0, 0x140004cc900, {0x10564f640, 0x14000318630})
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/resource.go:864 +0x898
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x1400013d170, {0x10565ba00?, 0x1400060ee40?}, 0x140000c8370)
    github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/grpc_provider.go:1024 +0xb94
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x140001205a0, {0x10565ba00?, 0x1400060e420?}, 0x14000618150)
    github.com/hashicorp/terraform-plugin-go@v0.16.0/tfprotov5/tf5server/server.go:821 +0x3c0
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x105623660?, 0x140001205a0}, {0x10565ba00, 0x1400060e420}, 0x140006180e0, 0x0)
    github.com/hashicorp/terraform-plugin-go@v0.16.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:422 +0x174
google.golang.org/grpc.(*Server).processUnaryRPC(0x14000458000, {0x10565e6a0, 0x140002fc680}, 0x140002d2000, 0x1400045a810, 0x105ae3040, 0x0)
    google.golang.org/grpc@v1.56.0/server.go:1337 +0xc7c
google.golang.org/grpc.(*Server).handleStream(0x14000458000, {0x10565e6a0, 0x140002fc680}, 0x140002d2000, 0x0)
    google.golang.org/grpc@v1.56.0/server.go:1714 +0x840
google.golang.org/grpc.(*Server).serveStreams.func1.1()
    google.golang.org/grpc@v1.56.0/server.go:959 +0x88
created by google.golang.org/grpc.(*Server).serveStreams.func1
    google.golang.org/grpc@v1.56.0/server.go:957 +0x170

Error: The terraform-provider-gitea_v0.16.0 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

task: Failed to run task "apply": exit status 1

Additional Data Important for reproducability.

jlec commented 1 year ago

gitea log

2023/08/10 18:51:02 ...eb/routing/logger.go:68:func1() [I] router: polling GET /user/events for 10.244.2.5:52614, elapsed 3958.4ms @ events/events.go:18(events.Events) 2023/08/10 18:51:10 ...eb/routing/logger.go:102:func1() [I] router: completed GET /api/v1/version for 10.244.2.5:43468, 200 OK in 168.3ms @ misc/version.go:15(misc.Version) 2023/08/10 18:51:10 ...eb/routing/logger.go:102:func1() [I] router: completed GET /api/v1/user for 10.244.2.5:43468, 200 OK in 114.3ms @ user/user.go:109(user.GetAuthenticatedUser) 2023/08/10 18:51:10 ...eb/routing/logger.go:102:func1() [I] router: completed GET /api/v1/admin/orgs?limit=50&page=1 for 10.244.2.5:43474, 200 OK in 235.5ms @ admin/org.go:81(admin.GetAllOrgs) 2023/08/10 18:51:10 ...eb/routing/logger.go:102:func1() [I] router: completed GET /api/v1/admin/orgs?limit=50&page=1 for 10.244.2.5:43468, 200 OK in 248.8ms @ admin/org.go:81(admin.GetAllOrgs) 2023/08/10 18:51:10 ...eb/routing/logger.go:102:func1() [I] router: completed GET /api/v1/users/search?uid=4 for 10.244.2.5:43490, 200 OK in 165.7ms @ user/user.go:18(user.Search) 2023/08/10 18:51:11 ...eb/routing/logger.go:102:func1() [I] router: completed GET /api/v1/orgs/grafana/repos?limit=50&page=1 for 10.244.2.5:43490, 200 OK in 218.7ms @ user/repo.go:140(user.ListOrgRepos) 2023/08/10 18:51:11 ...eb/routing/logger.go:102:func1() [I] router: completed GET /api/v1/orgs/jlec/repos?limit=50&page=1 for 10.244.2.5:43474, 200 OK in 249.8ms @ user/repo.go:140(user.ListOrgRepos) 2023/08/10 18:51:18 ...eb/routing/logger.go:102:func1() [I] router: completed GET /api/v1/version for 10.244.2.5:43474, 200 OK in 155.5ms @ misc/version.go:15(misc.Version) 2023/08/10 18:51:18 ...eb/routing/logger.go:102:func1() [I] router: completed GET /api/v1/user for 10.244.2.5:43474, 200 OK in 146.5ms @ user/user.go:109(user.GetAuthenticatedUser) 2023/08/10 18:51:19 ...eb/routing/logger.go:102:func1() [I] router: completed POST /api/v1/orgs/grafana/teams for 10.244.2.5:43474, 201 Created in 249.3ms @ org/team.go:185(org.CreateTeam) 2023/08/10 18:51:19 ...eb/routing/logger.go:102:func1() [I] router: completed PUT /api/v1/teams/11/members/justin for 10.244.2.5:43474, 204 No Content in 259.6ms @ org/team.go:455(org.AddTeamMember)

Lerentis commented 1 year ago

Hi @jlec,

Thanks for the report. Can you share the gitea version on which this happened?

jlec commented 1 year ago

@Lerentis 1.20.2, deployed using helm

jlec commented 1 year ago

tf import and subsequent apply works.

  # gitea_team.grafana_admin will be updated in-place
  ~ resource "gitea_team" "grafana_admin" {
        id                       = "11"
      ~ members                  = [
          + "justin",
        ]
        name                     = "admin"
      + units                    = "[repo.code, repo.issues, repo.ext_issues, repo.wiki, repo.pulls, repo.releases, repo.projects, repo.ext_wiki]"
        # (6 unchanged attributes hidden)
    }

something goes wrong with the initial create. Gitea creates the team, but the provider bails out.