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
14 changes: 13 additions & 1 deletion cmds/capacityd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const module = "monitor"
func cap(ctx context.Context, client zbus.Client) {
storage := stubs.NewStorageModuleStub(client)
identity := stubs.NewIdentityManagerStub(client)
network := stubs.NewNetworkerStub(client)
cl, err := bcdbClient()
if err != nil {
log.Fatal().Err(err).Msg("failed to connect to bcdb backend")
Expand All @@ -34,6 +35,17 @@ func cap(ctx context.Context, client zbus.Client) {
// call this now so we block here until identityd is ready to serve us
nodeID := identity.NodeID().Identity()

// block until networkd is ready to serve request from zbus
// this is used to prevent uptime and online status to the explorer if the node is not in a fully ready
// https://github.com/threefoldtech/zos/issues/632
bo := backoff.NewExponentialBackOff()
bo.MaxElapsedTime = 0
backoff.RetryNotify(func() error {
return network.Ready()
}, bo, func(err error, d time.Duration) {
log.Error().Err(err).Msgf("networkd is not ready yet")
})

r := capacity.NewResourceOracle(storage)

log.Info().Msg("inspect hardware resources")
Expand Down Expand Up @@ -75,7 +87,7 @@ func cap(ctx context.Context, client zbus.Client) {
log.Info().Msg("sends capacity detail to BCDB")
return cl.NodeSetCapacity(nodeID, ru, *dmi, disks, hypervisor)
}
bo := backoff.NewExponentialBackOff()
bo = backoff.NewExponentialBackOff()
bo.MaxElapsedTime = 0 // retry forever
backoff.RetryNotify(setCapacity, bo, func(err error, d time.Duration) {
log.Error().
Expand Down
13 changes: 13 additions & 0 deletions cmds/provisiond/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path/filepath"
"time"

"github.com/cenkalti/backoff/v3"
"github.com/threefoldtech/zos/pkg"
"github.com/threefoldtech/zos/pkg/app"
"github.com/threefoldtech/zos/pkg/environment"
Expand Down Expand Up @@ -92,6 +93,18 @@ func main() {
identity := stubs.NewIdentityManagerStub(zbusCl)
nodeID := identity.NodeID()

// block until networkd is ready to serve request from zbus
// this is used to prevent uptime and online status to the explorer if the node is not in a fully ready
// https://github.com/threefoldtech/zos/issues/632
network := stubs.NewNetworkerStub(zbusCl)
bo := backoff.NewExponentialBackOff()
bo.MaxElapsedTime = 0
backoff.RetryNotify(func() error {
return network.Ready()
}, bo, func(err error, d time.Duration) {
log.Error().Err(err).Msgf("networkd is not ready yet")
})

// to get reservation from tnodb
e, err := app.ExplorerClient()
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ type Member struct {

//Networker is the interface for the network module
type Networker interface {
// Ready return nil is networkd is ready to operate
// This function is used by other deamon to test if networkd is done booting
Ready() error

// Create a new network resource
CreateNR(Network) (string, error)
// Delete a network resource
Expand Down
4 changes: 4 additions & 0 deletions pkg/network/networker.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ func validatePeer(p pkg.Peer) error {
return nil
}

func (n *networker) Ready() error {
return nil
}

func (n *networker) Join(networkdID pkg.NetID, containerID string, addrs []string, publicIP6 bool) (join pkg.Member, err error) {
// TODO:
// 1- Make sure this network id is actually deployed
Expand Down
13 changes: 13 additions & 0 deletions pkg/stubs/network_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@ func (s *NetworkerStub) PublicAddresses(ctx context.Context) (<-chan pkg.Netlink
return ch, nil
}

func (s *NetworkerStub) Ready() (ret0 error) {
args := []interface{}{}
result, err := s.client.Request(s.module, s.object, "Ready", args...)
if err != nil {
panic(err)
}
ret0 = new(zbus.RemoteError)
if err := result.Unmarshal(0, &ret0); err != nil {
panic(err)
}
return
}

func (s *NetworkerStub) RemoveTap(arg0 pkg.NetID) (ret0 error) {
args := []interface{}{arg0}
result, err := s.client.Request(s.module, s.object, "RemoveTap", args...)
Expand Down