<div dir="ltr">I don't yet have a small test for this yet, so here's all the information I've found while I get that ready:<div><br></div><div>I have a <a href="https://nsbox.dev/" target="_blank">side project</a> that revolves around using systemd-nspawn to run pet containers. One feature I'm trying to use it for is booted containers, where the following happens:</div><div><br></div><div>- During container boot, a service is run that creates an account inside the container corresponding to the outside user. This service depends on multi-user.target, as well as console-getty (which is overridden to enable autologin).</div><div>- The service inside signals the outside world when it's done that the container is ready for login.</div><div>- Once the signal is received outside, the host uses nsenter to enter the container namespace, then runs</div><div><br></div><div>  runuser -s /bin/bash -- - "$THE_USER_NAME" some-command<br clear="all"><div><br></div><div>Here's the bizarre part: runuser just hangs forever. I went into debugging it further, and found it was hanging waiting for a response from systemd-logind while executing the PAM config. With verbose logging for logind enabled, I observed the following:<br><br></div><div>  Mar 27 01:04:35 test-boot systemd[1]: Failed to start Session 47 of user vagrant.</div><div><br></div><div>Looking further up:<br><br></div><div>  Mar 27 01:04:35 test-boot systemd-logind[25]: Sent message type=method_call sender=n/a destination=org.freedesktop.systemd1 path=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.></div>  Mar 27 01:04:35 test-boot systemd[1]: session-47.scope: Failed to add PIDs to scope's control group: No such file or directory<br>  Mar 27 01:04:35 test-boot systemd[1]: session-47.scope: Failed with result 'resources'</div><div><br></div><div>With verbose logging for systemd itself available, I observed the following (this was on cgroups v1, but the same error appears with v2):</div><div><br></div><div>  Mar 27 20:27:36 test-boot systemd[1]: session-3.scope: Failed to set 'memory.limit_in_bytes' attribute on '/user.slice/user-1000.slice/session-3.scope' to '-1': No such file or directory<br>  Mar 27 20:27:36 test-boot systemd[1]: session-3.scope: Failed to set 'pids.max' attribute on '/user.slice/user-1000.slice/session-3.scope' to 'max': No such file or directory<br>  Mar 27 20:27:36 test-boot systemd[1]: session-3.scope: Couldn't move process 73 to requested cgroup '/user.slice/user-1000.slice/session-3.scope': No such file or directory<br>  Mar 27 20:27:36 test-boot systemd[1]: session-3.scope: Failed to add PIDs to scope's control group: No such file or directory<br>  Mar 27 20:27:36 test-boot systemd[1]: session-3.scope: Failed with result 'resources'.<br><div><br></div><div>So...it seems to be getting stuck on moving processes to the new session's scope's cgroup? Here's the weird part: if I wait around 10-15 seconds or so, then run it again...it works. This would lead me to believe there's a race somewhere, but I can't find anything implying that in the logs.</div><div><br></div><div>At this point I'm just stumped. I'm working to reproduce it with just pure nspawn, but in the mean time, I was curious if anyone here had an idea on where this could be coming from?</div><div><br></div>-- <br><div dir="ltr" data-smartmail="gmail_signature">Ryan</div><div dir="ltr" data-smartmail="gmail_signature"><a href="https://refi64.com/" target="_blank">https://refi64.com/</a></div></div></div>