Skip to content

Commit 1933b10

Browse files
committed
fixes provisiond hanging specially with zoslight nodes
Signed-off-by: Ashraf Fouda <ashraf.m.fouda@gmail.com>
1 parent 7a63627 commit 1933b10

3 files changed

Lines changed: 260 additions & 80 deletions

File tree

‎pkg/kernel/kernel.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,25 @@ func (k Params) IsLight() bool {
7272

7373
// ISV3Light check if node is running in v3light mode
7474
func (k Params) IsV3Light() bool {
75-
version, found := GetParams().GetOne("version")
75+
version, found := k.GetOne("version")
7676
return found && version == "v3light"
7777
}
7878

7979
// getVersion checks if node is running version 4
8080
func (k Params) GetVersion() string {
81-
version, _ := GetParams().GetOne("version")
81+
version, _ := k.GetOne("version")
8282
return version
8383
}
8484

8585
// IsV4 checks if node is running version 4
8686
func (k Params) IsV4() bool {
87-
version, found := GetParams().GetOne("version")
87+
version, found := k.GetOne("version")
8888
return found && version == "v4"
8989
}
9090

9191
// IsV3 checks if node is running normal version 3
9292
func (k Params) IsV3() bool {
93-
version, found := GetParams().GetOne("version")
93+
version, found := k.GetOne("version")
9494
return found && version == "v3"
9595
}
9696

‎pkg/primitives/provisioner.go‎

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
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.
2232
func 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

Comments
 (0)