Terraform-provider-helm: Multiple helm_repository data providers overwrite eachother

Created on 3 May 2019  路  8Comments  路  Source: hashicorp/terraform-provider-helm

Terraform Version

Terraform v0.11.13

  • provider.helm v0.9.0
  • provider.kubernetes v1.6.2
  • provider.local v1.2.1
  • provider.null v2.1.1
  • provider.tls v1.2.0

Affected Resource(s)

  • helm_repository

Terraform Configuration Files

data "helm_repository" "incubator" {
  name = "some_chart"
  url  = "https://kubernetes-charts-incubator.storage.googleapis.com/"
}

data "helm_repository" "stable" {
  name = "another_chart"
  url  = "https://kubernetes-charts.storage.googleapis.com/"
}

Expected Behavior

The repositories.yaml contains both entries.

Actual Behavior

The repositories.yaml will only contain one of the entries.

Steps to Reproduce

  1. terraform apply

Most helpful comment

Thx, @jpreese, I'll try to reproduce the issue with a base repositories yaml file

All 8 comments

I'm afraid I don't understand very well the issue. Can you post a more detailed example/logs? I have tf files with multiple repositories working without any apparent issue, repositories.yaml in the $HOME/.helm containing multiple entries

Sure, I'll get a simple scenario created and post some logs when I get to work here in a moment. In your scenario, have you started from a base repositories.yaml?

It does work if the repository already exists in the repositories.yaml file. The problem, for me, was when it actually needed to do an add.

@sryabkov in #163 also seems to have this issue.

Steps:

  1. Start with the base repositories.yaml (from helm init --client-only) and/or just make sure that you dont already have the repository that you've defined in your provider.

Mine looks like this for this test case

apiVersion: v1
generated: "2019-04-09T18:32:00.6458817-04:00"
repositories:
- caFile: ""
  cache: C:\Users\jreese\.helm\repository\cache\stable-index.yaml
  certFile: ""
  keyFile: ""
  name: stable
  password: ""
  url: https://kubernetes-charts.storage.googleapis.com
  username: ""
- caFile: ""
  cache: C:\Users\jreese\.helm\repository\cache\local-index.yaml
  certFile: ""
  keyFile: ""
  name: local
  password: ""
  url: http://127.0.0.1:8879/charts
  username: ""
  1. Setup the tf configs.

Here is my entire terraform config (main.tf)

provider "helm" {
  version            = "~> 0.9"
}

data "helm_repository" "stable" {
  name = "another_chart"
  url  = "https://kubernetes-charts.storage.googleapis.com/"
}

data "helm_repository" "incubator" {
  name = "some_chart"
  url  = "https://kubernetes-charts-incubator.storage.googleapis.com/"
}
  1. Run terraform apply

The result will be that only one of them is added. Note that if you have the notepad doc open it might show both briefly, but it is then overwritten shortly after.

Running config
image

Doc asks if you want to reload, upon reloading, shows the second entry:
image

ANOTHER reload request:
image

Final state of the config after the apply finishes:
image

TF_LOG output
https://pastebin.com/pXjBp5q8

Thx, @jpreese, I'll try to reproduce the issue with a base repositories yaml file

Classic data race, I have the same issue, my current workaround is:

terraform apply -parallelism=1

which is, of course, doesn't scale as well, but at least is correct.

@bonifaido I guess you meant

terraform plan -parallelism=1

isn't it?

It works in both cases, I'm working around the referenced repo not found issue with this.

Thx @pdecat for providing great tests to #272

Was this page helpful?
0 / 5 - 0 ratings