Skip to content

kubectl run -it loses some lines of the log #27264

Closed

Description

@sttts

When running a command via kubectl run -it that immediately prints something, we might lose some lines of the log due to a race of the execution of the container and the kubectl attach used by kubectl run to attach to the terminal (compare comment #16670 (comment)).

As a workaround for running an interactive shell we have this ugly Hit enter for command prompt now. The actual root problem though is that docker attach does not replay the logs. It looks like docker run is the only way to actually synchronously run a command, get all the output and attach to the process.

Activity

  1. added
    priority/backlogHigher priority than priority/awaiting-more-evidence.
    sig/nodeCategorizes an issue or PR as relevant to SIG Node.
    on Jun 15, 2016
  2. ncdc commented on Jun 22, 2016

    @ncdc
    Member

    FYI Hit enter for command prompt will be removed once #25273 is merged. That forces a refresh of the TTY. I suppose it may still be possible to lose some lines, but if you have something like e.g. a curses-based screen displayed, 25273 should make that display correctly once you attach.

  3. sttts commented on Jun 23, 2016

    @sttts
    ContributorAuthor

    For curses that's fine. I had in mind the scripting use-case, i.e.

    KERNEL_VERSION=$(kubectl run -i --image=busybox --rm busybox --restart=Never -- uname -a)
    

    That's currently not really possible due to the issue.

  4. fejta-bot commented on Dec 19, 2017

    @fejta-bot

    Issues go stale after 30d of inactivity.
    Mark the issue as fresh with /remove-lifecycle stale.
    Stale issues rot after an additional 30d of inactivity and eventually close.

    Prevent issues from auto-closing with an /lifecycle frozen comment.

    If this issue is safe to close now please do so with /close.

    Send feedback to sig-testing, kubernetes/test-infra and/or @fejta.
    /lifecycle stale

  5. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Dec 19, 2017
  6. fejta-bot commented on Jan 18, 2018

    @fejta-bot

    Stale issues rot after 30d of inactivity.
    Mark the issue as fresh with /remove-lifecycle rotten.
    Rotten issues close after an additional 30d of inactivity.

    If this issue is safe to close now please do so with /close.

    Send feedback to sig-testing, kubernetes/test-infra and/or @fejta.
    /lifecycle rotten
    /remove-lifecycle stale

  7. added
    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.
    and removed
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Jan 18, 2018
  8. 70 remaining items

  9. esotsal commented on Oct 24, 2024

    @esotsal
    Contributor

    /assign

  10. esotsal commented on Jan 21, 2025

    @esotsal
    Contributor

    Have some time now and will try to work on this, commenting here to avoid being set to stale lifecycle.

  11. esotsal commented on Oct 15, 2025

    @esotsal
    Contributor

    I wasn’t able to find a way. Unassigning my self to leave this to someone else if is interested to work with.

    /unassign

  12. segevfiner commented on Oct 15, 2025

    @segevfiner

    This is quite a fundamental issue with how interactive mode is implemented AFAIK.

    The CLI first starts the container and then attaches to it, getting whatever is output from the point of attach on.

    To fix this, the output will need to be buffered (Including possibly any out of band tty modes). Or the output paused until the first attach.

    This will likely involve API changes, and possibly changes to CRI depending on the chosen implementation.

  13. olamilekan000 commented on Jan 3, 2026

    @olamilekan000
    Contributor

    /assign

  14. moved this from Backlog to Closed in SIG CLIon Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/kubectlkind/bugCategorizes issue or PR as related to a bug.priority/backlogHigher priority than priority/awaiting-more-evidence.sig/cliCategorizes an issue or PR as relevant to SIG CLI.sig/nodeCategorizes an issue or PR as relevant to SIG Node.triage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions