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

Multi-source application breaks CLI usage, even with single source #274

Closed
headyj opened this issue May 11, 2023 · 6 comments · Fixed by #289
Closed

Multi-source application breaks CLI usage, even with single source #274

headyj opened this issue May 11, 2023 · 6 comments · Fixed by #289
Labels
bug Something isn't working upstream-dependency Issue depends on changes being made to upstream dependencies (e.g. `argoproj/argo-cd`)

Comments

@headyj
Copy link

headyj commented May 11, 2023

Terraform Version, ArgoCD Provider Version and ArgoCD Version

Terraform version: v1.3.7
ArgoCD provider version: 5.3.0
ArgoCD version: v2.6.7

Affected Resource(s)

  • argocd_application

Steps to Reproduce

  1. Run a terraform apply on an argocd_application resource
  2. source field is now sources, even if you have a single source in your application
  3. run a argocd sync command using the cli (e.g. `argocd app sync --grpc-web my-app)
  4. the CLI returnes an error: time="2023-05-11T07:39:19Z" level=fatal msg="argocd cli does not work on multi-source app"

Expected Behavior

A single source application should still be added in the source field, not in sources

Before 5.3:

 [...]
    source:
        path: my-app
        [...]
    sources: []

Now:

 [...]
    source:
      repoUrl: ''
    sources:
        - path: my-app
          [..]

Link to ArgoCD cli issue: argoproj/argo-cd#12318

@headyj headyj added the bug Something isn't working label May 11, 2023
@onematchfox
Copy link
Collaborator

Hi @headyj,

I'm a little confused by this one. You seem to be mixing references to both the argocd CLI and the Terraform provider. For example, you mention:

  1. source field is now sources, even if you have a single source in your application

This is not true. There is no sources attribute in the argocd_application resource in the provider. There is only the source block, which, as the documentation indicates, can be specified one or more times. So, for an application with multiple sources, you would simply specify multiple source blocks.

  1. run a argocd sync command using the cli (e.g. `argocd app sync --grpc-web my-app)
  2. the CLI returnes an error: time="2023-05-11T07:39:19Z" level=fatal msg="argocd cli does not work on multi-source app"

Not sure what this has to do with the provider.

Finally, under the expected behaviour, you provide YAML config rather than HCL, so once again, I'm a bit confused about whether you are referring to the CLI or the Terraform provider.

@onematchfox onematchfox added the needs-more-info Waiting on additional information from issue/PR reporter. label May 16, 2023
@headyj
Copy link
Author

headyj commented May 22, 2023

@onematchfox that's because the problem occurs when you use the CLI, once you applied your changes using the terraform provider, so indeed it still works.

I know there is no sources field in the provider, but in the Application CRD, there is both source field (https://github.com/argoproj/argo-cd/blob/master/manifests/crds/application-crd.yaml#L3733) and sources (https://github.com/argoproj/argo-cd/blob/master/manifests/crds/application-crd.yaml#L1128). The new version of the provider is filling the sources field, even for a single source application, which breaks the CLI Usage

You can reproduce the full problem the following way:

  • Run a terraform apply on an argocd_application resource using 4.3 version
  • Check the Application object created in Kubernetes, and save it somewhere on your computer
  • Run a argocd sync command using the cli (e.g. argocd app sync --grpc-web my-app)
  • Everything works fine

Now:

  • Run a terraform apply on an argocd_application resource using 5.3 version
  • Check the updated Application object in Kubernetes and compare it to previous one, the sources field is now filled, instead of source before
  • Run a argocd sync command using the cli (e.g. argocd app sync --grpc-web my-app)
  • the CLI now returnes an error: time="2023-05-11T07:39:19Z" level=fatal msg="argocd cli does not work on multi-source app", which is linked to this issue on ArgoCD side: argocd cli needs to work on multi-source apps argoproj/argo-cd#12318

So until ArgoCD issue is fixed, the provider should still fill the source field of the CRD instead of sources for a single sourced application

I hope it's a bit more clear now

@onematchfox onematchfox added upstream-dependency Issue depends on changes being made to upstream dependencies (e.g. `argoproj/argo-cd`) and removed needs-more-info Waiting on additional information from issue/PR reporter. labels May 22, 2023
@onematchfox
Copy link
Collaborator

OK. I see the issue. I'm inclined to say the issue needs to be addressed in the ArgoCD CLI, but if someone wants to open a PR to change the provider to work around this issue then I won't oppose it.

@headyj
Copy link
Author

headyj commented May 22, 2023

Indeed, I agree the problem is mostly on the ArgoCD CLI side, but I don't feel like it's going to be fixed in a near future unfortunately.

On our side we strongly depends on both this provider and the CLI in our CI/CD process, so I cannot update the provider currently

@roccolangeweg
Copy link

roccolangeweg commented May 26, 2023

Chiming in on this one: we have recently updated our terraform provider and the sources block is giving issues versus the source it was before, because argocd-image-updater does not work when sources is used instead of source. Is there any way we can decide either to use the source or sources array?

argoproj-labs/argocd-image-updater#558

@onematchfox
Copy link
Collaborator

Is there any way we can decide either to use the source or sources array?

I have just opened a PR whereby the provider will revert to setting source for all applications that only have a single source defined. I.e. we will only set sources when multiple sources have been defined. Hopefully this will resolve the issues folks have been having.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream-dependency Issue depends on changes being made to upstream dependencies (e.g. `argoproj/argo-cd`)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants