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: remove wrapperd and launch processes directly #9489

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

dsseng
Copy link
Member

@dsseng dsseng commented Oct 11, 2024

Fixes #9472

TODO:

  • tests
  • finalize

@dsseng dsseng self-assigned this Oct 11, 2024
wrapper.stderr,
}

// TODO: use pa.Sys.CgroupFD here when we can be sure clone3 is available
Copy link
Member

Choose a reason for hiding this comment

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

let's absolutely do this

Copy link
Member Author

Choose a reason for hiding this comment

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

So implement 2 different pathways? We use this code in container mode as well, and we cannot really expect containers to be ran on kernel 5.5+ which has clone3

Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
…ling

Now everything except dashboard (operation not permitted (?!)) runs

Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
Do TIOCSCTTY on stdin, not WRONLY stdout to avoid EPERM

Signed-off-by: Dmitry Sharshakov <[email protected]>
Validate capabilities are dropped and cgroup, UID, environment and OOM adjustments are set

Signed-off-by: Dmitry Sharshakov <[email protected]>
Signed-off-by: Dmitry Sharshakov <[email protected]>
@dsseng dsseng marked this pull request as ready for review October 17, 2024 06:57
@@ -105,6 +105,7 @@ linters-settings:
- golang.zx2c4.com/wireguard
- golang.zx2c4.com/wireguard/wgctrl
- cloud.google.com/go
- kernel.org/pub/linux/libs/security/libcap/cap
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: remove as this was only debug

Comment on lines +27 to +29

// improved error logging
kernel.org/pub/linux/libs/security/libcap/cap => github.com/dsseng/go-libcap/cap v0.0.0-20241015195416-c3ab072bd718
Copy link
Member Author

Choose a reason for hiding this comment

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

todo remove

@@ -224,6 +224,7 @@ func TestProcessSuite(t *testing.T) {
t.Skip("wrapperd not found")
}

// What's the purpose of this test? Should it be replaced for new subprocess start method?
Copy link
Member Author

Choose a reason for hiding this comment

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

Needs review

Copy link
Member

@smira smira Oct 17, 2024

Choose a reason for hiding this comment

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

process reaper is due to the fact that Talos machine is PID=1 and it should reap all zombies, so it runs a waitpid() loop which breaks Go's wait for the process (as it reaps before Go might have a chance), so unrelated to wrapperd

@@ -66,7 +66,7 @@ func (d *Dashboard) Runner(r runtime.Runtime) (runner.Runner, error) {
}),
runner.WithStdinFile(tty),
runner.WithStdoutFile(tty),
runner.WithCtty(1),
runner.WithCtty(0),
Copy link
Member Author

Choose a reason for hiding this comment

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

ctty(1) failed as stdout is opened as write-only. We might want to change that, but perhaps using stdin as ctty is perfectly fine as we pass both for TTY to work

@dsseng dsseng changed the title WIP: replace wrapperd feat: remove wrapperd and launch processes directly Oct 17, 2024
@dsseng
Copy link
Member Author

dsseng commented Oct 17, 2024

Maybe the test should be a separate PR going in before refactoring. If so, will do later today

return fmt.Errorf("failed to load cgroup %s: %w", path, err)
}

if err := cgv2.AddProc(uint64(pid)); 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.

can we move to cgroupFD?

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't we also use this launch method when running in a container (thus not sure we have clone3 available)? Cgroup in clone3 is actually only available since kernel 5.7

Copy link
Member

Choose a reason for hiding this comment

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

good point, let's skip it for now

Copy link
Member

Choose a reason for hiding this comment

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

can we optionally have two paths? like auto-detect?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unsure whether that's going to be beneficial, but it's possible for sure

waitCh := make(chan error)

go func() {
waitCh <- reaper.WaitWrapper(usingReaper, notifyCh, cmdWrapper.cmd)
_, err := process.Wait()
Copy link
Member

Choose a reason for hiding this comment

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

should use reaper, don't change this part please

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

refactor: remove wrapperd in favor launcher
5 participants