From f3c9c0516e166244da8b466a0cdd9b180a0dec78 Mon Sep 17 00:00:00 2001 From: Christophe de Carvalho Date: Wed, 1 Apr 2020 16:26:36 +0200 Subject: [PATCH 1/3] send node ID v1 to the explorer --- pkg/identity/store.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/identity/store.go b/pkg/identity/store.go index 4775078f1..e762d2fcb 100644 --- a/pkg/identity/store.go +++ b/pkg/identity/store.go @@ -11,6 +11,7 @@ import ( "github.com/jbenet/go-base58" "github.com/threefoldtech/zos/pkg/gedis/types/directory" + "github.com/threefoldtech/zos/pkg/network" "github.com/threefoldtech/zos/pkg/geoip" @@ -39,8 +40,11 @@ func (s *httpIDStore) RegisterNode(node pkg.Identifier, farm pkg.FarmID, version pk := base58.Decode(node.Identity()) + v1ID, _ := network.NodeIDv1() + err := json.NewEncoder(&buf).Encode(directory.TfgridNode2{ NodeID: node.Identity(), + NodeIDv1: v1ID, FarmID: uint64(farm), OsVersion: version, Location: directory.TfgridLocation1{ From 22ede1c2b73e6994f94eb6002dd7211d800a63cb Mon Sep 17 00:00:00 2001 From: Christophe de Carvalho Date: Tue, 24 Mar 2020 15:38:19 +0100 Subject: [PATCH 2/3] handle error when smartcl returns an empty response fixes #608 --- pkg/capacity/capacity.go | 6 ++++++ pkg/capacity/smartctl/smartctl.go | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/pkg/capacity/capacity.go b/pkg/capacity/capacity.go index 848282fc6..4e6dfa50e 100644 --- a/pkg/capacity/capacity.go +++ b/pkg/capacity/capacity.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/pkg/errors" + "github.com/rs/zerolog/log" "github.com/shirou/gopsutil/host" "github.com/threefoldtech/zos/pkg/capacity/dmi" "github.com/threefoldtech/zos/pkg/capacity/smartctl" @@ -78,6 +79,11 @@ type Disks struct { // Disks list and parse the hardware information using smartctl func (r *ResourceOracle) Disks() (d Disks, err error) { devices, err := smartctl.ListDevices() + if errors.Is(err, smartctl.ErrEmpty) { + // TODO: for now we allow to not have the smartctl dump of all the disks + log.Warn().Err(err).Msg("smartctl did not found any disk on the system") + return d, nil + } if err != nil { return } diff --git a/pkg/capacity/smartctl/smartctl.go b/pkg/capacity/smartctl/smartctl.go index f6010c102..1097827d7 100644 --- a/pkg/capacity/smartctl/smartctl.go +++ b/pkg/capacity/smartctl/smartctl.go @@ -1,6 +1,7 @@ package smartctl import ( + "errors" "fmt" "os/exec" "regexp" @@ -11,6 +12,9 @@ var reScan = regexp.MustCompile(`(?m)^([^\s]+)\s+-d\s+([^\s]+)\s+#`) var reHeader = regexp.MustCompile(`(?m)([^\[]+)\[([^\[]+)\]`) var reInfo = regexp.MustCompile(`(?m)([^:]+):\s+(.+)`) +// ErrEmpty is return when smatctl doesn't find any device +var ErrEmpty = errors.New("smartctl returned an empty response") + // Device represents a device as returned by "smartctl --scan" type Device struct { Type string @@ -25,6 +29,10 @@ func ListDevices() ([]Device, error) { return nil, err } + if len(output) == 0 { + return nil, ErrEmpty + } + return parseScan(output) } From 12be93082ec8bd663e209c63657a2d8ba4f819ac Mon Sep 17 00:00:00 2001 From: Dylan Verstraete Date: Mon, 23 Mar 2020 10:13:08 +0100 Subject: [PATCH 3/3] Fixes empty reservation chache bug (#584) * fixes empty reservation chache issue * update local_store.go with requested changes --- pkg/provision/local_store.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/provision/local_store.go b/pkg/provision/local_store.go index 889617e5a..c1a951e8a 100644 --- a/pkg/provision/local_store.go +++ b/pkg/provision/local_store.go @@ -109,7 +109,15 @@ func NewFSStore(root string) (*FSStore, error) { } func (s *FSStore) removeAllButPersistent(rootPath string) error { - err := filepath.Walk(rootPath, func(path string, info os.FileInfo, r error) error { + // if rootPath is not present on the filesystem, return + _, err := os.Stat(rootPath) + if os.IsNotExist(err) { + return nil + } else if err != nil { + return err + } + + err = filepath.Walk(rootPath, func(path string, info os.FileInfo, r error) error { if r != nil { return r }