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

Fixes get --show-all #18165

Merged
merged 1 commit into from
Dec 19, 2015

Conversation

fabianofranz
Copy link
Contributor

Fixes showIfTerminating in resource printer to make sure it only skips terminating pods and detaches it from the showAll check.

Worth to mention that both kubectl get pods and kubectl get pod <name> print objects individually, so printPodList is never called by the kubectl get command making --show-all=true|false do nothing in the previous logic.

@k8s-github-robot
Copy link

Labelling this PR as size/M

@k8s-github-robot k8s-github-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 3, 2015
@bgrant0607 bgrant0607 assigned janetkuo and unassigned bgrant0607 Dec 3, 2015
@k8s-bot
Copy link

k8s-bot commented Dec 3, 2015

GCE e2e build/test failed for commit 51c0d89f4a91ce9885150846cc7cffbfa2a25df0.

@k8s-bot
Copy link

k8s-bot commented Dec 3, 2015

GCE e2e build/test failed for commit ec1811b4adf4d0a87a0ee002c09ccd910bd51016.

@@ -600,15 +641,6 @@ func printPodBase(pod *api.Pod, w io.Writer, withNamespace bool, wide bool, show
return err
}

func printPodList(podList *api.PodList, w io.Writer, withNamespace bool, wide bool, showAll bool, columnLabels []string) error {
Copy link
Member

Choose a reason for hiding this comment

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

Are these two functions moved without code changes? It might be better to keep them where they were, to make it easier to keep track of code changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They were moved without changes, the PrintObj method of HumanReadablePrinter is a little misplaced. Reverted.

@k8s-github-robot
Copy link

Labelling this PR as size/XS

@k8s-github-robot k8s-github-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 3, 2015
@k8s-bot
Copy link

k8s-bot commented Dec 4, 2015

GCE e2e test build/test passed for commit d4939fba8daf076a5a8cd08489743346d206323e.

@feihujiang
Copy link
Contributor

No, don't change the logic. Using showIfTerminating is to solve the problem that couldn't get the terminated pod by name. kubectl get pod should retrieve the pod regardless of its state. kubectl get pods would hide all terminated pods. If showIfTerminating is a little confusing, make the variable "showWhateverPodPhase" or other meaningful variable.

@feihujiang
Copy link
Contributor

By default (--show-all=false), kubectl get pods would hide all terminated pods. When --show-all=true, kubectl get pods would show all pods.

@fabianofranz
Copy link
Contributor Author

@feihujiang showIfTerminating is useless today for the get command because it's always true in any of the scenarios below. It happens because both get list and get by name call printPod, never printPodList.

# showIfTerminating is *always* true here

$ kubectl get pods
$ kubectl get pods -a
$ kubectl get pod <name>
$ kubectl get pod <name> -a

In result, the check in line 545 will never be fulfilled, making showAll (and in result --show-all=true|false) do nothing. This PR fixes --show-all to make it actually perform the filter.

@feihujiang
Copy link
Contributor

@fabianofranz The problem is, change in this commit make $ kubectl get pod <name> couldn't get the terminated pod (pod.Status.Phase equal to api.PodSucceeded or equal to api.PodFailed) directly. And I think a good user experience is that kubectl get pod <name> should retrieve the pod regardless of its state.

@janetkuo
Copy link
Member

janetkuo commented Dec 9, 2015

We changed kubectl get code to always flatten podList first before printing it, in order to support kubectl get -f <list-type-resource>. Now getting a list of pods only calls printPod, but not printPodList.

We should find a new way to hide terminated pods by default if not getting the pod by its name, and show all pods when --show-all=true.

@feihujiang
Copy link
Contributor

Yes, should find a new way to hide terminated pods.
Not getting the pod by its name only have the one method $ kubectl get pods.
Other methods are all getting the pod by its name, such as, $ kubectl get pods <name>, $kubectl get -f <list-type-resource>. @janetkuo If I'm wrong, please correct me.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 9, 2015
@fabianofranz
Copy link
Contributor Author

What about removing showIfTerminating and always rely on showAll - e.g. in the get command, if it's getting the resource by name then we force showAll to be true, which will make sure the named resource is always shown. If it sounds like a solution then I'll update this PR.

@janetkuo
Copy link
Member

janetkuo commented Dec 9, 2015

@fabianofranz sounds good! And as @feihujiang mentioned, we should hide terminated pods when kubectl get pods, but don't hide them when kubectl get pods <pod name> or kubectl get -f <file>.

@k8s-github-robot
Copy link

Labelling this PR as size/M

@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 10, 2015
@fabianofranz
Copy link
Contributor Author

Ok, changed this to remove showIfTerminating and always rely on showAll, which is forced to true when getting the resource by name or filename. PTAL

@feihujiang
Copy link
Contributor

LGTM-- my comment is optional.

// HasNames returns true if the provided args contain resource names
func HasNames(args []string) bool {
args = normalizeMultipleResourcesArgs(args)
hasCombinedTypes, _ := hasCombinedTypeArgs(args)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this function need to return the error, so that we can handle the error as early as possible?

Copy link
Member

Choose a reason for hiding this comment

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

We should check the returned error here.

@feihujiang
Copy link
Contributor

Adding a test for this function in test-cmd.sh is better. :)

@fabianofranz
Copy link
Contributor Author

@feihujiang Yeah, I'll add a test-cmd.sh test. Would you suggest an image we could use to check the Succeeded/Failed phase? I don't think there is something like that in test-cmd.sh yet.

@feihujiang
Copy link
Contributor

We couldn't test this in test-cmd.sh, because Succeeded/Failed are the phase of the lifecycle of a pod, so pod couldn't turn into Succeeded or Failed immediately when we create it. However tests in test-cmd.sh are just for simple scenarios.

@feihujiang
Copy link
Contributor

Add unit test is ok. :)

@k8s-github-robot
Copy link

Labelling this PR as size/L

@k8s-github-robot k8s-github-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 Dec 11, 2015
@fabianofranz
Copy link
Contributor Author

The printer already has some tests, so I added some for the flag enforcing and HasNames. PTAL

@k8s-bot
Copy link

k8s-bot commented Dec 11, 2015

GCE e2e test build/test passed for commit 37a83a0785ef0f07c3f36818ef0676f3018e5c69.

@feihujiang
Copy link
Contributor

LGTM

@fabianofranz
Copy link
Contributor Author

@janetkuo LGTMed, up to you to tag this. tks everyone!

args: []string{"rc/foo", "rc/bar", "rc/zee"},
expectedHasName: true,
},
}
Copy link
Member

Choose a reason for hiding this comment

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

add "" and invalid test cases such as "rc/foo", "bar"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

@janetkuo
Copy link
Member

Mostly LG other than nits. Thanks!

@k8s-bot
Copy link

k8s-bot commented Dec 17, 2015

GCE e2e test build/test passed for commit 717896e.

@fabianofranz
Copy link
Contributor Author

@janetkuo comments addressed.

@janetkuo janetkuo added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 18, 2015
@janetkuo
Copy link
Member

Thanks! LGTM.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Dec 19, 2015

GCE e2e test build/test passed for commit 717896e.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

k8s-github-robot pushed a commit that referenced this pull request Dec 19, 2015
@k8s-github-robot k8s-github-robot merged commit 00c7541 into kubernetes:master Dec 19, 2015
openshift-publish-robot pushed a commit to openshift/kubernetes that referenced this pull request Jan 25, 2018
Automatic merge from submit-queue (batch tested with PRs 18129, 18152, 17403, 18020, 18165).

UPSTREAM: 57422: Rework method of updating atomic-updated data volumes

**What this PR does / why we need it**:

This is a backport of kubernetes#57422

This change affects the way that secret, configmap, downwardAPI and projected volumes (which all use the same underlying code) implement their data update functionality.

* Instead of creating a subdirectory hierarchy that will contain symlinks to each actual data file, create only symlinks to items in the root of the volume, whether they be files or directories.
* Rather than comparing the user-visible data directory to see if an update is needed, compare with the current version of the data directory.
* Fix data dir timestamp format year
* Create `..data` symlink even when a data volume has no data so consumers can have simplified update watch logic.

**Which issue(s) this PR fixes**
This addresses https://bugzilla.redhat.com/show_bug.cgi?id=1516569 and https://bugzilla.redhat.com/show_bug.cgi?id=1430322

**Special notes for your reviewer**:

**Release note**:
```release-note
Allow volumes to be mounted beneath secret volumes [1430322] [1516569]
```

Origin-commit: 91d864d470581d67e38bbe3fe3b967aeea3feded
openshift-publish-robot pushed a commit to openshift/kubernetes that referenced this pull request Feb 27, 2018
Automatic merge from submit-queue (batch tested with PRs 18129, 18152, 17403, 18020, 18165).

UPSTREAM: 57422: Rework method of updating atomic-updated data volumes

**What this PR does / why we need it**:

This is a backport of kubernetes#57422

This change affects the way that secret, configmap, downwardAPI and projected volumes (which all use the same underlying code) implement their data update functionality.

* Instead of creating a subdirectory hierarchy that will contain symlinks to each actual data file, create only symlinks to items in the root of the volume, whether they be files or directories.
* Rather than comparing the user-visible data directory to see if an update is needed, compare with the current version of the data directory.
* Fix data dir timestamp format year
* Create `..data` symlink even when a data volume has no data so consumers can have simplified update watch logic.

**Which issue(s) this PR fixes**
This addresses https://bugzilla.redhat.com/show_bug.cgi?id=1516569 and https://bugzilla.redhat.com/show_bug.cgi?id=1430322

**Special notes for your reviewer**:

**Release note**:
```release-note
Allow volumes to be mounted beneath secret volumes [1430322] [1516569]
```

Origin-commit: 91d864d470581d67e38bbe3fe3b967aeea3feded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

8 participants