nixos/test-driver: null out self.pid when shutting down the container

Without this, we end up with `self.pid` set to the pid of a dead
process, and `self.process == None`. This causes us to blow [this
assert](https://github.com/jfly/nixpkgs/blob/dd51e81af9226ee80e6f0891f4649e12ea15dfd0/nixos/lib/test-driver/src/test_driver/machine/__init__.py#L1496)
in `NspawnMachine.release`.

It would probably be cleaner to just get rid of `self.pid`. It's
redundant given that we have `self.process`. I'll do that in a followup
commit.

This was discovered here:
https://github.com/NixOS/nixpkgs/pull/522886#discussion_r3285395646, and
will be protected against future regression by a test introduced in that
PR.
This commit is contained in:
Jeremy Fleischman
2026-05-22 01:53:43 -07:00
parent bcebf9451f
commit 11855b765c
@@ -1721,6 +1721,7 @@ class NspawnMachine(BaseMachine):
with self.nested("waiting for the container to power off"):
self.process.wait()
self.process = None
self.pid = None
class MachineDeprecationWrapper: