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

Terraform plugin crash setting spec.generator.clusters.template.spec.source.directory=true #402

Open
mcanevet opened this issue Jun 25, 2024 · 1 comment
Labels
bug Something isn't working help wanted Community help wanted!

Comments

@mcanevet
Copy link

Terraform Version, ArgoCD Provider Version and ArgoCD Version

Terraform version: `v1.8.2`
ArgoCD provider version: `v6.1.1`
ArgoCD version: `v2.11.3`

Affected Resource(s)

  • argocd_application_set

Terraform Configuration Files

resource "argocd_application_set" "cluster_addons" {
  metadata {
    name = "cluster-addons"
  }

  spec {
    generator {
      clusters {
        template {
          spec {
            source {
              directory {
                recurse = true
              }
            }
          }
        }
      }
    }

    template {
      metadata {
        name = "cluster-addons"
      }

      spec {
        project = "default"

        source {
          repo_url        = "{{metadata.annotations.addons_repo_url}}"
          path            = "{{metadata.annotations.addons_repo_basepath}}{{metadata.annotations.addons_repo_path}}"
          target_revision = "{{metadata.annotations.addons_repo_revision}}"
        }

        destination {
          namespace = "argocd"
          server    = "{{name}}"
        }

        sync_policy {
          automated {
            prune     = true
            self_heal = true
          }
        }
      }
    }
  }
}

Debug Output

Panic Output

The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-argocd_v6.1.1 plugin:

panic: runtime error: index out of range [0] with length 0

goroutine 77 [running]:
github.com/oboukili/terraform-provider-argocd/argocd.expandApplicationSetTemplate({_, _}, _)
        github.com/oboukili/terraform-provider-argocd/argocd/structure_application_set.go:812 +0x39c
github.com/oboukili/terraform-provider-argocd/argocd.expandApplicationSetClustersGenerator({0x103b0d9e0?, 0x140013bdd40}, 0xc4?)
        github.com/oboukili/terraform-provider-argocd/argocd/structure_application_set.go:114 +0x194
github.com/oboukili/terraform-provider-argocd/argocd.expandApplicationSetGenerators({0x1400154d870, 0x1, 0x10315d5b5?}, 0x9?)
        github.com/oboukili/terraform-provider-argocd/argocd/structure_application_set.go:70 +0xe0
github.com/oboukili/terraform-provider-argocd/argocd.expandApplicationSetSpec(_, _, _)
        github.com/oboukili/terraform-provider-argocd/argocd/structure_application_set.go:26 +0xc8
github.com/oboukili/terraform-provider-argocd/argocd.expandApplicationSet(_, _, _)
        github.com/oboukili/terraform-provider-argocd/argocd/structure_application_set.go:17 +0xb0
github.com/oboukili/terraform-provider-argocd/argocd.resourceArgoCDApplicationSetCreate({0x1040833e0, 0x140013bc000}, 0x0?, {0x103e0ef40?, 0x14000407180?})
        github.com/oboukili/terraform-provider-argocd/argocd/resource_argocd_application_set.go:44 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x14000cba620, {0x104083418, 0x14000eff050}, 0xd?, {0x103e0ef40, 0x14000407180})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:778 +0xe8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x14000cba620, {0x104083418, 0x14000eff050}, 0x1400177a270, 0x1400168c980, {0x103e0ef40, 0x14000407180})
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:909 +0x8a0
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x140006a6120, {0x104083418?, 0x14000efee70?}, 0x140016823c0)
        github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1072 +0xb78
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x104099860?, 0x140006a6120?}}, {0x104083418, 0x14000efee70}, 0x0?)
        github.com/hashicorp/[email protected]/tf5to6server/tf5to6server.go:37 +0x58
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0x104083370?, {0x104083418?, 0x14000efeb40?}, 0x14001682370)
        github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x188
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0x14000b12280, {0x104083418?, 0x14000efe150?}, 0x14000380070)
        github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:857 +0x3bc
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x103ed31c0?, 0x14000b12280}, {0x104083418, 0x14000efe150}, 0x1400168c000, 0x0)
        github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:467 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0x140000361e0, {0x104083418, 0x14000efe0c0}, {0x1040923c0, 0x140005c8680}, 0x14001688000, 0x14000d5e2d0, 0x105b16518, 0x0)
        google.golang.org/[email protected]/server.go:1343 +0xc6c
google.golang.org/grpc.(*Server).handleStream(0x140000361e0, {0x1040923c0, 0x140005c8680}, 0x14001688000)
        google.golang.org/[email protected]/server.go:1737 +0x9f0
google.golang.org/grpc.(*Server).serveStreams.func1.1()
        google.golang.org/[email protected]/server.go:986 +0x88
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/[email protected]/server.go:997 +0x174

Error: The terraform-provider-argocd_v6.1.1 plugin crashed!

Steps to Reproduce

Expected Behavior

Should generate this ApplicationSet resource:

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: cluster-addons
  namespace: argocd
spec:
  syncPolicy:
    preserveResourcesOnDeletion: true
  generators:
    - clusters: {}
  template:
    metadata:
      name: cluster-addons
    spec:
      project: default
      source:
        repoURL: '{{metadata.annotations.addons_repo_url}}'
        path: '{{metadata.annotations.addons_repo_basepath}}{{metadata.annotations.addons_repo_path}}'
        targetRevision: '{{metadata.annotations.addons_repo_revision}}'
        directory:
          recurse: true
      destination:
        namespace: argocd
        name: '{{name}}'
      syncPolicy:
        automated: {}

Actual Behavior

crashes

Important Factoids

When not setting spec.generator.clusters.template.spec.source.directory, the resource is properly created.

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@mcanevet mcanevet added the bug Something isn't working label Jun 25, 2024
Copy link

github-actions bot commented Oct 2, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Oct 2, 2024
@mkilchhofer mkilchhofer added help wanted Community help wanted! and removed Stale labels Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Community help wanted!
Projects
None yet
Development

No branches or pull requests

2 participants