m/n/core/hostsfile: narrow down network service type to just network status
This will allow testing the hostsfile service more easily in the future.
Change-Id: Ic61337bac77f643543e1a83837b009f9ea73439f
Reviewed-on: https://review.monogon.dev/c/monogon/+/2877
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/node/core/network/hostsfile/hostsfile.go b/metropolis/node/core/network/hostsfile/hostsfile.go
index 48f4f18..b82ecbe 100644
--- a/metropolis/node/core/network/hostsfile/hostsfile.go
+++ b/metropolis/node/core/network/hostsfile/hostsfile.go
@@ -38,9 +38,8 @@
)
type Config struct {
- // Network is a handle to the Network service, used to update the hostsfile
- // service with information about the local node's external IP address.
- Network *network.Service
+ // Network will be read to retrieve the current status of the Network service.
+ Network event.Value[*network.Status]
// Ephemeral is the root of the ephemeral storage of the node, into which the
// service will write its managed files.
Ephemeral *localstorage.EphemeralDirectory
@@ -149,8 +148,7 @@
localC := make(chan *network.Status)
s.clusterC = make(chan nodeMap)
- st := &s.Network.Status
- if err := supervisor.Run(ctx, "local", event.Pipe(st, localC)); err != nil {
+ if err := supervisor.Run(ctx, "local", event.Pipe(s.Network, localC)); err != nil {
return err
}
if err := supervisor.Run(ctx, "cluster", s.runCluster); err != nil {
diff --git a/metropolis/node/core/roleserve/worker_hostsfile.go b/metropolis/node/core/roleserve/worker_hostsfile.go
index c454ff2..8574235 100644
--- a/metropolis/node/core/roleserve/worker_hostsfile.go
+++ b/metropolis/node/core/roleserve/worker_hostsfile.go
@@ -41,7 +41,7 @@
svc := hostsfile.Service{
Config: hostsfile.Config{
- Network: s.network,
+ Network: &s.network.Status,
Ephemeral: &s.storageRoot.Ephemeral,
ESP: &s.storageRoot.ESP,
NodeID: cc.nodeID(),