Skip to content

Conversation

@mrunalp
Copy link
Member

@mrunalp mrunalp commented Jan 12, 2018

Signed-off-by: Mrunal Patel [email protected]

- What I did
Added support to enable strace on containers.

- How I did it
Added an annotation which when passed over the API is taken as a signal to start a strace on the container.

- How to verify it
Set the annotation/label on a container and check that strace process is started for it.

- Description for the changelog

@mrunalp mrunalp requested a review from runcom as a code owner January 12, 2018 00:39
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes labels Jan 12, 2018
Copy link
Contributor

@TomSweeneyRedHat TomSweeneyRedHat left a comment

Choose a reason for hiding this comment

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

Change LGTM, but Travis isn't happy.


if enableStrace {
go func() {
straceCmd := exec.Command("strace", "-f", "-o", fmt.Sprintf("/tmp/%v", c.id), "-p", fmt.Sprintf("%d", c.state.Pid))
Copy link
Contributor

Choose a reason for hiding this comment

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

This will have to be added as a requirement for CRI-O.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a README.

oci/oci.go Outdated
straceCmd := exec.Command("strace", "-f", "-o", fmt.Sprintf("/tmp/%v", c.id), "-p", fmt.Sprintf("%d", c.state.Pid))
_, err := straceCmd.CombinedOutput()
if err != nil {
logrus.Infof("Failed to execute strace: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be Errorf?

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 17, 2018
@mrunalp mrunalp changed the title WIP: Add support for stracing containers Add support for stracing containers Jan 17, 2018
@mrunalp
Copy link
Member Author

mrunalp commented Jan 17, 2018

Updated and added a commit to allow this when daemon has enabled it explicitly.

@mrunalp
Copy link
Member Author

mrunalp commented Jan 17, 2018

/test all

@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 17, 2018

@mrunalp: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/openshift-jenkins/e2e_rhel 74f624b link /test e2e_rhel

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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/test-infra repository. I understand the commands that are listed here.

lib/config.go Outdated
ContainerExitsDir string `toml:"container_exits_dir"`

// AllowStrace determinates whether the cri-o strace annotation takes effect
// or not.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the “not” case could use more specifics. Perhaps “or not” → “or is silently ignored”? We'll also want similar text in a docs/crio.8.md entry.


// Only allow strace annotation if cri-o daemon allows it
if !s.config.Config.AllowStrace {
specgen.RemoveAnnotation(annotations.Strace)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if the server config is available in CreateContainer or not. But this approach only covers annotations and does not guard against the setting coming in through labels. It would be nice if we could move this guard into CreateContainer somehow to cover both injection paths. As a side benefit, it would allow us to guard against unwanted strace invocations without having to adjust user-supplied annotations (more on leaving annotations alone in opencontainers/runtime-spec#946).

This flag controls whether strace is started for containers
with the cri-o strace annotation/label "io.kubernetes.cri-o.Strace".

Signed-off-by: Mrunal Patel <[email protected]>
Signed-off-by: Mrunal Patel <[email protected]>
@mrunalp
Copy link
Member Author

mrunalp commented Jan 19, 2018

Updated.


**--cpu-profile**: Set the CPU profile file path

**--allow-strace**: Allow strace for containers when the strace annotation/label "io.kubernetes.cri-o.Strace=true" is set
Copy link
Contributor

Choose a reason for hiding this comment

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

Except for the last few of these, the options in this man page seem to be ordered alphabetically. There are a number of them, so I think we may want to continue with that alphabetization to keep them easy to find.

stdinOnce bool
privileged bool
trusted bool
allowStrace bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to poke these holes one at a time? Or do we want to poke a big hole and add:

server  *server.Config

so the container can use c.server.AllowStrace? A bigger hole would make the NewContainer interface more stable if we need additional server configs passed through later on.

@mrunalp
Copy link
Member Author

mrunalp commented Nov 28, 2018

Closing as we need to chase down issues in runc to support this effectively.

@mrunalp mrunalp closed this Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants