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

diff: Fix overlapping filenames #71923

Merged
merged 1 commit into from
Dec 11, 2018

Conversation

apelisse
Copy link
Member

The filename can overlap when multiple resources have the same name (but
obviously are of a different type). Include the name of the type in the
file name to prevent the overlap.

What type of PR is this?

/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #71920

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Fix overlapping filenames in diff if multiple resources have the same name.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Dec 10, 2018
@k8s-ci-robot k8s-ci-robot added area/kubectl sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Dec 10, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: apelisse

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 Dec 10, 2018
@towolf
Copy link
Contributor

towolf commented Dec 11, 2018

Disambiguating the name with the kind seems the right solution. Adding namespace would be even better, no? I can have kind: Service, name: test in multiple namespaces. Just saw, disambiguation is keyed with Version.Kind:Namespace.Name. Thanks!

And then I wonder, what you think the intended behaviour is, when I have duplicates of kind and name pairs.

In the cluster this is not possible, but on disk it is. Which dupe will be picked? It's not handling this case is it?

@towolf
Copy link
Contributor

towolf commented Dec 11, 2018

Version is sometimes converted to another storage version in etcd and is returned in another apiVersion. Will this lead to noisy diffs?

@apelisse
Copy link
Member Author

apelisse commented Dec 11, 2018

Version is sometimes converted to another storage version in etcd and is returned in another apiVersion. Will this lead to noisy diffs?

That should be irrelevant, because kube-apiserver returns just the version we're asking for (same as the version on disk)

@apelisse
Copy link
Member Author

And then I wonder, what you think the intended behaviour is, when I have duplicates of kind and name pairs.

Yeah, this problem is more general than just diff. I'm also less concerned about diff than I am about apply, because diff is not mutating. I think it deserves another issue if you want to see that use-case fixed.

I'm pretty sure that diff should behave like apply does: you want to see the changes as they are actually going to happen, and I think it is consistent today.

The filename can overlap when multiple resources have the same name (but
obviously are of a different type). Include the name of the type in the
file name to prevent the overlap.
@mengqiy
Copy link
Member

mengqiy commented Dec 11, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 11, 2018
@apelisse
Copy link
Member Author

/kind bug
/priority critical-urgent

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Dec 11, 2018
@k8s-ci-robot k8s-ci-robot removed the needs-kind Indicates a PR lacks a `kind/foo` label and requires one. label Dec 11, 2018
@k8s-ci-robot k8s-ci-robot merged commit 425b1ff into kubernetes:master Dec 11, 2018
group = fmt.Sprintf("%v.", obj.Info.Mapping.GroupVersionKind.Group)
}
return group + fmt.Sprintf(
"%v.%v:%v.%v",
Copy link
Member

Choose a reason for hiding this comment

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

Colons aren't cross-platform safe, are they?

k8s-ci-robot added a commit that referenced this pull request Dec 12, 2018
…23-upstream-release-1.13

Automated cherry pick of #71923: diff: Fix overlapping filenames
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. area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubectl diff -Rf (recursive mode) does not work
5 participants