Skip to content

exec:fix exec log grow to burst - #11862

Open
ningmingxiao wants to merge 1 commit into
containerd:mainfrom
ningmingxiao:fix_exec_log
Open

ningmingxiao wants to merge 1 commit into
containerd:mainfrom
ningmingxiao:fix_exec_log

Conversation

@ningmingxiao

@ningmingxiao ningmingxiao commented May 15, 2025 •

Copy link
Copy Markdown
Contributor

@k8s-ci-robot

Copy link
Copy Markdown

Hi @ningmingxiao. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

Comment thread integration/container_exec_test.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 10 changed files in this pull request and generated 3 comments.

Comment thread integration/client/client_unix.go Resolved
Comment thread integration/container_exec_test.go Resolved
Comment thread integration/container_exec_test.go Resolved
Copilot AI review requested due to automatic review settings July 16, 2026 02:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 11 changed files in this pull request and generated 3 comments.

Comment thread integration/container_exec_test.go Resolved
Comment thread integration/container_exec_test.go Resolved
Copilot AI review requested due to automatic review settings July 16, 2026 03:00
@ningmingxiao
ningmingxiao marked this pull request as draft July 16, 2026 03:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 11 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings July 16, 2026 03:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 11 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

cmd/containerd-shim-runc-v2/process/exec.go:220

  • Exec now overrides runc's --log via opts.LogFile, but on failure the shim still calls runtimeError, which only reads from p.runtime.Log (the shared log.json). This means exec failures will likely lose the detailed OCI runtime error (or potentially report an unrelated prior error), reducing debuggability.
	opts := &runc.ExecOpts{
		PidFile: pidFile.Path(),
		Detach:  true,
		LogFile: filepath.Join(filepath.Dir(e.parent.runtime.Log), fmt.Sprintf("%s-exec.log", e.id)),
	}
	if pio != nil {
		opts.IO = pio.IO()
	}
	if socket != nil {
		opts.ConsoleSocket = socket
	}
	defer os.Remove(opts.LogFile)
	if err := e.parent.runtime.Exec(ctx, e.parent.id, e.spec, opts); err != nil {
		close(e.waitBlock)
		return e.parent.runtimeError(err, "OCI runtime exec failed")
	}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 11 changed files in this pull request and generated 1 comment.

Comment thread integration/client/client_windows.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 11 changed files in this pull request and generated 1 comment.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 11 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 14 changed files in this pull request and generated 2 comments.

Comment thread integration/container_exec_test.go Resolved
Comment thread integration/container_exec_test.go Resolved
@ningmingxiao

Copy link
Copy Markdown
Contributor Author

ping @samuelkarp can you take a look ?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 14 changed files in this pull request and generated no new comments.

@ningmingxiao

Copy link
Copy Markdown
Contributor Author

ping @samuelkarp

Comment thread integration/container_exec_test.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 14 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

integration/container_exec_test.go:125

  • This test derives the task log directory from client.GetDefaultState() (which is hard-coded to /run/containerd-test on Unix). That can break when the integration harness points --cri-endpoint at a containerd instance using a different --state directory (e.g. via CONTAINERD_STATE overrides), because the log.json path will be computed incorrectly.

Consider deriving the state directory from the actual endpoint used by the test (e.g. filepath.Dir(containerdEndpoint) for unix sockets) and dropping the dependency on integration/client here.

	execLogDir := getLogDirPath(client.GetDefaultState(), "v2", "k8s.io", cn)
	logJSON := filepath.Join(execLogDir, "log.json")
	before, err := os.Stat(logJSON)
	require.NoError(t, err)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 14 changed files in this pull request and generated no new comments.

Comment thread integration/container_exec_test.go Outdated
if err != nil {
return "", err
}
return cfg.DefaultRuntimeName, nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should be looking for the actual shim io.containerd.runc.v2 not runc or crun here.

Something like:

  // runtimeTypeForHandler returns the containerd runtime type that the CRI plugin
  // uses for the given runtime handler. An empty handler resolves to the
  // configured default.
  func runtimeTypeForHandler(t *testing.T, handler string) string {
        resp, err := runtimeService.Status()
        require.NoError(t, err)
                
        var cfg criconfig.Config
        require.NoError(t, json.Unmarshal([]byte(resp.GetInfo()["config"]), &cfg))
   
        if handler == "" {
                handler = cfg.DefaultRuntimeName
        }
        r, ok := cfg.Runtimes[handler]
        require.Truef(t, ok, "runtime handler %q is not configured", handler)
        return r.Type
  }
   
  func TestVerifyRuntimeTypeForHandler(t *testing.T) {
        rt := runtimeTypeForHandler(t, *runtimeHandler)
        t.Logf("handler %q resolves to runtime type %q", *runtimeHandler, rt)
        require.Equal(t, plugins.RuntimeRuncV2, rt)
  }

or

  func TestVerifyRuntimeInfoName(t *testing.T) {
        info, err := containerdClient.RuntimeInfo(context.Background(), plugins.RuntimeRuncV2, nil)
        require.NoError(t, err)
        t.Logf("RuntimeInfo name=%q version=%+v", info.Name, info.Version)
        require.Equal(t, plugins.RuntimeRuncV2, info.Name)
  }

(Claude Code Opus 5 wrote these)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done, thanks @samuelkarp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 14 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

integration/container_exec_test.go:130

  • This test reads log.json from client.GetDefaultState() ("/run/containerd-test" on Linux), but the integration test suite connects to an existing containerd via -cri-endpoint (default "/run/containerd/containerd.sock"), so the actual state dir is typically different (e.g. "/run/containerd"). Use the CRI config’s stateDir from runtimeService.Status() to locate the task directory, otherwise this test will fail or silently validate the wrong file.
	t.Logf("Exec in container %s", cn)

	execLogDir := getLogDirPath(client.GetDefaultState(), "v2", "k8s.io", cn)
	logJSON := filepath.Join(execLogDir, "log.json")
	before, err := os.Stat(logJSON)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 14 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

integration/client/client_windows.go:48

  • Use of os.Getenv("programfiles") is inconsistent with other Windows paths in this repo (which use "ProgramFiles") and can produce a relative path if the variable is empty. Consider reading "ProgramFiles" first and falling back if needed.
func GetDefaultState() string {
	return filepath.Join(os.Getenv("programfiles"), "containerd", "state-test")
}

@kubernetes-prow

Copy link
Copy Markdown

PR needs rebase.

Details

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Needs Update

Development

Successfully merging this pull request may close these issues.

log.json of a container may grow to burst the tmpfs of /run, if a k8s user configure an exec liveness probe of a non exist executable file name.

7 participants