Remove hashicorp/go-multierror
Signed-off-by: Jin Dong <jin.dong@databricks.com>
This commit is contained in:
@@ -26,7 +26,6 @@ import (
|
||||
v1 "github.com/containerd/nri/types/v1"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/opencontainers/selinux/go-selinux"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
|
||||
@@ -61,7 +60,7 @@ func (c *Controller) Start(ctx context.Context, id string) (cin sandbox.Controll
|
||||
defer func() {
|
||||
if retErr != nil && cleanupErr != nil {
|
||||
log.G(ctx).WithField("id", id).WithError(cleanupErr).Errorf("failed to fully teardown sandbox resources after earlier error: %s", retErr)
|
||||
retErr = multierror.Append(retErr, CleanupErr{cleanupErr})
|
||||
retErr = errors.Join(retErr, CleanupErr{cleanupErr})
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
|
||||
"github.com/containerd/go-cni"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
@@ -258,8 +257,8 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
|
||||
cleanupErr = fmt.Errorf("failed to cleanup sandbox: %w", cerr)
|
||||
|
||||
// Strip last error as cleanup error to handle separately
|
||||
if merr, ok := err.(*multierror.Error); ok {
|
||||
if errs := merr.WrappedErrors(); len(errs) > 0 {
|
||||
if merr, ok := err.(interface{ Unwrap() []error }); ok {
|
||||
if errs := merr.Unwrap(); len(errs) > 0 {
|
||||
err = errs[0]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ package sbserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/log"
|
||||
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ func (c *criService) ListPodSandboxStats(
|
||||
) (*runtime.ListPodSandboxStatsResponse, error) {
|
||||
sandboxes := c.sandboxesForListPodSandboxStatsRequest(r)
|
||||
|
||||
var errs *multierror.Error
|
||||
var errs []error
|
||||
podSandboxStats := new(runtime.ListPodSandboxStatsResponse)
|
||||
for _, sandbox := range sandboxes {
|
||||
sandboxStats, err := c.podSandboxStats(ctx, sandbox)
|
||||
@@ -42,13 +42,13 @@ func (c *criService) ListPodSandboxStats(
|
||||
case errdefs.IsUnavailable(err):
|
||||
log.G(ctx).WithField("podsandboxid", sandbox.ID).Debugf("failed to get pod sandbox stats, this is likely a transient error: %v", err)
|
||||
case err != nil:
|
||||
errs = multierror.Append(errs, fmt.Errorf("failed to decode sandbox container metrics for sandbox %q: %w", sandbox.ID, err))
|
||||
errs = append(errs, fmt.Errorf("failed to decode sandbox container metrics for sandbox %q: %w", sandbox.ID, err))
|
||||
default:
|
||||
podSandboxStats.Stats = append(podSandboxStats.Stats, sandboxStats)
|
||||
}
|
||||
}
|
||||
|
||||
return podSandboxStats, errs.ErrorOrNil()
|
||||
return podSandboxStats, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func (c *criService) sandboxesForListPodSandboxStatsRequest(r *runtime.ListPodSandboxStatsRequest) []sandboxstore.Sandbox {
|
||||
|
||||
Reference in New Issue
Block a user