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

error converting YAML to JSON: yaml: line 22: did not find expected key #13044

Open
Marwen-TAALLAH opened this issue May 17, 2024 · 7 comments
Open

Comments

@Marwen-TAALLAH
Copy link

Marwen-TAALLAH commented May 17, 2024

I am trying to create a redis helm chart via a module within a github workflow. The problem seems to be in the helm-values.yaml file in the module. It's an error converting YAML to JSON: yaml.

I have a workflow in github that executes a command that terraform apply a module that is in another github repo, in this module I have a helm-values.yaml that looks like this:

architecture: standalone

fullnameOverride: ${redis_deployment_name}
auth:
  password: ${redis_admin_password}

master:
  ${ indent(2, redis_affinity) }
  ${ indent(2, redis_nodeSelector) }
  ${ indent(2, redis_default_tolerations) }
  persistence:
    enabled: false
  resources:
    limits:
      cpu: 350m
      memory: 700Mi
    requests:
      cpu: 100m
      memory: 256Mi

pdb:
  enabled: true

redisStreamEnabled: true

but I get this error:

 Error: ---> error converting YAML to JSON: yaml: line 19: did not find expected key architecture: standalone

I changed the manifest file to look like this:

## @param architecture; architecture. Allowed: `standalone` or `replication`
##
architecture: standalone

fullnameOverride: ${redis_deployment_name}
auth:
  password: ${redis_admin_password}

master:
  ${ indent(2, redis_affinity) }
  ${ indent(2, redis_nodeSelector) }
  ${ indent(2, redis_default_tolerations) }
  persistence:
    enabled: false
  resources:
    limits:
      cpu: 350m
      memory: 700Mi
    requests:
      cpu: 100m
      memory: 256Mi
pdb:
  enabled: true

redisStreamEnabled: true

But now i'm getting this error:

Error: ---> error converting YAML to JSON: yaml: line 21: did not find expected key ## @param architecture; architecture. Allowed: `standalone` or `replication`

So i changed one more time to this:

---
# Parameter info: architecture. Allowed values: `standalone` or `replication`

architecture: standalone

fullnameOverride: ${redis_deployment_name}
auth:
  password: ${redis_admin_password}

master:
  ${ indent(2, redis_affinity) }
  ${ indent(2, redis_nodeSelector) }
  ${ indent(2, redis_default_tolerations) }
  persistence:
    enabled: false
  resources:
    limits:
      cpu: 350m
      memory: 700Mi
    requests:
      cpu: 100m
      memory: 256Mi

pdb:
  enabled: true

redisStreamEnabled: true

But now I get this error:

Error: ---> error converting YAML to JSON: yaml: line 22: did not find expected key ---
│ # Parameter info: architecture. Allowed values: `standalone` or `replication`
@yxxhero
Copy link
Member

yxxhero commented May 18, 2024

@Marwen-TAALLAH please format your code by code.

@Marwen-TAALLAH
Copy link
Author

@Marwen-TAALLAH please format your code by code.

Done !

@banjoh
Copy link

banjoh commented May 20, 2024

@Marwen-TAALLAH is there a step to process the values.yaml file first before passing it to helm, or is the file passed in as-is in the description? If so, I think helm will report an error because that file does not look like valid YAML

master:
  ${ indent(2, redis_affinity) }
  ${ indent(2, redis_nodeSelector) }
  ${ indent(2, redis_default_tolerations) }
  persistence:
    enabled: false

Specifically, the master value is a mixture of a map/dictionary and a scaler (string).

I'm not aware of helm supporting templating for the values file

@Marwen-TAALLAH
Copy link
Author

@Marwen-TAALLAH is there a step to process the values.yaml file first before passing it to helm, or is the file passed in as-is in the description? If so, I think helm will report an error because that file does not look like valid YAML

master:
  ${ indent(2, redis_affinity) }
  ${ indent(2, redis_nodeSelector) }
  ${ indent(2, redis_default_tolerations) }
  persistence:
    enabled: false

Specifically, the master value is a mixture of a map/dictionary and a scaler (string).

I'm not aware of helm supporting templating for the values file

@banjoh The values.yaml file is causing a problem only when the redis chart is called as a module, when executinf the terraform apply locally, the file doesn't cause an issue !!

@banjoh
Copy link

banjoh commented May 20, 2024

Are you able to create a reproducer chart, say by creating a chart using helm create foo then adding your values to the default values file? If you are using subcharts, then setup your test accordingly. It will be easier to troubleshoot the issue if terraform and any other external tool is absent.

@Marwen-TAALLAH
Copy link
Author

@banjoh I am able to create the chart with helm directly without terraform, I am also able to create the chart with terraform, all of that with the exact same values.yaml I have provided.
The problem occured when I tried to call the terraform code as a module.

@banjoh
Copy link

banjoh commented May 20, 2024

@Marwen-TAALLAH to rule out terraform as being the problem here, could you provide the helm commands that terraform successfully templates your helm chart with?

I cannot run terraform, so I'm not able to ascertain whether this values file is valid as you say.

Am looking to see the output of helm template <your-chart> --values values.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants