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

kyaml/fn/framework ensures the annotation output format matches the input #4297

Merged
merged 7 commits into from Nov 19, 2021

Conversation

mengqiy
Copy link
Member

@mengqiy mengqiy commented Nov 17, 2021

If the input only contains legacy format anntations (path, index, id), the
output will be the same.

ALLOW_MODULE_SPAN

…nput

If the input only contains legacy format anntations (path, index, id), the
output will be the same.
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 17, 2021
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 17, 2021
@mengqiy
Copy link
Member Author

mengqiy commented Nov 17, 2021

/cc @natasha41575 @droot

Copy link
Contributor

@natasha41575 natasha41575 left a comment

Choose a reason for hiding this comment

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

minor comments

IIUC, this PR is making it so that the functions will be responsible for knowing which annotations to use based on the input?

kyaml/kio/kio.go Show resolved Hide resolved
kyaml/kio/kio.go Outdated Show resolved Hide resolved
kyaml/kio/kioutil/kioutil.go Show resolved Hide resolved
Copy link
Contributor

@droot droot left a comment

Choose a reason for hiding this comment

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

I am not super familiar with the annotation machinery so would leave @natasha41575 and you to decide the final approval.

One note: overall the code for annotations seems to have become very complex. Not sure if there is way to reduce this complexity.

kyaml/fn/framework/framework.go Outdated Show resolved Hide resolved
kyaml/kio/kio.go Outdated Show resolved Hide resolved
@mengqiy
Copy link
Member Author

mengqiy commented Nov 18, 2021

/hold
I'm doing more testing before merging.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 18, 2021
@k8s-ci-robot
Copy link
Contributor

@mengqiy: 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.

@mengqiy
Copy link
Member Author

mengqiy commented Nov 18, 2021

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Nov 18, 2021
kyaml/kio/kio.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 19, 2021
@mengqiy
Copy link
Member Author

mengqiy commented Nov 19, 2021

@droot I changed it to use id as the key identify the objects. If we can't find id, we just skip it. kpt fn render and eval always set id, but kpt fn source don't. But it should be a big deal.

@@ -293,6 +293,8 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: foo
annotations:
internal.config.k8s.io/annotations-migration-resource-id: '1'
Copy link
Member Author

Choose a reason for hiding this comment

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

This is part of the command test.
I'm not sure why it will need this change to pass.

@k8s-ci-robot k8s-ci-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 19, 2021
kyaml/fn/framework/framework.go Show resolved Hide resolved
kyaml/kio/kio.go Show resolved Hide resolved
@natasha41575
Copy link
Contributor

You can ignore the presubmit failure

@natasha41575
Copy link
Contributor

/retest

@@ -63,6 +63,9 @@ xxx:
apiVersion: foo/v1
kind: Bar
xxx:
metadata:
annotations:
internal.config.k8s.io/annotations-migration-resource-id: '0'
Copy link
Contributor

Choose a reason for hiding this comment

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

@KnVerey this is something we should discuss before the next release of the api module to decide if we are okay with the change.

What's happening is to migrate the annotations, kyaml/kio adds a new annotation to help keep track of the migration, then runs the filter, then removes the annotation. In the case that the filter errors, it includes in its error message the contents of the failing RNode. Unfortunately that means that this annotation gets included in the error message before we can remove it.

Because this is blocking kpt and doesn't show up in the output of kustomize (we've added the annotation to kustomize's BuildAnnotations so that it will get removed), I'm approving this PR to go in so that they can use an unreleased version of kyaml until we have a better solution/decision.

No changes need to be made if we decide we're okay with these annotations showing up in the output of api and cmd/config tests.

One option I was considering was to change the error message for the filters to just have the object's GVKNN, rather than the entire content of the RNode.

Another option is to clear the annotation in the filter functions before generating the error message, but we'd need to do that in several places, which doesn't seem ideal to me.

@natasha41575
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 19, 2021
@mengqiy
Copy link
Member Author

mengqiy commented Nov 19, 2021

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 19, 2021
@natasha41575
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mengqiy, 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 19, 2021
@natasha41575 natasha41575 merged commit d113424 into kubernetes-sigs:master Nov 19, 2021
@mengqiy mengqiy deleted the anno branch November 19, 2021 21:40
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants