Skip to content
Merged
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
5 changes: 3 additions & 2 deletions container/common/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
package common

import (
"errors"
"fmt"
"io/fs"
"math"
"os"
"path"
Expand All @@ -25,7 +27,6 @@ import (

"github.com/karrick/godirwalk"
"github.com/opencontainers/cgroups"
"github.com/pkg/errors"
"golang.org/x/sys/unix"

"github.com/google/cadvisor/container"
Expand Down Expand Up @@ -308,7 +309,7 @@ func listDirectories(dirpath string, parent string, recursive bool, output map[s
dirents, err := godirwalk.ReadDirents(dirpath, buf)
if err != nil {
// Ignore if this hierarchy does not exist.
if os.IsNotExist(errors.Cause(err)) {
if errors.Is(err, fs.ErrNotExist) {
err = nil
}
return err
Expand Down
8 changes: 4 additions & 4 deletions container/containerd/identifiers/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
package identifiers

import (
"fmt"
"regexp"

"github.com/containerd/errdefs"
"github.com/pkg/errors"
)

const (
Expand All @@ -64,15 +64,15 @@ var (
// In general identifiers that pass this validation should be safe for use as filesystem path components.
func Validate(s string) error {
if len(s) == 0 {
return errors.Wrapf(errdefs.ErrInvalidArgument, "identifier must not be empty")
return fmt.Errorf("identifier must not be empty: %w", errdefs.ErrInvalidArgument)
}

if len(s) > maxLength {
return errors.Wrapf(errdefs.ErrInvalidArgument, "identifier %q greater than maximum length (%d characters)", s, maxLength)
return fmt.Errorf("identifier %q greater than maximum length (%d characters): %w", s, maxLength, errdefs.ErrInvalidArgument)
}

if !identifierRe.MatchString(s) {
return errors.Wrapf(errdefs.ErrInvalidArgument, "identifier %q must match %v", s, identifierRe)
return fmt.Errorf("identifier %q must match %v: %w", s, identifierRe, errdefs.ErrInvalidArgument)
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions container/containerd/namespaces/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ package namespaces

import (
"context"
"fmt"
"os"

"github.com/containerd/errdefs"
"github.com/pkg/errors"

"github.com/google/cadvisor/container/containerd/identifiers"
)
Expand Down Expand Up @@ -83,10 +83,10 @@ func Namespace(ctx context.Context) (string, bool) {
func NamespaceRequired(ctx context.Context) (string, error) {
namespace, ok := Namespace(ctx)
if !ok || namespace == "" {
return "", errors.Wrapf(errdefs.ErrFailedPrecondition, "namespace is required")
return "", fmt.Errorf("namespace is required: %w", errdefs.ErrFailedPrecondition)
}
if err := identifiers.Validate(namespace); err != nil {
return "", errors.Wrap(err, "namespace validation")
return "", fmt.Errorf("namespace validation: %w", err)
}
return namespace, nil
}
5 changes: 2 additions & 3 deletions container/containerd/pkg/dialer/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ package dialer

import (
"context"
"fmt"
"net"
"time"

"github.com/pkg/errors"
)

type dialResult struct {
Expand Down Expand Up @@ -87,6 +86,6 @@ func timeoutDialer(address string, timeout time.Duration) (net.Conn, error) {
dr.c.Close()
}
}()
return nil, errors.Errorf("dial %s: timeout", address)
return nil, fmt.Errorf("dial %s: timeout", address)
}
}
3 changes: 1 addition & 2 deletions container/podman/podman.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
dockercontainer "github.com/docker/docker/api/types/container"
dockerimage "github.com/docker/docker/api/types/image"
dockersystem "github.com/docker/docker/api/types/system"
"github.com/pkg/errors"

"github.com/google/cadvisor/container/docker"
"github.com/google/cadvisor/container/docker/utils"
Expand All @@ -53,7 +52,7 @@ func validateResponse(gotError error, response *http.Response) error {
}

if gotError != nil {
err = errors.Wrap(gotError, err.Error())
err = fmt.Errorf("%s: %w", err.Error(), gotError)
}

return err
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ require (
github.com/opencontainers/cgroups v0.0.2
github.com/opencontainers/runc v1.3.0
github.com/opencontainers/runtime-spec v1.2.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.22.0
github.com/prometheus/client_model v0.6.2
github.com/prometheus/common v0.64.0
Expand Down Expand Up @@ -71,6 +70,7 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
Expand Down
Loading