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

fix: logs updated on starting of a stopped container #3896

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Shubhranshu153
Copy link
Contributor

@Shubhranshu153 Shubhranshu153 commented Feb 18, 2025

Issue:

When we start a container that was running and stopped or exited, logs are not updated.

Steps to Reproduce:

step 1: Run and exit container

sudo nerdctl run -it --name test-1 alpine:latest
/ # echo hello
hello
/ # exit
  1. start the same container
 sudo nerdctl start -a test-1
/ # echo bar
bar
/ # exit
  1. Check logs. Bar is missing.
 sudo nerdctl logs test-1
/ # echo hello
hello
/ # exit

fix:

The pr fixes it by adding multiwriters to start of containers.

@Shubhranshu153 Shubhranshu153 force-pushed the fix-logs-on-attach branch 6 times, most recently from 49019a2 to ccb179d Compare February 18, 2025 09:03
@Shubhranshu153
Copy link
Contributor Author

@AkihiroSuda
PTAL when you get a chance.
Thank You.

@apostasie
Copy link
Contributor

Docker failure is #3908

Rootful failure is #3513

@apostasie
Copy link
Contributor

@Shubhranshu153 I just have a batch of nits on the test.

Btw, feedback on the test framework is highly welcome.

Ideally, if we get #3591 in first, we can get rid of the added DelayOnceReaders here (and unbuffer).

But anyhow, don't sweat it - I can clean that up afterwards if needed.

@Shubhranshu153 Shubhranshu153 force-pushed the fix-logs-on-attach branch 3 times, most recently from df70bc7 to 72193e6 Compare February 24, 2025 18:20
@Shubhranshu153
Copy link
Contributor Author

Thanks the retry of the test passed.
@fahedouch @AkihiroSuda PTAL.

@apostasie
Copy link
Contributor

@Shubhranshu153 testing framework PR got merged.

Here is the TL;DR for you to update your PR:

  • package got moved to:
    • github.com/containerd/nerdctl/mod/tigron/test
    • github.com/containerd/nerdctl/mod/tigron/require
    • github.com/containerd/nerdctl/mod/tigron/expect
  • test.Contains should be replaced with expect.Contains
  • test.Require is now require.All
  • test.Windows is now require.Windows
  • test.Not is now require.Not

if flagT {
in, err := consoleutil.NewDetachableStdin(con, detachKeys, closer)
if err != nil {
return nil, err
}
ioCreator = cio.NewCreator(cio.WithStreams(in, con, nil), cio.WithTerminal)
ioCreator = cioutil.NewContainerIO(namespace, logURI, true, in, con, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

@Shubhranshu153 Just out of curiosity, we are using logURI for logging here. Would it cause any issues like #3895?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it would, working on a separate PR for it.

@Shubhranshu153 Shubhranshu153 force-pushed the fix-logs-on-attach branch 2 times, most recently from f110c75 to ed7e0bc Compare March 11, 2025 17:37
Copy link
Member

@fahedouch fahedouch left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda
Copy link
Member

Needs rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants