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: executor/pns containerid prefix fix #4555

Merged
merged 6 commits into from
Nov 19, 2020

Conversation

L3Nerd
Copy link
Contributor

@L3Nerd L3Nerd commented Nov 18, 2020

Checklist:

In several environments, where docker is used and the kubelet and docker are managed by systemd, the cgroup line has a docker- prefix. Here is a table of the possible combinations and the resulting cgroup lines.

This PR fixes the behaviour and removes all possible "*-" prefixes, like "docker-*" in systemd controlled docker/kubelet environments.

Failing example before the fix:

time="2020-11-18T12:10:04.158Z" level=info msg="containerID docker-4bb908294439e857f63daec791892a3dddace0cd02bec10fe3f1c5d91589d31f mapped to pid 39"
time="2020-11-18T12:10:04.158Z" level=warning msg="Failed to get main PID: Failed to determine pid for containerID 4bb908294439e857f63daec791892a3dddace0cd02bec10fe3f1c5d91589d31f: container may have exited too quickly"

Signed-off-by: Lennart Kindermann <lennart.kindermann@cloudseeds.de>
Signed-off-by: Lennart Kindermann <lennart.kindermann@cloudseeds.de>
Signed-off-by: Lennart Kindermann <lennart.kindermann@cloudseeds.de>
Signed-off-by: Lennart Kindermann <lennart.kindermann@cloudseeds.de>
Signed-off-by: Lennart Kindermann <lennart.kindermann@cloudseeds.de>

// remove possible "*-" prefix
// e.g. crio-7a92a067289f6197148912be1c15f20f0330c7f3c541473d3b9c4043ca137b42.scope
parts := strings.Split(containerID, "-")
Copy link
Contributor

Choose a reason for hiding this comment

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

this could panic in len(parts) == 0?

Copy link

Choose a reason for hiding this comment

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

strings.Split() always returns a slice of length ≥ 1, as even the empty string, split on any "split char" would result in []string{""}.

Please refer to the documentation where it says:

If s does not contain sep and sep is not empty, Split returns a slice of length 1 whose only element is s.

Copy link
Contributor Author

@L3Nerd L3Nerd Nov 19, 2020

Choose a reason for hiding this comment

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

And it's already tested here, here and here.

Copy link
Contributor

Choose a reason for hiding this comment

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

My bad - I actually meant line 435 - but I don't think it can panic on closer inspecting

@alexec
Copy link
Contributor

alexec commented Nov 19, 2020

Please sync with master.

…s-cgroups

Signed-off-by: Lennart Kindermann <lennart.kindermann@cloudseeds.de>
@alexec alexec merged commit 48af024 into argoproj:master Nov 19, 2020
@L3Nerd L3Nerd deleted the fix-pns-cgroups branch November 19, 2020 17:28
brabster pushed a commit to brabster/argo that referenced this pull request Nov 24, 2020
Signed-off-by: Lennart Kindermann <lennart.kindermann@cloudseeds.de>
Signed-off-by: Paul Brabban <paul.brabban@gmail.com>
alexcapras pushed a commit to alexcapras/argo that referenced this pull request Dec 2, 2020
Signed-off-by: Lennart Kindermann <lennart.kindermann@cloudseeds.de>
Signed-off-by: Alex Capras <alexcapras@gmail.com>
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.

3 participants