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

kubectl diff -Rf (recursive mode) does not work #71920

Closed
towolf opened this issue Dec 10, 2018 · 5 comments · Fixed by #71923
Closed

kubectl diff -Rf (recursive mode) does not work #71920

towolf opened this issue Dec 10, 2018 · 5 comments · Fixed by #71923
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/cli Categorizes an issue or PR as relevant to SIG CLI.

Comments

@towolf
Copy link
Contributor

towolf commented Dec 10, 2018

What happened:

I get a diff, when I specify a file directly, but on recursive mode, no diff is shown anymore:

$ kubectl diff -f kube-system/heapster/heapster.deploy.yaml                                                                                                                                                          
diff -u -N /tmp/LIVE-408713333/heapster /tmp/MERGED-013765456/heapster                                                                                                                                               
--- /tmp/LIVE-408713333/heapster        2018-12-10 23:38:10.619663532 +0100                                                                                                                                          
+++ /tmp/MERGED-013765456/heapster      2018-12-10 23:38:10.635663847 +0100                                                                                                                                          
@@ -44,7 +44,7 @@                                                                                                                                                                                                    
       - command:                                                                                                                                                                                                    
         - /heapster                                                                                                                                                                                                 
         - --source=kubernetes.summary_api:https://kubernetes.default?kubeletPort=10250&kubeletHttps=true&useServiceAccount=true&insecure=false                                                                      
-        image: k8s.example.com/heapster-amd64:v1.6.0-beta.1                                                                                                                                               
+        image: k8s.example.com/heapster-amd64:v1.5.4                                                                                                                                                      
         imagePullPolicy: IfNotPresent                                                                                                                                                                               
         livenessProbe:                                                                                                                                                                                              
           failureThreshold: 3                                                                                                                                                                                       
exit status 1                                                                                                                                                                                                        
$ kubectl diff -f kube-system/heapster                                                                                                                                                                               
$ kubectl diff -Rf kube-system/heapster  
$

What you expected to happen:

Recursive mode should work

How to reproduce it (as minimally and precisely as possible):

Have a bunch of YAML manifest, but with name collisions, e.g. Service heapster, Deployment heapster, etc

Anything else we need to know?:

I think the problem is that all objects have the same name, which should not be a problem per se.

$ grep name: kube-system/heapster -r                                                                                                                                                                                
kube-system/heapster/heapster.service.yaml:  name: heapster
kube-system/heapster/heapster-rbac.yaml:  name: heapster-binding
kube-system/heapster/heapster-rbac.yaml:  name: system:heapster
kube-system/heapster/heapster-rbac.yaml:  name: heapster
kube-system/heapster/heapster.deploy.yaml:  name: heapster
kube-system/heapster/heapster.deploy.yaml:  name: heapster
kube-system/heapster/heapster.deploy.yaml:        - name: heapster

Only heapster-binding has a different name, and looking at the generated temp files, only heapster and heapster-binding are present:

$ export KUBECTL_EXTERNAL_DIFF="find"
$ kubectl diff -Rf kube-system/heapster
/tmp/LIVE-582567937
/tmp/LIVE-582567937/heapster
/tmp/LIVE-582567937/heapster-binding
/tmp/MERGED-207518060
/tmp/MERGED-207518060/heapster
/tmp/MERGED-207518060/heapster-binding

Environment:

  • Kubernetes version (use kubectl version):
    $ kubectl version --short
    Client Version: v1.13.0
    Server Version: v1.13.0

/kind bug

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Dec 10, 2018
@towolf
Copy link
Contributor Author

towolf commented Dec 10, 2018

/sig cli

@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Dec 10, 2018
@towolf
Copy link
Contributor Author

towolf commented Dec 10, 2018

@apelisse I think the files are overwriting each other?

$ strace -f  kubectl diff -Rf kube-system/heapster |& grep /heapster.*O_WRONLY
[pid  6719] openat(AT_FDCWD, "/tmp/LIVE-916861561/heapster-binding", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0700) = 6
[pid  6719] openat(AT_FDCWD, "/tmp/MERGED-519006084/heapster-binding", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0700) = 6
[pid  6721] openat(AT_FDCWD, "/tmp/LIVE-916861561/heapster", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0700) = 6
[pid  6721] openat(AT_FDCWD, "/tmp/MERGED-519006084/heapster", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0700 <unfinished ...>
[pid  6730] openat(AT_FDCWD, "/tmp/LIVE-916861561/heapster", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0700) = 6
[pid  6729] openat(AT_FDCWD, "/tmp/MERGED-519006084/heapster", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0700 <unfinished ...>
[pid  6729] openat(AT_FDCWD, "/tmp/LIVE-916861561/heapster", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0700 <unfinished ...>
[pid  6729] openat(AT_FDCWD, "/tmp/MERGED-519006084/heapster", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0700 <unfinished ...>

@apelisse
Copy link
Member

Yeah, good catch, I'll try to fix that asap

@towolf
Copy link
Contributor Author

towolf commented Dec 10, 2018

Thanks! By the way, very nice work with dry-run and diff. I was waiting for this.

@apelisse
Copy link
Member

@towolf Feel free to look at the PR and give your opinion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. sig/cli Categorizes an issue or PR as relevant to SIG CLI.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants