Skip to content

Commit

Permalink
Remove multierr, update deps (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
majst01 authored May 15, 2023
1 parent a1413e8 commit ea6a6e3
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 198 deletions.
14 changes: 7 additions & 7 deletions cmd/metal-api/internal/grpc/event-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package grpc

import (
"context"
"errors"
"fmt"
"time"

"github.com/metal-stack/metal-api/cmd/metal-api/internal/datastore"
"github.com/metal-stack/metal-api/cmd/metal-api/internal/metal"
v1 "github.com/metal-stack/metal-api/pkg/api/v1"
"go.uber.org/multierr"
"go.uber.org/zap"
)

Expand All @@ -31,12 +31,12 @@ func (e *EventService) Send(ctx context.Context, req *v1.EventServiceSendRequest

failed := []string{}
processed := uint64(0)
var processErr error
var processErrs []error
for machineID, event := range req.Events {

m, err := e.ds.FindMachineByID(machineID)
if err != nil && !metal.IsNotFound(err) {
processErr = multierr.Append(processErr, fmt.Errorf("machine with ID:%s not found %w", machineID, err))
processErrs = append(processErrs, fmt.Errorf("machine with ID:%s not found %w", machineID, err))
failed = append(failed, machineID)
continue
}
Expand All @@ -51,15 +51,15 @@ func (e *EventService) Send(ctx context.Context, req *v1.EventServiceSendRequest
}
err = e.ds.CreateMachine(m)
if err != nil {
processErr = multierr.Append(processErr, err)
processErrs = append(processErrs, err)
failed = append(failed, machineID)
continue
}
}

ok := metal.AllProvisioningEventTypes[metal.ProvisioningEventType(event.Event)]
if !ok {
processErr = multierr.Append(processErr, err)
processErrs = append(processErrs, err)
failed = append(failed, machineID)
continue
}
Expand All @@ -72,7 +72,7 @@ func (e *EventService) Send(ctx context.Context, req *v1.EventServiceSendRequest

_, err = e.ds.ProvisioningEventForMachine(e.log, &ev, machineID)
if err != nil {
processErr = multierr.Append(processErr, err)
processErrs = append(processErrs, err)
failed = append(failed, machineID)
continue
}
Expand All @@ -82,5 +82,5 @@ func (e *EventService) Send(ctx context.Context, req *v1.EventServiceSendRequest
return &v1.EventServiceSendResponse{
Events: processed,
Failed: failed,
}, processErr
}, errors.Join(processErrs...)
}
7 changes: 3 additions & 4 deletions cmd/metal-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"github.com/go-openapi/spec"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.uber.org/multierr"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"

Expand Down Expand Up @@ -882,7 +881,7 @@ func evaluateVPNConnected() error {
return err
}

var updateErr error
var errs []error
for _, m := range ms {
m := m
if m.Allocation == nil || m.Allocation.VPN == nil {
Expand All @@ -897,13 +896,13 @@ func evaluateVPNConnected() error {
m.Allocation.VPN.Connected = connected
err := ds.UpdateMachine(&old, &m)
if err != nil {
updateErr = multierr.Append(updateErr, err)
errs = append(errs, err)
logger.Errorw("unable to update vpn connected state, continue anyway", "machine", m.ID, "error", err)
continue
}
logger.Infow("updated vpn connected state", "machine", m.ID, "connected", connected)
}
return updateErr
return errors.Join(errs...)
}

// might return (nil, nil) if auditing is disabled!
Expand Down
97 changes: 49 additions & 48 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ module github.com/metal-stack/metal-api
go 1.20

require (
github.com/Masterminds/semver/v3 v3.2.0
github.com/avast/retry-go/v4 v4.3.3
github.com/Masterminds/semver/v3 v3.2.1
github.com/avast/retry-go/v4 v4.3.4
github.com/aws/aws-sdk-go v1.44.175
github.com/dustin/go-humanize v1.0.1
github.com/emicklei/go-restful-openapi/v2 v2.9.1
// FIXME go-restful v3.10.x breaks imageCreate
github.com/emicklei/go-restful/v3 v3.9.0
github.com/go-openapi/spec v0.20.8
github.com/go-openapi/spec v0.20.9
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/juanfont/headscale v0.20.0
github.com/looplab/fsm v0.3.0
Expand All @@ -23,18 +23,17 @@ require (
github.com/metal-stack/security v0.6.6
github.com/metal-stack/v v1.0.3
github.com/nsqio/go-nsq v1.1.0
github.com/prometheus/client_golang v1.14.0
github.com/spf13/cobra v1.6.1
github.com/prometheus/client_golang v1.15.1
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.2
github.com/testcontainers/testcontainers-go v0.19.0
github.com/testcontainers/testcontainers-go v0.20.1
github.com/undefinedlabs/go-mpatch v1.0.6
go.uber.org/multierr v1.9.0
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.7.0
golang.org/x/sync v0.1.0
google.golang.org/grpc v1.53.0
google.golang.org/protobuf v1.28.1
golang.org/x/crypto v0.9.0
golang.org/x/sync v0.2.0
google.golang.org/grpc v1.55.0
google.golang.org/protobuf v1.30.0
gopkg.in/rethinkdb/rethinkdb-go.v6 v6.2.2
)

Expand All @@ -47,19 +46,19 @@ require (
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/avast/retry-go v3.0.0+incompatible // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/benbjohnson/clock v1.3.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bufbuild/connect-go v1.5.2 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/bufbuild/connect-go v1.7.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/containerd v1.6.19 // indirect
github.com/coreos/go-oidc/v3 v3.5.0 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set/v2 v2.2.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v23.0.1+incompatible // indirect
github.com/deckarep/golang-set/v2 v2.3.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker v23.0.6+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
Expand All @@ -71,37 +70,38 @@ require (
github.com/go-openapi/errors v0.20.3 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/runtime v0.25.0 // indirect
github.com/go-openapi/strfmt v0.21.3 // indirect
github.com/go-openapi/runtime v0.26.0 // indirect
github.com/go-openapi/strfmt v0.21.7 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.14.0 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
github.com/icza/dyno v0.0.0-20220812133438-f0b6f8a18845 // indirect
github.com/icza/dyno v0.0.0-20230330125955-09f820a8d9c0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.13.0 // indirect
github.com/jackc/pgconn v1.14.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.1 // indirect
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.13.0 // indirect
github.com/jackc/pgx/v4 v4.17.2 // indirect
github.com/jackc/pgproto3/v2 v2.3.2 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgtype v1.14.0 // indirect
github.com/jackc/pgx/v4 v4.18.1 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmoiron/sqlx v1.3.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/native v1.0.0 // indirect
github.com/josharian/native v1.1.0 // indirect
github.com/jsimonetti/rtnetlink v1.3.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.16.3 // indirect
Expand All @@ -112,43 +112,43 @@ require (
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/jwx v1.2.25 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mdlayher/netlink v1.7.1 // indirect
github.com/mdlayher/socket v0.4.0 // indirect
github.com/mdlayher/netlink v1.7.2 // indirect
github.com/mdlayher/socket v0.4.1 // indirect
github.com/meilisearch/meilisearch-go v0.24.0 // indirect
github.com/mitchellh/go-ps v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/opencontainers/runc v1.1.4 // indirect
github.com/opencontainers/image-spec v1.1.0-rc3 // indirect
github.com/opencontainers/runc v1.1.7 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
github.com/philip-bui/grpc-zerolog v1.0.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/puzpuzpuz/xsync/v2 v2.4.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20220927061507-ef77025ab5aa // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/rs/zerolog v1.29.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
Expand All @@ -157,24 +157,25 @@ require (
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.45.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.mongodb.org/mongo-driver v1.11.2 // indirect
go.mongodb.org/mongo-driver v1.11.3 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/goleak v1.1.12 // indirect
go.uber.org/multierr v1.9.0 // indirect
go4.org/intern v0.0.0-20230205224052-192e9f60865c // indirect
go4.org/mem v0.0.0-20220726221520-4f986261bf13 // indirect
go4.org/netipx v0.0.0-20220925034521-797b0c90d8ab // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230221090011-e4bae7ad2296 // indirect
golang.org/x/exp v0.0.0-20230306221820-f0f767cdffd6 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.3.0 // indirect; indirecct
golang.org/x/tools v0.6.0 // indirect
golang.org/x/tools v0.9.1 // indirect
golang.zx2c4.com/wireguard/windows v0.5.3 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
gopkg.in/cenkalti/backoff.v2 v2.2.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
Loading

0 comments on commit ea6a6e3

Please sign in to comment.