Revamp DHCP, add basic context management
This started off as a small change to make the network service DHCP client a bit nicer, and ended up basically me half-assedly starting to add context within Smalltown.
In my opionion a simple OnStart/OnStop lifecycle management for services will stop working once we have to start handling failing services. I think taking inspiration from Erlang's OTP and implementing some sort of supervision tree is the way to go. I think this also ties nicely together with Go's context system, at least partially. Implementing the full supervision tree system is out of scope for this change, but at least this introduces .Context() on the base service struct that service implementations can use. Currently each service has its own background context, but again, this should tie into some sort of supervision tree in the future. There will be a design document for this.
I also rejigger the init code to have a context available immediately, and use that to acquire (with timeout) information about DHCP addresses from the network service.
I also fix a bug where the network service is started twice (once by init, once by the smalltown node code; now the smalltown node code takes in a dependency injected network service instead).
I also fix a bug where OnStop would call OnStart. Whoops.
Test Plan: no new functionality, covered by current tests
Bug: T561
X-Origin-Diff: phab/D396
GitOrigin-RevId: adddf3dd2f140b6ea64eb034ff19533d32c4ef23
diff --git a/core/scripts/test_boot.sh b/core/scripts/test_boot.sh
index 3b4b57d..03cf8c4 100755
--- a/core/scripts/test_boot.sh
+++ b/core/scripts/test_boot.sh
@@ -17,7 +17,7 @@
spawn core/scripts/launch.sh
-expect "Network service got IP" {} default {
+expect "DHCP client ASSIGNED" {} default {
print_stderr "Failed while waiting for IP address\n"
exit 1
}