Skip to content
Open
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
43 changes: 29 additions & 14 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
version: "2"
linters:
disable:
- unused
enable:
- errcheck
- gofmt
- govet
- ineffassign
- unconvert
- staticcheck
- gocyclo
enable-all: false
linters-settings:
gocyclo:
# Minimal code complexity to report.
# Default: 30 (but we recommend 10-20)
min-complexity: 100
run:
timeout: 20m
- unconvert
settings:
gocyclo:
# Minimal code complexity to report.
# Default: 30 (but we recommend 10-20)
min-complexity: 100
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
4 changes: 2 additions & 2 deletions cmds/identityd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ func main() {
log.Fatal().Msgf("fail to connect to message broker server: %v\n", err)
}

server.Register(zbus.ObjectID{Name: "manager", Version: "0.0.1"}, idMgr)
server.Register(zbus.ObjectID{Name: "monitor", Version: "0.0.1"}, monitor)
_ = server.Register(zbus.ObjectID{Name: "manager", Version: "0.0.1"}, idMgr)
_ = server.Register(zbus.ObjectID{Name: "monitor", Version: "0.0.1"}, monitor)

ctx, cancel := utils.WithSignal(context.Background())
// register the cancel function with defer if the process stops because of a update
Expand Down
10 changes: 5 additions & 5 deletions cmds/modules/api_gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ var Module cli.Command = cli.Command{

func action(cli *cli.Context) error {
var (
msgBrokerCon string = cli.String("broker")
workerNr uint = cli.Uint("workers")
msgBrokerCon = cli.String("broker")
workerNr = cli.Uint("workers")
)

server, err := zbus.NewRedisServer(module, msgBrokerCon, workerNr)
Expand Down Expand Up @@ -78,7 +78,7 @@ func action(cli *cli.Context) error {
return fmt.Errorf("failed to create api gateway: %w", err)
}

server.Register(zbus.ObjectID{Name: "api-gateway", Version: "0.0.1"}, gw)
_ = server.Register(zbus.ObjectID{Name: "api-gateway", Version: "0.0.1"}, gw)

ctx, _ := utils.WithSignal(context.Background())
utils.OnDone(ctx, func(_ error) {
Expand Down Expand Up @@ -112,7 +112,7 @@ func action(cli *cli.Context) error {

// this ctx is used to allow the node to restart the peer without leaving any unwanted open connections
currentPeerCtx, cancel := context.WithCancel(ctx)
backoff.Retry(func() error {
_ = backoff.Retry(func() error {
_, err = peer.NewPeer(
currentPeerCtx,
hex.EncodeToString(pair.Seed()),
Expand Down Expand Up @@ -181,7 +181,7 @@ func action(cli *cli.Context) error {
}

currentPeerCtx, cancel = context.WithCancel(ctx)
backoff.Retry(func() error {
_ = backoff.Retry(func() error {
_, err = peer.NewPeer(
currentPeerCtx,
hex.EncodeToString(pair.Seed()),
Expand Down
10 changes: 5 additions & 5 deletions cmds/modules/contd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ var Module cli.Command = cli.Command{

func action(cli *cli.Context) error {
var (
moduleRoot string = cli.String("root")
msgBrokerCon string = cli.String("broker")
workerNr uint = cli.Uint("workers")
containerdCon string = cli.String("containerd")
moduleRoot = cli.String("root")
msgBrokerCon = cli.String("broker")
workerNr = cli.Uint("workers")
containerdCon = cli.String("containerd")
)

// wait for shim-logs to be available before starting
Expand Down Expand Up @@ -83,7 +83,7 @@ func action(cli *cli.Context) error {

containerd := container.New(client, moduleRoot, containerdCon)

server.Register(zbus.ObjectID{Name: module, Version: "0.0.1"}, containerd)
_ = server.Register(zbus.ObjectID{Name: module, Version: "0.0.1"}, containerd)

log.Info().
Str("broker", msgBrokerCon).
Expand Down
8 changes: 4 additions & 4 deletions cmds/modules/flistd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ var Module cli.Command = cli.Command{

func action(cli *cli.Context) error {
var (
moduleRoot string = cli.String("root")
msgBrokerCon string = cli.String("broker")
workerNr uint = cli.Uint("workers")
moduleRoot = cli.String("root")
msgBrokerCon = cli.String("broker")
workerNr = cli.Uint("workers")
)

redis, err := zbus.NewRedisClient(msgBrokerCon)
Expand All @@ -66,7 +66,7 @@ func action(cli *cli.Context) error {
}

mod := flist.New(moduleRoot, storage)
server.Register(zbus.ObjectID{Name: module, Version: "0.0.1"}, mod)
_ = server.Register(zbus.ObjectID{Name: module, Version: "0.0.1"}, mod)

ctx, _ := utils.WithSignal(context.Background())

Expand Down
8 changes: 4 additions & 4 deletions cmds/modules/gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ var Module cli.Command = cli.Command{

func action(cli *cli.Context) error {
var (
moduleRoot string = cli.String("root")
msgBrokerCon string = cli.String("broker")
workerNr uint = cli.Uint("workers")
moduleRoot = cli.String("root")
msgBrokerCon = cli.String("broker")
workerNr = cli.Uint("workers")
)

server, err := zbus.NewRedisServer(module, msgBrokerCon, workerNr)
Expand All @@ -62,7 +62,7 @@ func action(cli *cli.Context) error {
if err != nil {
return errors.Wrap(err, "failed to construct gateway object")
}
server.Register(zbus.ObjectID{Name: "manager", Version: "0.0.1"}, mod)
_ = server.Register(zbus.ObjectID{Name: "manager", Version: "0.0.1"}, mod)

ctx, cancel := utils.WithSignal(context.Background())
defer cancel()
Expand Down
6 changes: 3 additions & 3 deletions cmds/modules/networkd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ var Module cli.Command = cli.Command{

func action(cli *cli.Context) error {
var (
root string = cli.String("root")
broker string = cli.String("broker")
root = cli.String("root")
broker = cli.String("broker")
)

if err := os.MkdirAll(root, 0755); err != nil {
Expand Down Expand Up @@ -159,7 +159,7 @@ func startZBusServer(ctx context.Context, broker string, networker pkg.Networker
log.Error().Err(err).Msgf("fail to connect to message broker server")
}

server.Register(zbus.ObjectID{Name: module, Version: "0.0.1"}, networker)
_ = server.Register(zbus.ObjectID{Name: module, Version: "0.0.1"}, networker)

log.Info().
Str("broker", broker).
Expand Down
20 changes: 12 additions & 8 deletions cmds/modules/noded/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func registerationServer(ctx context.Context, msgBrokerCon string, info registra
}

registrar := registrar.NewRegistrar(ctx, redis, info)
server.Register(zbus.ObjectID{Name: "registrar", Version: "0.0.1"}, registrar)
_ = server.Register(zbus.ObjectID{Name: "registrar", Version: "0.0.1"}, registrar)
log.Debug().Msg("object registered")
if err := server.Run(ctx); err != nil && err != context.Canceled {
log.Fatal().Err(err).Msg("unexpected error exited registrar")
Expand All @@ -81,9 +81,9 @@ func registerationServer(ctx context.Context, msgBrokerCon string, info registra

func action(cli *cli.Context) error {
var (
msgBrokerCon string = cli.String("broker")
printID bool = cli.Bool("id")
printNet bool = cli.Bool("net")
msgBrokerCon = cli.String("broker")
printID = cli.Bool("id")
printNet = cli.Bool("net")
)
env := environment.MustGet()
subURLs := env.SubstrateURL
Expand Down Expand Up @@ -161,7 +161,11 @@ func action(cli *cli.Context) error {
WithSecureBoot(secureBoot).
WithVirtualized(len(hypervisor) != 0)

go registerationServer(ctx, msgBrokerCon, info)
go func() {
if err := registerationServer(ctx, msgBrokerCon, info); err != nil {
log.Error().Err(err).Msg("registration server failed")
}
}()
log.Info().Msg("start perf scheduler")

perfMon, err := perf.NewPerformanceMonitor(msgBrokerCon)
Expand Down Expand Up @@ -232,9 +236,9 @@ func action(cli *cli.Context) error {
log.Fatal().Err(err).Msg("failed to initialize host monitor")
}

server.Register(zbus.ObjectID{Name: "host", Version: "0.0.1"}, host)
server.Register(zbus.ObjectID{Name: "system", Version: "0.0.1"}, system)
server.Register(zbus.ObjectID{Name: "performance-monitor", Version: "0.0.1"}, perfMon)
_ = server.Register(zbus.ObjectID{Name: "host", Version: "0.0.1"}, host)
_ = server.Register(zbus.ObjectID{Name: "system", Version: "0.0.1"}, system)
_ = server.Register(zbus.ObjectID{Name: "performance-monitor", Version: "0.0.1"}, perfMon)

log.Info().Uint32("node", node).Uint32("twin", twin).Msg("node registered")

Expand Down
4 changes: 2 additions & 2 deletions cmds/modules/powerd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ var Module cli.Command = cli.Command{

func action(cli *cli.Context) error {
var (
msgBrokerCon string = cli.String("broker")
powerdLabel string = "powerd"
msgBrokerCon = cli.String("broker")
powerdLabel = "powerd"
)

ctx, _ := utils.WithSignal(cli.Context)
Expand Down
21 changes: 11 additions & 10 deletions cmds/modules/provisiond/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ func runChecks(ctx context.Context, rootDir string, cl zbus.Client) error {
log.Info().Err(zuiErr).Send()
}

cmd.CombinedOutput()
_, _ = cmd.CombinedOutput()
err := cmd.Run()
if err == context.Canceled {
switch err {
case context.Canceled:
return err
} else if err == nil {
case nil:
return nil
}

Expand All @@ -128,9 +129,9 @@ func runChecks(ctx context.Context, rootDir string, cl zbus.Client) error {

func action(cli *cli.Context) error {
var (
msgBrokerCon string = cli.String("broker")
rootDir string = cli.String("root")
integrity bool = cli.Bool("integrity")
msgBrokerCon = cli.String("broker")
rootDir = cli.String("root")
integrity = cli.Bool("integrity")
)

server, err := zbus.NewRedisServer(serverName, msgBrokerCon, 1)
Expand Down Expand Up @@ -194,7 +195,7 @@ func action(cli *cli.Context) error {
network := stubs.NewNetworkerStub(cl)
bo := backoff.NewExponentialBackOff()
bo.MaxElapsedTime = 0
backoff.RetryNotify(func() error {
_ = backoff.RetryNotify(func() error {
return network.Ready(cli.Context)
}, bo, func(err error, d time.Duration) {
log.Error().Err(err).Msg("networkd is not ready yet")
Expand Down Expand Up @@ -348,14 +349,14 @@ func action(cli *cli.Context) error {
return errors.Wrap(err, "failed to instantiate provision engine")
}

server.Register(
_ = server.Register(
zbus.ObjectID{Name: provisionModule, Version: "0.0.1"},
pkg.Provision(engine),
)

server.Register(
_ = server.Register(
zbus.ObjectID{Name: statisticsModule, Version: "0.0.1"},
pkg.Statistics(primitives.NewStatisticsStream(statistics)),
primitives.NewStatisticsStream(statistics),
)

log.Info().
Expand Down
8 changes: 4 additions & 4 deletions cmds/modules/qsfsd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ var Module cli.Command = cli.Command{

func action(cli *cli.Context) error {
var (
moduleRoot string = cli.String("root")
msgBrokerCon string = cli.String("broker")
workerNr uint = cli.Uint("workers")
moduleRoot = cli.String("root")
msgBrokerCon = cli.String("broker")
workerNr = cli.Uint("workers")
)

server, err := zbus.NewRedisServer(module, msgBrokerCon, workerNr)
Expand All @@ -66,7 +66,7 @@ func action(cli *cli.Context) error {
return errors.Wrap(err, "failed to construct qsfsd object")
}

server.Register(zbus.ObjectID{Name: "manager", Version: "0.0.1"}, mod)
_ = server.Register(zbus.ObjectID{Name: "manager", Version: "0.0.1"}, mod)
log.Info().
Str("broker", msgBrokerCon).
Uint("worker nr", workerNr).
Expand Down
6 changes: 3 additions & 3 deletions cmds/modules/storaged/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var Module cli.Command = cli.Command{

func action(cli *cli.Context) error {
var (
msgBrokerCon string = cli.String("broker")
workerNr uint = cli.Uint("workers")
msgBrokerCon = cli.String("broker")
workerNr = cli.Uint("workers")
)

storageModule, err := storage.New(cli.Context)
Expand All @@ -53,7 +53,7 @@ func action(cli *cli.Context) error {
return errors.Wrap(err, "fail to connect to message broker server")
}

server.Register(zbus.ObjectID{Name: "storage", Version: "0.0.1"}, storageModule)
_ = server.Register(zbus.ObjectID{Name: "storage", Version: "0.0.1"}, storageModule)

log.Info().
Str("broker", msgBrokerCon).
Expand Down
8 changes: 4 additions & 4 deletions cmds/modules/vmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ func copyDepth1(src, dst string) error {

func action(cli *cli.Context) error {
var (
moduleRoot string = cli.String("root")
msgBrokerCon string = cli.String("broker")
workerNr uint = cli.Uint("workers")
moduleRoot = cli.String("root")
msgBrokerCon = cli.String("broker")
workerNr = cli.Uint("workers")
)

if err := os.MkdirAll(moduleRoot, 0755); err != nil {
Expand Down Expand Up @@ -140,7 +140,7 @@ func action(cli *cli.Context) error {
log.Error().Err(err).Msg("failed to clean up deprecated module root")
}

server.Register(zbus.ObjectID{Name: "manager", Version: "0.0.1"}, mod)
_ = server.Register(zbus.ObjectID{Name: "manager", Version: "0.0.1"}, mod)

ctx, _ := utils.WithSignal(context.Background())
utils.OnDone(ctx, func(_ error) {
Expand Down
6 changes: 3 additions & 3 deletions cmds/modules/zbusdebug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ var (

func action(cli *cli.Context) error {
var (
msgBrokerCon string = cli.String("broker")
module string = cli.String("module")
msgBrokerCon = cli.String("broker")
module = cli.String("module")
)

cl, err := zbus.NewRedisClient(msgBrokerCon)
Expand Down Expand Up @@ -99,7 +99,7 @@ func printModuleStatus(ctx context.Context, cl zbus.Client, module string) error
enc := yaml.NewEncoder(os.Stdout)
defer enc.Close()

enc.Encode(status)
_ = enc.Encode(status)
fmt.Println()
return nil
}
Loading
Loading