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 get broken for list #38907

Closed
mengqiy opened this issue Dec 16, 2016 · 16 comments · Fixed by #39038
Closed

kubectl get broken for list #38907

mengqiy opened this issue Dec 16, 2016 · 16 comments · Fixed by #39038
Assignees

Comments

@mengqiy
Copy link
Member

mengqiy commented Dec 16, 2016

kubectl get -o yaml|json is broken for list.

How to reproduce:
Create multiple resource from list: kubectl create -f https://raw.githubusercontent.com/kubernetes/kubernetes/master/hack/testdata/multi-resource-list.json.

Get the resources back: kubectl get -o yaml -f https://raw.githubusercontent.com/kubernetes/kubernetes/master/hack/testdata/multi-resource-list.json

Output:

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: 2016-12-16T22:09:53Z
  labels:
    app: mock
  name: mock
  namespace: default
  resourceVersion: "387943"
  selfLink: /api/v1/namespaces/default/services/mock
  uid: 5edec4bb-c3dc-11e6-aa89-42010a800002
spec:
  clusterIP: 10.0.160.121
  ports:
  - port: 99
    protocol: TCP
    targetPort: 9949
  selector:
    app: mock
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}

Only the first resource get printed out.

@kubernetes/kubectl @kubernetes/sig-cli-misc

@mengqiy
Copy link
Member Author

mengqiy commented Dec 16, 2016

@fabianofranz maybe we need to include this in #38768?

@adohe-zz
Copy link

@ymqytw what't the get response? I mean we really get all resources or just issue with printer.

@mengqiy
Copy link
Member Author

mengqiy commented Dec 19, 2016

@adohe I guess it's printer's issue. But I'm not sure how printer works for list of resources.
We get all the resources. There are 2 GET requests:
api/v1/namespaces/default/services/mock
api/v1/namespaces/default/replicationcontrollers/mock
But the printer only prints out service.

@fabianofranz
Copy link
Contributor

maybe we need to include this in #38768?

Done.

@smarterclayton
Copy link
Contributor

smarterclayton commented Dec 19, 2016 via email

@mengqiy
Copy link
Member Author

mengqiy commented Dec 19, 2016

Is this also broken in 1.5, i.e. a regression?

Yes, it is also broke in 1.5.

@smarterclayton
Copy link
Contributor

Setting priority and adding cherry pick candidate. This would break people using scripting.

@smarterclayton
Copy link
Contributor

Can someone take ownership to fixing this and getting it into the 1.5.x track?

@adohe-zz
Copy link

@smarterclayton I would fix this today.

@adohe-zz
Copy link

@kubernetes/sig-cli-misc the root cause is: we retrieve a list from server, and then we flatten the list , get multiple Info, but singular here is true, so we just print the first object.

@ncdc
Copy link
Member

ncdc commented Dec 20, 2016

Looks like this behavior was changed in #36085. I think the fix is to check len(infos) instead of looking at singular, as singular is going to report true when you do kubectl get -f <file> (and it looks like that hasn't changed from before).

@smarterclayton
Copy link
Contributor

smarterclayton commented Dec 20, 2016 via email

@ncdc
Copy link
Member

ncdc commented Dec 20, 2016

I can fix this if you would like me to, @adohe?

@ncdc
Copy link
Member

ncdc commented Dec 20, 2016

My suggestion above breaks other tests. Trying to figure out what's up.

@ncdc
Copy link
Member

ncdc commented Dec 20, 2016

Ah I see what it is. We still need to check singular and go into the list code path if it's !singular || len(infos) > 1

@adohe-zz
Copy link

@ncdc thanks very much :)

k8s-github-robot pushed a commit that referenced this issue Jan 11, 2017
Automatic merge from submit-queue

Fix kubectl get -f <file> -o <nondefault printer> so it prints all items in the file

**What this PR does / why we need it**: Fix kubectl get -f <file> -o <nondefault printer> so it prints all the objects in the file, instead of just the first one. Also add a test for this feature.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #38907 

**Special notes for your reviewer**:

**Release note**:

```release-note
```

cc @adohe @deads2k @liggitt @fabianofranz @kubernetes/kubectl @kubernetes/sig-cli-misc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants