fix (events): convert multierror to stdlib error (#3743)

* fix (events): convert multierror to stdlib error

multierror errors will be converted to a stdlib error (because
multierror doesn't support json marshaling).

* refact (errors): convert from multierror to stdlib errors.Join(...)

* refact: convert from pkg/errors to stdlib error wrapping
This commit is contained in:
Jim authored and GitHub committed 2023-09-17 19:35:43 -04:00
1 parent 98f8383a2b
commit 0d19892e03
28 files changed
+142 -152

No files matched your search

+5 -6
View File
@@ -7,6 +7,7 @@ package ops
import (
"context"
"errors"
"fmt"
"net"
"net/http"
@@ -18,10 +19,8 @@ import (
"github.com/hashicorp/boundary/internal/daemon/worker"
"github.com/hashicorp/go-cleanhttp"
"github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-multierror"
"github.com/hashicorp/go-secure-stdlib/listenerutil"
"github.com/mitchellh/cli"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
@@ -89,7 +88,7 @@ func (s *Server) Start() {
func (s *Server) Shutdown() error {
const op = "ops.(Server).Shutdown"
var closeErrors *multierror.Error
var closeErrors error
for _, b := range s.bundles {
if b == nil || b.ln == nil || b.ln.Config == nil || b.ln.OpsListener == nil || b.ln.HTTPServer == nil {
return fmt.Errorf("%s: missing bundle, listener or its fields", op)
@@ -100,17 +99,17 @@ func (s *Server) Shutdown() error {
err := b.ln.HTTPServer.Shutdown(ctx)
if err != nil {
multierror.Append(closeErrors, fmt.Errorf("%s: failed to shutdown http server: %w", op, err))
errors.Join(closeErrors, fmt.Errorf("%s: failed to shutdown http server: %w", op, err))
}
err = b.ln.OpsListener.Close()
err = listenerCloseErrorCheck(b.ln.Config.Type, err)
if err != nil {
multierror.Append(closeErrors, fmt.Errorf("%s: failed to close listener mux: %w", op, err))
errors.Join(closeErrors, fmt.Errorf("%s: failed to close listener mux: %w", op, err))
}
}
return closeErrors.ErrorOrNil()
return closeErrors
}
// WaitIfHealthExists waits for a configurable period of time `d` if the health endpoint has been