-
Notifications
You must be signed in to change notification settings - Fork 39.6k
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
Fix incorrect message when attaching to ephemeral containers #111185
Conversation
Skipping CI for Draft Pull Request. |
/triage accepted |
return "" | ||
} | ||
if _, path := podcmd.FindContainerByName(o.Pod, containerName); strings.HasPrefix(path, "spec.ephemeralContainers") { | ||
return fmt.Sprintf("Session ended, the ephemeral container will not be restarted but may be reattached using '%s %s -c %s -i -t' if it is still running", o.CommandName, o.Pod.Name, containerName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which circumstances ephemeral container can be reattached?, because all of the cases I tried, it failed.
Is it because I exited from ephemeral container by typingexit
?
Wouldn't be better(or possible) to state that: is reattachment going to work or not instead "may not"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, typing exit
means that the container is no longer running. If you disconnect while the process is still running (for example, because of a network reset or by killing kubectl) then you can reattach.
// reattachMessage returns a message to print after attach has completed, or | ||
// the empty string if no message should be printed. | ||
func (o *AttachOptions) reattachMessage(containerName string, rawTTY bool) string { | ||
if o.Quiet || !o.Stdin || !rawTTY || o.Pod.Spec.RestartPolicy != corev1.RestartPolicyAlways { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for learning; why we added !rawTTY
in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just because that's the current behavior.
/retest |
Co-authored-by: Akanksha kumari <akankshakumari393@gmail.com>
/lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: brianpursley, verb The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind bug
/sig cli
/priority important-longterm
What this PR does / why we need it:
kubectl prints reconnect instructions after a
kubectl attach
session ends, but this is misleading for ephemeral containers because they won't be restarted and the attach will fail.Which issue(s) this PR fixes:
Fixes #111027
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: