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

Bug: Unterminated template string #1274

Open
bernardhalas opened this issue Mar 14, 2024 · 6 comments
Open

Bug: Unterminated template string #1274

bernardhalas opened this issue Mar 14, 2024 · 6 comments
Labels
bug Something isn't working good first issue Good for newcomers groomed Task that everybody agrees to pass the gatekeeper

Comments

@bernardhalas
Copy link
Member

Current Behaviour

Getting the following error:

terraformer-8495c979b8-c8j59 terraformer 2024-03-14T02:34:09Z WRN ../go/internal/command/cmd.go:145 > Retrying command terraform apply --auto-approve --parallelism=8... (2/5) module=terraformer
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       ╷
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │ Error: Invalid multi-line string
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │ 
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │   on vienna-2-fewhjx0-azure-1-provider.tf line 3, in provider "azurerm":
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │    3:   subscription_id = "80839dc0-2dcc-4ed1-8c8b-f208da773517
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │    4: "
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │ 
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │ Quoted strings may not be split over multiple lines. To produce a
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │ multi-line string, either use the \n escape to represent a newline
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │ character or use the "heredoc" multi-line template syntax.
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       ╵
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       ╷
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │ Error: Unterminated template string
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │ 
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │   on vienna-2-fewhjx0-azure-1-provider.tf line 3, in provider "azurerm":
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │    3:   subscription_id = "80839dc0-2dcc-4ed1-8c8b-f208da773517
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │    4: "
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │ 
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       │ No closing marker was found for the string.
terraformer-8495c979b8-c8j59 terraformer vienna-2-fewhjx0       ╵
terraformer-8495c979b8-c8j59 terraformer 2024-03-14T02:34:09Z WRN ../go/internal/command/cmd.go:92 > Error encountered while executing terraform apply --auto-approve --parallelism=8 : exit status 1 module=terraformer

Expected Behaviour

The input manifest should be processed successfully

Steps To Reproduce

Applying the manifest:

apiVersion: claudie.io/v1beta1
kind: InputManifest
metadata:
  name: vienna-2
  namespace: claudie
  labels:
    app.kubernetes.io/part-of: claudie
spec:
  providers:
    - name: azure-1
      providerType: azure
      secretRef:
        name: azure-secret-1
        namespace: claudie
    - name: oci-1
      providerType: oci
      secretRef:
        name: oci-secret-1
        namespace: claudie
  nodePools:
    dynamic:
      - name: control-azure
        providerSpec:
          name: azure-1
          region: West Europe
          zone: "1"
        count: 2
        serverType: Standard_B2s
        image: Canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts:22.04.202212120
      - name: compute-1-azure
        providerSpec:
          name: azure-1
          region: Germany West Central
          zone: "1"
        count: 2
        serverType: Standard_B2s
        image: Canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts:22.04.202212120
        storageDiskSize: 50
      - name: compute-2-azure
        providerSpec:
          name: azure-1
          region: West Europe
          zone: "1"
        count: 2
        serverType: Standard_B2s
        image: Canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts:22.04.202212120
        storageDiskSize: 50
  kubernetes:
    clusters:
      - name: vienna-2
        version: v1.26.0
        network: 192.168.2.0/24
        pools:
          control:
            - control-azure
          compute:
            - compute-2-azure
            - compute-1-azure
@bernardhalas bernardhalas added the bug Something isn't working label Mar 14, 2024
@cloudziu
Copy link
Contributor

I now see where the issue is, the provider configuration - after the subscription ID there is a new line

@Despire
Copy link
Contributor

Despire commented Mar 19, 2024

@bernardhalas, this is more of a user error, you have created a secret that has a whitespace (newline) at the end of the subscription ID (input manifest that you posted is ok syntactically).

To minimize this kind of error we could trim the whitespace when reading the secrets

@bernardhalas bernardhalas self-assigned this Mar 22, 2024
@bernardhalas bernardhalas added the groomed Task that everybody agrees to pass the gatekeeper label Mar 22, 2024
@bernardhalas
Copy link
Member Author

I'll validate if the newline was coming from the azure provider secret. @Despire thanks for the hint.

@Despire
Copy link
Contributor

Despire commented Apr 2, 2024

any updates @bernardhalas ?

@Despire
Copy link
Contributor

Despire commented May 17, 2024

This can be reproduced for examply by executing:

echo "....secret...." | base64

to correctly base64 the secret without the implicit newline from echo:

echo -n "...secret..." | base64

@bernardhalas
Copy link
Member Author

bernardhalas commented May 17, 2024

Hi, this was indeed a problem on the side of a user. While using Claudie recently it appeared a few more times.
I'd like to propose trimming the secret values, to ensure copy/paste whitespace and newline chars don't create errors which are difficult to fix.

Btw, in case someone comes across an error and suspects the issue being caused by a trailing newline char, this helps:

kubectl get secret name-of-secret -o go-template='
{{range $k,$v := .data}}{{printf "%s: " $k}}{{if not $v}}{{$v}}{{else}}{{$v | base64decode}}{{end}}{{"\n"}}{{end}}'

(ref)

@bernardhalas bernardhalas removed their assignment May 17, 2024
@Despire Despire added the good first issue Good for newcomers label May 17, 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 good first issue Good for newcomers groomed Task that everybody agrees to pass the gatekeeper
Projects
None yet
Development

No branches or pull requests

3 participants