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

feat: implment persistent logging for containers running in foreground #2683

Merged
merged 1 commit into from
Dec 19, 2023

Conversation

vsiravar
Copy link
Contributor

@vsiravar vsiravar commented Dec 5, 2023

Fixes: #1657

TODO:
- Refactoring taskutil and container_io to use custom cio.Creator for all flags(-d,-t,-i,-a). This would unblock attach for -d.
[X] Changes for windows.
[X] Adding integration tests

go.mod Outdated
@@ -33,6 +33,7 @@ require (
github.com/fahedouch/go-logrotate v0.2.0
github.com/fatih/color v1.16.0
github.com/fluent/fluent-logger-golang v1.9.0
github.com/hashicorp/go-multierror v1.1.1
Copy link
Member

Choose a reason for hiding this comment

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

@@ -48,7 +48,6 @@ func generateRuntimeCOpts(cgroupManager, runtimeStr string) ([]containerd.NewCon
runtimeOpts = nil
}
} else {
// runtimeStr is a runc binary
Copy link
Member

Choose a reason for hiding this comment

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

Was this line removed by an accident?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, fixed it in the last commit.

func NewContainerIO(namespace string, logURI string, tty bool, stdin io.Reader, stdout, stderr io.Writer) cio.Creator {
return func(id string) (cio.IO, error) {

// is from https://github.com/containerd/containerd/blob/main/cmd/containerd-shim-runc-v2/process/io.go#L247
Copy link
Member

Choose a reason for hiding this comment

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

Please use a permanent link that contains a tag or a commit hash

cmd.ExtraFiles = append(cmd.ExtraFiles, sr, serrr, w)

if err := cmd.Start(); err != nil {
return nil, fmt.Errorf("failed to start binary process: %w", err)
Copy link
Member

Choose a reason for hiding this comment

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

The error string should contain cmd.Args

limitations under the License.
*/

package ioutil
Copy link
Member

Choose a reason for hiding this comment

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

The package name can be confused with the deprecated io/ioutil

Copy link
Member

Choose a reason for hiding this comment

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

Maybe “cioutil”?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes makes sense, I missed the io/ioutil package. Changed it to cioutil in last commit.

cmd := process.NewBinaryCmd(uri, id, namespace)
cmd.ExtraFiles = append(cmd.ExtraFiles, sr, serrr, w)

if err := cmd.Start(); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

The pipes should be cleaned up on an error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated with closer to close pipes and stop logger process on errors.

@vsiravar vsiravar changed the title feat: implment container IO for run without -d [Draft] feat: implment container IO for run without -d Dec 5, 2023
@vsiravar vsiravar force-pushed the vsiravar/update-container-io branch 7 times, most recently from 3aa3276 to 76bf40d Compare December 13, 2023 03:33
Signed-off-by: Vishwas Siravara <siravara@amazon.com>
@vsiravar vsiravar changed the title [Draft] feat: implment container IO for run without -d feat: implment persistent logginf for containers running in foreground Dec 13, 2023
@vsiravar vsiravar marked this pull request as ready for review December 13, 2023 22:29
@vsiravar vsiravar changed the title feat: implment persistent logginf for containers running in foreground feat: implment persistent logging for containers running in foreground Dec 13, 2023
@vsiravar
Copy link
Contributor Author

Thanks for reviewing the PR. I have addressed the initial feedback, refactored NewContainerIO and added integration tests to validate logs for containers started in the foreground. @AkihiroSuda PTAL when you get a chance.

@AkihiroSuda AkihiroSuda added this to the v1.7.3 (tentative) milestone Dec 15, 2023
Copy link
Member

@AkihiroSuda AkihiroSuda 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 AkihiroSuda merged commit 370b4d0 into containerd:main Dec 19, 2023
22 checks passed
@AkihiroSuda AkihiroSuda mentioned this pull request Dec 19, 2023
@AkihiroSuda
Copy link
Member

@AkihiroSuda AkihiroSuda mentioned this pull request Jan 2, 2024
@AkihiroSuda AkihiroSuda modified the milestones: v2.0.0, v1.7.3 Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support nerdctl logs for the containers running without -d
2 participants