44 "github.com/threefoldtech/zbus"
55 "github.com/threefoldtech/zos_base/pkg/gridtypes"
66 "github.com/threefoldtech/zos_base/pkg/gridtypes/zos"
7+ "github.com/threefoldtech/zos_base/pkg/kernel"
78 "github.com/threefoldtech/zos_base/pkg/primitives/gateway"
89 "github.com/threefoldtech/zos_base/pkg/primitives/network"
910 netlight "github.com/threefoldtech/zos_base/pkg/primitives/network-light"
@@ -19,22 +20,46 @@ import (
1920)
2021
2122// NewPrimitivesProvisioner creates a new 0-OS provisioner
23+ //
24+ // Only the workload types this node variant can actually serve are registered.
25+ // A manager reaches its worker over zbus, and a light node runs netlightd
26+ // (module "netlight") in place of networkd (module "network"), so registering
27+ // the full network backed types there would leave a request queued for a module
28+ // that never answers. The provisioner rejects an unregistered type outright,
29+ // which surfaces to the owner as a failed workload instead of a deployment that
30+ // never resolves. Keep this in step with systemMonitor.GetNodeFeatures, which
31+ // advertises the same split to the grid.
2232func NewPrimitivesProvisioner (zbus zbus.Client ) provision.Provisioner {
33+ return provision .NewMapProvisioner (managersFor (zbus , kernel .GetParams ()))
34+ }
35+
36+ // managersFor builds the set of workload managers the given node variant can
37+ // actually serve. Split out from NewPrimitivesProvisioner so the variant gating
38+ // is testable without a matching /proc/cmdline.
39+ func managersFor (zbus zbus.Client , params kernel.Params ) map [gridtypes.WorkloadType ]provision.Manager {
40+ // types every variant serves. their managers talk to storaged, flistd,
41+ // contd and vmd, which run everywhere.
2342 managers := map [gridtypes.WorkloadType ]provision.Manager {
2443 zos .ZMountType : zmount .NewManager (zbus ),
2544 zos .ZLogsType : zlogs .NewManager (zbus ),
2645 zos .QuantumSafeFSType : qsfs .NewManager (zbus ),
2746 zos .ZDBType : zdb .NewManager (zbus ),
28- zos .NetworkType : network .NewManager (zbus ),
29- zos .PublicIPType : pubip .NewManager (zbus ),
30- zos .PublicIPv4Type : pubip .NewManager (zbus ), // backward compatibility
31- zos .ZMachineType : vm .NewManager (zbus ),
32- zos .NetworkLightType : netlight .NewManager (zbus ),
33- zos .ZMachineLightType : vmlight .NewManager (zbus ),
3447 zos .VolumeType : volume .NewManager (zbus ),
3548 zos .GatewayNameProxyType : gateway .NewNameManager (zbus ),
3649 zos .GatewayFQDNProxyType : gateway .NewFQDNManager (zbus ),
50+ zos .PublicIPType : pubip .NewManager (zbus ),
51+ zos .PublicIPv4Type : pubip .NewManager (zbus ), // backward compatibility
52+ }
53+
54+ if params .IsLight () {
55+ // served by netlightd, module "netlight". networkd does not run here.
56+ managers [zos .NetworkLightType ] = netlight .NewManager (zbus )
57+ managers [zos .ZMachineLightType ] = vmlight .NewManager (zbus )
58+ } else {
59+ // served by networkd, module "network". netlightd does not run here.
60+ managers [zos .NetworkType ] = network .NewManager (zbus )
61+ managers [zos .ZMachineType ] = vm .NewManager (zbus )
3762 }
3863
39- return provision . NewMapProvisioner ( managers )
64+ return managers
4065}
0 commit comments