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 broken Local() logic #61227

Merged
merged 1 commit into from
May 16, 2018
Merged

Conversation

apelisse
Copy link
Member

Local and Live functions where doing and returning the same thing,
giving empty results by default. Fix the local function by copying the
objects before fetching the live version.

What this PR does / why we need it: Diff prints empty output by default. Fixes it.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #61145

Special notes for your reviewer:

Release note:

NONE

@apelisse apelisse requested a review from smarterclayton March 15, 2018 17:09
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 15, 2018
@k8s-ci-robot k8s-ci-robot requested review from dims and ericchiang March 15, 2018 17:10
@mengqiy
Copy link
Member

mengqiy commented Mar 16, 2018

/retest

@smarterclayton
Copy link
Contributor

Test case so this doesn't revert in future?

@apelisse
Copy link
Member Author

I probably could but:

  1. I'm not sure how to mock/fake/test the interaction with the resourcebuilder,
  2. I don't want to invest too much time working on this, since it will have to change with server-side apply.

@toothbrush
Copy link

Is there any chance this will make it into a minor 1.9 or 1.10 release? I'm really keen on this feature, and although i realise the implementation will have to change soon anyway, it'd be really nice to have in the interim.

@apelisse
Copy link
Member Author

@toothbrush Actually, it won't have to change that much, so we should find a path forward at this point. I don't really have time to figure out how to test this, but I'd really like to get this merged too.

@smarterclayton Any suggestions on how we can test this? :-)

@smarterclayton
Copy link
Contributor

Why is mocking required? I was expecting a test-cmd scenario that prevents this regressing when we have server side apply

@apelisse
Copy link
Member Author

Why is mocking required? I was expecting a test-cmd scenario that prevents this regressing when we have server side apply

Sounds good. Thanks!

@dims
Copy link
Member

dims commented Apr 30, 2018

/uncc @dims

@k8s-ci-robot k8s-ci-robot removed the request for review from dims April 30, 2018 12:34
@toothbrush
Copy link

I wish i could contribute more to this discussion than simply "how are we doing?" but i'm afraid that's all i've got! Maybe i should try my hand at constructing the test command? I would need pointers from the experts, though.

@apelisse
Copy link
Member Author

I'll work on this tomorrow

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 14, 2018
@apelisse
Copy link
Member Author

apelisse commented May 14, 2018

@smarterclayton I've added a test. It's not the best test in the world, but it would have caught this bug.

@apelisse
Copy link
Member Author

/retest

@apelisse apelisse force-pushed the fix-diff branch 2 times, most recently from 28683b5 to a671add Compare May 15, 2018 22:03
@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 May 15, 2018
info.Object = nil
remote, err := dl.Download(info)
if err != nil {
glog.Warningf("failed to download remote object: %v", err)
Copy link
Contributor

@smarterclayton smarterclayton May 16, 2018

Choose a reason for hiding this comment

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

Nit but human warnings aren't via glog in CLIs, we use fmt.Fprintf(stdErr, "warning: ...")

glog is terrible for humans.

}

func (d *Downloader) Download(info *resource.Info) (*unstructured.Unstructured, error) {
gvk := info.Object.GetObjectKind().GroupVersionKind()
Copy link
Contributor

Choose a reason for hiding this comment

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

@deads2k is any of this impacted by your mapper changes?

Copy link
Contributor

Choose a reason for hiding this comment

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

@deads2k is any of this impacted by your mapper changes?

This should be ok. The way this is used you always end up with a GVK.

@@ -263,6 +266,7 @@ type Object interface {
// InfoObject is an implementation of the Object interface. It gets all
// the information from the Info object.
type InfoObject struct {
Remote *unstructured.Unstructured
Copy link
Contributor

Choose a reason for hiding this comment

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

adding remote here as unstructured explicitly seems inconsistent. I would have expected

Remote runtime.Unstructured

at a minimum.

Local and Live functions where doing and returning the same thing,
giving empty results by default. Fix the local function by copying the
objects before fetching the live version.
@smarterclayton
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 16, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: apelisse, smarterclayton

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 May 16, 2018
@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 7d9725e into kubernetes:master May 16, 2018
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. release-note-none Denotes a PR that doesn't merit a release note. 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.

kubectl diff feature always returns empty
8 participants