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

Bug: kpt diff 3way "extra operand" error #1378

Closed
karlkfi opened this issue Jan 21, 2021 · 9 comments
Closed

Bug: kpt diff 3way "extra operand" error #1378

karlkfi opened this issue Jan 21, 2021 · 9 comments
Assignees
Labels
area/pkg customer deep engagement triaged Issue has been triaged by adding an `area/` label

Comments

@karlkfi
Copy link
Contributor

karlkfi commented Jan 21, 2021

$ kpt pkg diff --diff-type=3way
/usr/bin/diff: extra operand '/tmp/kpt-386194509'
/usr/bin/diff: Try '/usr/bin/diff --help' for more information.
error: exit status 2

Sorry, I don't have a reproducable example on-hand now, but I don't think it should be possible for kpt to send "extra operands" to diff. Seems like a failure for kpt to validate the diff command inputs properly.

@mikebz mikebz added area/pkg customer deep engagement triaged Issue has been triaged by adding an `area/` label labels Jan 21, 2021
@mikebz
Copy link
Contributor

mikebz commented Jan 21, 2021

I am going to set it up as triaged for now, but obviously no example makes it hard to do the investigation. If it happens again please see if this is something you can share with the team. Thank you for reporting the bug 🙇

@karlkfi
Copy link
Contributor Author

karlkfi commented Jan 22, 2021

I think the diff tool in Cloud Shell doesn't support 3way diffs. It's complaining because it only takes 2 files as arguments, not 3.

$ diff --help
Usage: diff [OPTION]... FILES
Compare FILES line by line.

...

FILES are 'FILE1 FILE2' or 'DIR1 DIR2' or 'DIR FILE' or 'FILE DIR'.
If --from-file or --to-file is given, there are no restrictions on FILE(s).
If a FILE is '-', read standard input.
Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.

Report bugs to: bug-diffutils@gnu.org
GNU diffutils home page: <https://www.gnu.org/software/diffutils/>
General help using GNU software: <https://www.gnu.org/gethelp/>
$ diff -version
diff (GNU diffutils) 3.7
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Paul Eggert, Mike Haertel, David Hayes,
Richard Stallman, and Len Tower.

@karlkfi
Copy link
Contributor Author

karlkfi commented Jan 22, 2021

Looks like Cloud Shell runs Debian 10 buster and has diffutils installed, which comes with diff & diff3.

Other linux versions and macs may have different versions of diff installed or even diff3 as diff.

@runewake2 runewake2 self-assigned this Jan 27, 2021
@runewake2
Copy link
Contributor

Hi, your previous comment seems correct. kpt pkg diff uses the local diff tool to calculate diffs and diffutilsdiff does not support 3 way diffing. You can provide an alternative tool by passing kpt pkg diff the --diff-tool flag however it doesn't look like diff3 in Cloud Shell supports directories.

--diff-tool diff3 fails with:

/usr/bin/diff3: /tmp/kpt-470776679: Is a directory

I did have some success with --diff-tool vimdiff but I don't think this creates the resulting diff you'd expect without more work.

I'm still exploring other potential options here. For now it may be quickest to install your preferred 3 way diffing tool and provide that tool to kpt.

@mikebz
Copy link
Contributor

mikebz commented Feb 19, 2021

is this issue now fixed or is there more?

@karlkfi
Copy link
Contributor Author

karlkfi commented Feb 19, 2021

I suggest making sure it works in Cloud Shell by default, whether that means a change to kpt or a change to Cloud Shell.

@runewake2
Copy link
Contributor

I agree, I think that is the ideal experience. However, I'm not sure how we'd implement this without introducing a lot of work on our end. Many of the 3 way diffing tools I'm aware of are UI based and diff3 does not support diffing over directories. Is there a tool you think would be appropriate here?

@runewake2
Copy link
Contributor

Hi Karl, right now I think the best option to solve this is to use --diff-type=remote to compare the upstream branch at your current version (stored in your Kptfile) and the upstream branch at the branches HEAD. This will give you feedback on any upstream changes that have been made to your packages since you last updated the package.

If your using 3way diffing locally then a tool like meld also seems to work well. However this visual diffing experience is not possible right now from a CLI or Cloud Shell. We do not have plans currently to implement that so I'm going to close this issue for now. If there is a tool that you think would be able to provide this experience please consider reopening this and we can take a look. I've also noted some other comments on the experience of diffing packages and we'll work to improve those experiences in other issues.

@karlkfi
Copy link
Contributor Author

karlkfi commented Mar 1, 2021

For anyone who finds this later, I suggest using kpt pkg diff --diff-type=remote to evaluate upstream-only changes since you last updated.

Then use kpt pkg update . --strategy resource-merge and an IDE or visual diff tool to evaluate how those changes will affect your local package instance/fork. This way you can approve or reject the changes with local git commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/pkg customer deep engagement triaged Issue has been triaged by adding an `area/` label
Projects
None yet
Development

No branches or pull requests

3 participants