Skip to content

Commit 8cc357d

Browse files
check on errors length of all healthchecks (#2352)
* recessively check on errors length of all healthchecks * check the result type assertion * use redis.Bytes instead of asserting result to []byte
1 parent 02480a9 commit 8cc357d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

pkg/diagnostics/diagnostics.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88

99
"github.com/gomodule/redigo/redis"
1010
"github.com/threefoldtech/zbus"
11-
"github.com/threefoldtech/zos/pkg"
1211
"github.com/threefoldtech/zos/pkg/utils"
1312
)
1413

@@ -119,19 +118,24 @@ func (m *DiagnosticsManager) isHealthy() bool {
119118
conn := m.redisPool.Get()
120119
defer conn.Close()
121120

122-
data, err := conn.Do("GET", testNetworkKey)
121+
data, err := redis.Bytes(conn.Do("GET", testNetworkKey))
123122
if err != nil || data == nil {
124123
return false
125124
}
126125

127-
var result pkg.TaskResult
128-
if err := json.Unmarshal(data.([]byte), &result); err != nil {
129-
return false
126+
var result struct {
127+
Result map[string][]string `json:"result"`
130128
}
131129

132-
if len(result.Result.(map[string]interface{})) != 0 {
130+
if err := json.Unmarshal(data, &result); err != nil {
133131
return false
134132
}
135133

134+
for _, errors := range result.Result {
135+
if len(errors) > 0 {
136+
return false
137+
}
138+
}
139+
136140
return true
137141
}

0 commit comments

Comments
 (0)