Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/kernel/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,25 @@ func (k Params) IsLight() bool {

// ISV3Light check if node is running in v3light mode
func (k Params) IsV3Light() bool {
version, found := GetParams().GetOne("version")
version, found := k.GetOne("version")
return found && version == "v3light"
}

// getVersion checks if node is running version 4
func (k Params) GetVersion() string {
version, _ := GetParams().GetOne("version")
version, _ := k.GetOne("version")
return version
}

// IsV4 checks if node is running version 4
func (k Params) IsV4() bool {
version, found := GetParams().GetOne("version")
version, found := k.GetOne("version")
return found && version == "v4"
}

// IsV3 checks if node is running normal version 3
func (k Params) IsV3() bool {
version, found := GetParams().GetOne("version")
version, found := k.GetOne("version")
return found && version == "v3"
}

Expand Down
39 changes: 32 additions & 7 deletions pkg/primitives/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/threefoldtech/zbus"
"github.com/threefoldtech/zos_base/pkg/gridtypes"
"github.com/threefoldtech/zos_base/pkg/gridtypes/zos"
"github.com/threefoldtech/zos_base/pkg/kernel"
"github.com/threefoldtech/zos_base/pkg/primitives/gateway"
"github.com/threefoldtech/zos_base/pkg/primitives/network"
netlight "github.com/threefoldtech/zos_base/pkg/primitives/network-light"
Expand All @@ -19,22 +20,46 @@ import (
)

// NewPrimitivesProvisioner creates a new 0-OS provisioner
//
// Only the workload types this node variant can actually serve are registered.
// A manager reaches its worker over zbus, and a light node runs netlightd
// (module "netlight") in place of networkd (module "network"), so registering
// the full network backed types there would leave a request queued for a module
// that never answers. The provisioner rejects an unregistered type outright,
// which surfaces to the owner as a failed workload instead of a deployment that
// never resolves. Keep this in step with systemMonitor.GetNodeFeatures, which
// advertises the same split to the grid.
func NewPrimitivesProvisioner(zbus zbus.Client) provision.Provisioner {
return provision.NewMapProvisioner(managersFor(zbus, kernel.GetParams()))
}

// managersFor builds the set of workload managers the given node variant can
// actually serve. Split out from NewPrimitivesProvisioner so the variant gating
// is testable without a matching /proc/cmdline.
func managersFor(zbus zbus.Client, params kernel.Params) map[gridtypes.WorkloadType]provision.Manager {
// types every variant serves. their managers talk to storaged, flistd,
// contd and vmd, which run everywhere.
managers := map[gridtypes.WorkloadType]provision.Manager{
zos.ZMountType: zmount.NewManager(zbus),
zos.ZLogsType: zlogs.NewManager(zbus),
zos.QuantumSafeFSType: qsfs.NewManager(zbus),
zos.ZDBType: zdb.NewManager(zbus),
zos.NetworkType: network.NewManager(zbus),
zos.PublicIPType: pubip.NewManager(zbus),
zos.PublicIPv4Type: pubip.NewManager(zbus), // backward compatibility
zos.ZMachineType: vm.NewManager(zbus),
zos.NetworkLightType: netlight.NewManager(zbus),
zos.ZMachineLightType: vmlight.NewManager(zbus),
zos.VolumeType: volume.NewManager(zbus),
zos.GatewayNameProxyType: gateway.NewNameManager(zbus),
zos.GatewayFQDNProxyType: gateway.NewFQDNManager(zbus),
zos.PublicIPType: pubip.NewManager(zbus),
zos.PublicIPv4Type: pubip.NewManager(zbus), // backward compatibility
}

if params.IsLight() {
// served by netlightd, module "netlight". networkd does not run here.
managers[zos.NetworkLightType] = netlight.NewManager(zbus)
managers[zos.ZMachineLightType] = vmlight.NewManager(zbus)
} else {
// served by networkd, module "network". netlightd does not run here.
managers[zos.NetworkType] = network.NewManager(zbus)
managers[zos.ZMachineType] = vm.NewManager(zbus)
}

return provision.NewMapProvisioner(managers)
return managers
}
Loading
Loading