kustomize icon indicating copy to clipboard operation
kustomize copied to clipboard

Line breaks on long strings with spaces

Open maxhomann opened this issue 6 years ago • 44 comments
trafficstars

When combining helm templates with kustomize overlays, a line break is inserted when the line is very long and contains spaces.

Tested versions: 2.0.1 and 2.0.3 Using test/base.yml:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: test
  labels:
    app.version: "{{ .Values.services.mariadb.app.version }}"
spec:
  template:
    spec:
      containers:
      - name: mariadb
        image: "thisIsAReallyLongRepositoryLinkThatResultsInALineBreakWhenBuildingWithKustomize/mariadb:{{ .Values.services.mariadb.image.version }}"

and test/kustomization.yml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- base.yml

results in

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app.version: '{{ .Values.services.mariadb.app.version }}'
  name: test
spec:
  template:
    spec:
      containers:
      - image: thisIsAReallyLongRepositoryLinkThatResultsInALineBreakWhenBuildingWithKustomize/mariadb:{{
          .Values.services.mariadb.image.version }}
        name: mariadb

Expected Behavior:

  • Line without line break
  • Also, the string/quoted value of the image name in base.yml is converted to an unqouted value on build while the app.version label is enclosed in single quotes. I would expect that either the quotes are not removed at all or the quoting behavior is constant

maxhomann avatar Apr 05 '19 08:04 maxhomann

I think if https://github.com/go-yaml/yaml/pull/455 gets merged that might be the signal to migrate to yaml.v3, and unlimited line lengths...

laverya avatar Apr 24 '19 00:04 laverya

This behavior is still in v3.0.1. Using the same input files, the output has line breaks:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app.version: '{{ .Values.services.mariadb.app.version }}'
  name: test
spec:
  template:
    spec:
      containers:
      - image: thisIsAReallyLongRepositoryLinkThatResultsInALineBreakWhenBuildingWithKustomize/mariadb:{{
          .Values.services.mariadb.image.version }}

maxhomann avatar Jul 12 '19 09:07 maxhomann

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Oct 10 '19 10:10 fejta-bot

Hi guys,

there is a workaround for this issue?

rchessa avatar Oct 17 '19 08:10 rchessa

Have the same issue here. Need to keep the formatting as is without breaking long lines. Any ideas?

kristofferahl avatar Nov 11 '19 14:11 kristofferahl

@kristofferahl, we worked around this by using:

attribute: |
  very long line

Not sure if this is semantically 100% equal, though. It mitigated the issue in our specific case.

kautsig avatar Nov 11 '19 15:11 kautsig

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

fejta-bot avatar Dec 11 '19 16:12 fejta-bot

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

fejta-bot avatar Jan 10 '20 17:01 fejta-bot

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Jan 10 '20 17:01 k8s-ci-robot

/reopen

laverya avatar May 13 '20 00:05 laverya

@laverya: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar May 13 '20 00:05 k8s-ci-robot

There's a fix in gopkg.in/yaml.v2, now released as v2.3.0 - I'll make a PR to update kustomize to this version. (basically, if the string doesn't have newline literals in it, v2.3.0 won't split the string over multiple lines when encoding things - previously it would wrap before 80 characters)

laverya avatar May 13 '20 00:05 laverya

Just validated, and 3.6.1 still exhibits this behavior:

kustomization.yaml

resources:
- deployment.yaml

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
spec:
  replicas: 1
  selector:
    matchLabels:
      component: test
  template:
    metadata:
      labels:
        component: test
    spec:
      containers:
        - name: test
          image: "test"
          env:
            - name: DATABASE_URL
              value: postgres://{{repl ConfigOption "database_user"}}:{{repl ConfigOption "database_password"}}@db.{{repl Namespace}}.svc.cluster.local:5432/db

yields this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
spec:
  replicas: 1
  selector:
    matchLabels:
      component: test
  template:
    metadata:
      labels:
        component: test
    spec:
      containers:
      - env:
        - name: DATABASE_URL
          value: postgres://{{repl ConfigOption "database_user"}}:{{repl ConfigOption
            "database_password"}}@db.{{repl Namespace}}.svc.cluster.local:5432/db
        image: test
        name: test
$ kustomize version
{Version:3.6.1 GitCommit:c97fa946d576eb6ed559f17f2ac43b3b5a8d5dbd BuildDate:2020-05-28T01:07:36+01:00 GoOs:darwin GoArch:amd64}

laverya avatar Jun 03 '20 16:06 laverya

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

fejta-bot avatar Jul 03 '20 17:07 fejta-bot

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Jul 03 '20 17:07 k8s-ci-robot

We should get a unit test in place that displays this behavior (or confirms that it's gone).

monopole avatar Aug 10 '20 19:08 monopole

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

fejta-bot avatar Sep 09 '20 19:09 fejta-bot

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Sep 09 '20 19:09 k8s-ci-robot

This is still an issue, with latest version of kustomize bundled with Argo CD 2.0.1. I use the kustomized-helm pattern, but kustomize corrupts the following

BEFORE

containers:
- name: createdb-{{ $index }}
  image: postgres:11-alpine # A relatively small official image that can run psql
  command:
    - sh
    - -c
    - >
        while ! pg_isready -U postgres -h {{ template "timescaledb.fullname" $ }}; do sleep 1; done;
        echo "${SQLCOMMAND}" | psql --file=- --echo-queries -d "${ACCESS_SVC_CONNSTR}" \
          --set ON_ERROR_STOP=1 \
          --set dbname="${DBNAME}"

AFTER

containers:
- name: createdb-{{ $index }}
  image: postgres:11-alpine # A relatively small official image that can run psql
  command:
    - sh
    - -c
    - >
        while ! pg_isready -U postgres -h {{ template "timescaledb.fullname" $ }}; do sleep 1; done;
        echo "${SQLCOMMAND}" | psql --file=- --echo-queries -d 
"${ACCESS_SVC_CONNSTR}" \

          --set ON_ERROR_STOP=1 \
          --set dbname="${DBNAME}"

WillooWisp avatar May 04 '21 13:05 WillooWisp

Still have this problem, even with kustomize v4.3.0. In my case it's when you have a patch file with a really long string as the replacement value.

hancockjt avatar Sep 22 '21 21:09 hancockjt

I see a note all the way back in https://github.com/kubernetes-sigs/kustomize/releases/tag/api%2Fv0.8.11 that forced line wrapping is supposed to no longer be present. Doesn't seem to be the case though, at least on 4.3.0 which we are currently using.

I can't find an issue/PR that explicitly states that this has been dealt with. Has it fallen through the cracks?

karlschriek avatar Feb 03 '22 10:02 karlschriek

/reopen

cprivitere avatar Mar 01 '22 16:03 cprivitere

@cprivite: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Mar 01 '22 16:03 k8s-ci-robot

please, reopen

kungfuchicken avatar Mar 10 '22 23:03 kungfuchicken

@maxhomann can you reopen this?

cprivitere avatar Mar 11 '22 15:03 cprivitere

I am still experiencing this with Kustomize version v4.5.2.

Please reopen this issue.

asankov avatar Mar 16 '22 15:03 asankov

@KnVerey @natasha41575 @yuwenma Sorry to ping you all, but we need some eyes on this from active owners/reviewers. Can you please re-open this issue? This is causing real problems today.

Example new user story would be building a yaml with an upstream open source project's yaml (like calico) as one of your bases that you don't have control over, but has really long lines (their description fields). You cannot use any version of kustomize after 4.0.4 if you want to use those upstream source files without modification.

cprivitere avatar Mar 23 '22 17:03 cprivitere

We can reopen this issue for tracking, but there's nothing really that we (kustomize) can do about it because it's a bug in the underlying go-yaml library.

natasha41575 avatar Mar 23 '22 17:03 natasha41575

@maxhomann: This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Mar 23 '22 17:03 k8s-ci-robot

We can reopen this issue for tracking, but there's nothing really that we (kustomize) can do about it because it's a bug in the underlying go-yaml library.

That's fine, but none of us (the people having the issue) know what that bug is or how to fix it or who to bug to get it fixed. It sounds like you do, so could you or someone you appoint champion this cause for us with the go-yaml community?

cprivitere avatar Mar 23 '22 17:03 cprivitere