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

DO NOT MERGE: demonstrate required changes for yaml update #4004

Closed
wants to merge 5 commits into from

Conversation

natasha41575
Copy link
Contributor

@natasha41575 natasha41575 commented Jun 17, 2021

used the fork of yaml from this PR go-yaml/yaml#750 and updated the kyaml tests so that they pass

EDIT: Now points to the fork in go-yaml/yaml#753

tracking issue: #3946

this PR demonstrates what impact the change would have in kyaml

cc @mikebz

ALLOW_MODULE_SPAN

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: natasha41575

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 17, 2021
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 17, 2021
@natasha41575 natasha41575 added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 17, 2021
@natasha41575 natasha41575 changed the title DO NOT MERGE: show required changes for yaml update DO NOT MERGE: demonstrate required changes for yaml update Jun 17, 2021
@k8s-ci-robot
Copy link
Contributor

@natasha41575: This PR has multiple commits, and the default merge method is: merge.
You can request commits to be squashed using the label: tide/merge-method-squash

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.

kyaml/yaml/alias.go Outdated Show resolved Hide resolved
@KnVerey
Copy link
Contributor

KnVerey commented Jun 17, 2021

Are any changes required outside kyaml? Can you push the replace statement so that we can see the test suite state too?

@natasha41575 natasha41575 force-pushed the TestYaml branch 2 times, most recently from a04296e to 9d3235f Compare June 17, 2021 20:39
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 17, 2021
@kubernetes-sigs kubernetes-sigs deleted a comment from k8s-ci-robot Jun 17, 2021
@natasha41575
Copy link
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 17, 2021
@natasha41575 natasha41575 force-pushed the TestYaml branch 2 times, most recently from ddd5399 to a2e7623 Compare June 17, 2021 21:52
Copy link
Contributor

@KnVerey KnVerey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having examined all the changes in this PR, here's what I conclude so far.

There are two things that need to be addressed on @mikebz PR:

There are also two potentially concerning changes from the intermediate diff:

api/krusty/configmaps_test.go Outdated Show resolved Hide resolved
cmd/config/internal/commands/cmdwrap_test.go Show resolved Hide resolved
cmd/config/internal/commands/merge3_test.go Show resolved Hide resolved
cmd/config/internal/commands/source_test.go Show resolved Hide resolved
kyaml/kio/pkgio_reader_test.go Show resolved Hide resolved
kyaml/yaml/match_test.go Outdated Show resolved Hide resolved
@natasha41575 natasha41575 force-pushed the TestYaml branch 4 times, most recently from 9f2bbfc to 9377267 Compare June 21, 2021 23:53
api/go.sum Outdated Show resolved Hide resolved
kyaml/yaml/match_test.go Outdated Show resolved Hide resolved
@natasha41575
Copy link
Contributor Author

natasha41575 commented Jun 22, 2021

Examples of what happens now:

  1. Default (indent=2, sequence indents disabled):
apiVersion: config.kubernetes.io/v1alpha1
kind: ResourceList
items:
- kind: Deployment
  apiVersion: v1
  metadata:
    name: tester
    namespace: default
  spec:
    replicas: 0
results:
  name: Incompatible config
  items:
  - message: bad value for replicas
    severity: error
    resourceRef:
      apiVersion: v1
      kind: Deployment
      name: tester
      namespace: default
    field:
      path: .spec.Replicas
      currentValue: "0"
      suggestedValue: "3"
    file:
      path: /path/to/deployment.yaml
  - message: some error
    severity: error
  1. Default indent (=2), EnableSeqIndent():
apiVersion: config.kubernetes.io/v1alpha1
kind: ResourceList
items:
  - kind: Deployment
    apiVersion: v1
    metadata:
      name: tester
      namespace: default
    spec:
      replicas: 0
results:
  name: Incompatible config
  items:
    - message: bad value for replicas
      severity: error
      resourceRef:
        apiVersion: v1
        kind: Deployment
        name: tester
        namespace: default
      field:
        path: .spec.Replicas
        currentValue: "0"
        suggestedValue: "3"
      file:
        path: /path/to/deployment.yaml
    - message: some error
      severity: error

Note: the above is the same output that you get if you use yaml.v3 at head with SetIndent(2)

  1. SetIndent(4), use default sequence indent (disabled sequence indents)
apiVersion: config.kubernetes.io/v1alpha1
kind: ResourceList
items:
  - kind: Deployment
    apiVersion: v1
    metadata:
        name: tester
        namespace: default
    spec:
        replicas: 0
results:
    name: Incompatible config
    items:
      - message: bad value for replicas
        severity: error
        resourceRef:
            apiVersion: v1
            kind: Deployment
            name: tester
            namespace: default
        field:
            path: .spec.Replicas
            currentValue: "0"
            suggestedValue: "3"
        file:
            path: /path/to/deployment.yaml
      - message: some error
        severity: error
  1. SetIndent(4) and EnableSeqIndent():
apiVersion: config.kubernetes.io/v1alpha1
kind: ResourceList
items:
    - kind: Deployment
      apiVersion: v1
      metadata:
        name: tester
        namespace: default
      spec:
        replicas: 0
results:
    name: Incompatible config
    items:
        - message: bad value for replicas
          severity: error
          resourceRef:
            apiVersion: v1
            kind: Deployment
            name: tester
            namespace: default
          field:
            path: .spec.Replicas
            currentValue: "0"
            suggestedValue: "3"
          file:
            path: /path/to/deployment.yaml
        - message: some error
          severity: error

Note: the above is the same output that you get if you use yaml.v3 at head with SetIndent(4)

kyaml/yaml/alias.go Outdated Show resolved Hide resolved
@natasha41575 natasha41575 force-pushed the TestYaml branch 2 times, most recently from f838e1c to 95a6b76 Compare June 22, 2021 20:35
@natasha41575 natasha41575 removed the request for review from justinsb June 22, 2021 23:49
@natasha41575 natasha41575 force-pushed the TestYaml branch 2 times, most recently from 40d721f to c63d7a3 Compare June 23, 2021 01:24
@KnVerey
Copy link
Contributor

KnVerey commented Jun 25, 2021

Awesome work on this! No concerns with what's left in the diff now.

@@ -169,8 +169,8 @@ items:
name: test
app: nginx
ports:
# This i the port.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are reordered here. Why?

Copy link
Contributor

@KnVerey KnVerey Jun 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bug fix. If you look at the input fixture above, the comments are in the new position, not the old:

- apiVersion: v1
  kind: Service
  metadata:
    name: test
    labels:
      app: nginx
      name: test
  spec:
    ports:
    # This i the port.
    - port: 8080
      targetPort: 8080
      name: http
    selector:
      app: nginx
      name: test

@phanimarupaka
Copy link
Contributor

phanimarupaka commented Jun 30, 2021

@natasha41575 I tried your fork and here are the couple of issues I noticed.

  1. Head comments are being deleted.
    In the example I tried, there is --- after head comment which makes the parse think it is empty node and drops the comment. I think this is expected and nothing much can be done.
  2. Multi-line strings are converted to single line. I think there is already an issue in go-yaml about this.

Can you please verify and confirm?

@KnVerey
Copy link
Contributor

KnVerey commented Jun 30, 2021

Multi-line strings are converted to single line. I think there is already an issue in go-yaml about this.

Are you referring to the changes visible in this PR? If so, the strings are not multi-line in the input. Previously, go-yaml wrapped after a certain string length, and the change is that it intentionally stopped doing that: go-yaml/yaml#572. Natasha and I discussed whether this means we need a new major version of Kustomize, but she found a previous case where essentially the same thing changed in a minor release in the past. If you're referring to something else, please provide an example.

Head comments are being deleted. In the example I tried, there is --- after head comment which makes the parse think it is empty node and drops the comment. I think this is expected and nothing much can be done.

I agree that's what I'd expect: if there are comments before a --- document header, then they technically belong to a previous empty document and will be dropped. Did this behave differently with previous versions of kyaml?

@natasha41575
Copy link
Contributor Author

natasha41575 commented Jun 30, 2021

The commits here were merged in #4013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants