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 logs -f Is there a reason -f still errors when a pod is in state ContainerCreating? Can it wait? #1612

Closed
carterjfulcher opened this issue Jun 17, 2024 · 5 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@carterjfulcher
Copy link

carterjfulcher commented Jun 17, 2024

As Kubernetes developers, we often find ourselves repeatedly hitting the UpArrow + Enter combo in the terminal while waiting for a pod to start, to ensure we don’t miss any log output.

I am recommending a change which enhances the -f flag to wait until the pod is fully initialized during ContainerCreating status instead of erroring, making the development process smoother and more efficient.

The error in particular I'm referring to is the following, when kubectl logs -f [POD_ID] is invoked on a pod with status ContainerCreating:

Error from server (BadRequest): container "pod-name" in pod "pod-id" is waiting to start: ContainerCreating

I am happy to submit a PR for this change, if approved.

@carterjfulcher carterjfulcher added the kind/feature Categorizes issue or PR as related to a new feature. label Jun 17, 2024
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jun 17, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@brianpursley
Copy link
Member

Does something like this work for what you need?

kubectl wait --for=condition=Ready pod/foo && kubectl logs -f pod/foo

You could even turn this into a simple plugin by putting it into a file called kubectl-waitlogs somewhere in your path:

#!/bin/sh
kubectl wait --for=condition=Ready pod/$1 && kubectl logs -f pod/$1

And then chmod +x kubectl-waitlogs

and now you can:

kubectl waitlogs foo

@ardaguclu
Copy link
Member

kubernetes/kubernetes#125868 brings about new for condition just for creation.

$ kubectl wait --for=create pod/test-1
$ kubectl logs -f pod/test-1

I'd prefer closing this issue.

@mpuckett159
Copy link
Contributor

/close

This has been solved by a few options.

@k8s-ci-robot
Copy link
Contributor

@mpuckett159: Closing this issue.

In response to this:

/close

This has been solved by a few options.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

No branches or pull requests

5 participants