mirror of
https://github.com/containers/podman.git
synced 2025-12-02 19:28:58 +08:00
update c/{common,image,storage} to latest
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
9
vendor/github.com/containers/common/libnetwork/types/define.go
generated
vendored
9
vendor/github.com/containers/common/libnetwork/types/define.go
generated
vendored
@@ -3,7 +3,8 @@ package types
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/containers/storage/pkg/regexp"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -19,7 +20,11 @@ var (
|
||||
|
||||
// NameRegex is a regular expression to validate names.
|
||||
// This must NOT be changed.
|
||||
NameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$")
|
||||
NameRegex = regexp.Delayed("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$")
|
||||
// RegexError is thrown in presence of an invalid name.
|
||||
RegexError = fmt.Errorf("names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*: %w", ErrInvalidArg) // nolint:revive // This lint is new and we do not want to break the API.
|
||||
|
||||
// NotHexRegex is a regular expression to check if a string is
|
||||
// a hexadecimal string.
|
||||
NotHexRegex = regexp.Delayed(`[^0-9a-fA-F]`)
|
||||
)
|
||||
|
||||
2
vendor/github.com/containers/common/libnetwork/util/filters.go
generated
vendored
2
vendor/github.com/containers/common/libnetwork/util/filters.go
generated
vendored
@@ -38,7 +38,7 @@ func createFilterFuncs(key string, filterValues []string) (types.FilterFunc, err
|
||||
case "id":
|
||||
// matches part of one id
|
||||
return func(net types.Network) bool {
|
||||
return util.StringMatchRegexSlice(net.ID, filterValues)
|
||||
return util.FilterID(net.ID, filterValues)
|
||||
}, nil
|
||||
|
||||
// TODO: add dns enabled, internal filter
|
||||
|
||||
2
vendor/github.com/containers/common/pkg/config/default.go
generated
vendored
2
vendor/github.com/containers/common/pkg/config/default.go
generated
vendored
@@ -32,8 +32,6 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
// DefaultInitPath is the default path to the container-init binary.
|
||||
DefaultInitPath = "/usr/libexec/podman/catatonit"
|
||||
// DefaultInfraImage is the default image to run as infrastructure containers in pods.
|
||||
DefaultInfraImage = ""
|
||||
// DefaultRootlessSHMLockPath is the default path for rootless SHM locks.
|
||||
|
||||
7
vendor/github.com/containers/common/pkg/config/default_common.go
generated
vendored
Normal file
7
vendor/github.com/containers/common/pkg/config/default_common.go
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
//go:build !freebsd
|
||||
// +build !freebsd
|
||||
|
||||
package config
|
||||
|
||||
// DefaultInitPath is the default path to the container-init binary.
|
||||
var DefaultInitPath = "/usr/libexec/podman/catatonit"
|
||||
3
vendor/github.com/containers/common/pkg/config/default_freebsd.go
generated
vendored
3
vendor/github.com/containers/common/pkg/config/default_freebsd.go
generated
vendored
@@ -1,5 +1,8 @@
|
||||
package config
|
||||
|
||||
// DefaultInitPath is the default path to the container-init binary.
|
||||
var DefaultInitPath = "/usr/local/libexec/podman/catatonit"
|
||||
|
||||
func getDefaultCgroupsMode() string {
|
||||
return "enabled"
|
||||
}
|
||||
|
||||
28
vendor/github.com/containers/common/pkg/retry/retry.go
generated
vendored
28
vendor/github.com/containers/common/pkg/retry/retry.go
generated
vendored
@@ -17,8 +17,9 @@ import (
|
||||
|
||||
// Options defines the option to retry.
|
||||
type Options struct {
|
||||
MaxRetry int // The number of times to possibly retry.
|
||||
Delay time.Duration // The delay to use between retries, if set.
|
||||
MaxRetry int // The number of times to possibly retry.
|
||||
Delay time.Duration // The delay to use between retries, if set.
|
||||
IsErrorRetryable func(error) bool
|
||||
}
|
||||
|
||||
// RetryOptions is deprecated, use Options.
|
||||
@@ -31,8 +32,11 @@ func RetryIfNecessary(ctx context.Context, operation func() error, options *Opti
|
||||
|
||||
// IfNecessary retries the operation in exponential backoff with the retry Options.
|
||||
func IfNecessary(ctx context.Context, operation func() error, options *Options) error {
|
||||
if options.IsErrorRetryable == nil {
|
||||
options.IsErrorRetryable = IsErrorRetryable
|
||||
}
|
||||
err := operation()
|
||||
for attempt := 0; err != nil && isRetryable(err) && attempt < options.MaxRetry; attempt++ {
|
||||
for attempt := 0; err != nil && options.IsErrorRetryable(err) && attempt < options.MaxRetry; attempt++ {
|
||||
delay := time.Duration(int(math.Pow(2, float64(attempt)))) * time.Second
|
||||
if options.Delay != 0 {
|
||||
delay = options.Delay
|
||||
@@ -49,7 +53,11 @@ func IfNecessary(ctx context.Context, operation func() error, options *Options)
|
||||
return err
|
||||
}
|
||||
|
||||
func isRetryable(err error) bool {
|
||||
// IsErrorRetryable makes a HEURISTIC determination whether it is worth retrying upon encountering an error.
|
||||
// That heuristic is NOT STABLE and it CAN CHANGE AT ANY TIME.
|
||||
// Callers that have a hard requirement for specific treatment of a class of errors should make their own check
|
||||
// instead of relying on this function maintaining its past behavior.
|
||||
func IsErrorRetryable(err error) bool {
|
||||
switch err {
|
||||
case nil:
|
||||
return false
|
||||
@@ -72,18 +80,18 @@ func isRetryable(err error) bool {
|
||||
}
|
||||
return true
|
||||
case *net.OpError:
|
||||
return isRetryable(e.Err)
|
||||
return IsErrorRetryable(e.Err)
|
||||
case *url.Error: // This includes errors returned by the net/http client.
|
||||
if e.Err == io.EOF { // Happens when a server accepts a HTTP connection and sends EOF
|
||||
return true
|
||||
}
|
||||
return isRetryable(e.Err)
|
||||
return IsErrorRetryable(e.Err)
|
||||
case syscall.Errno:
|
||||
return isErrnoRetryable(e)
|
||||
case errcode.Errors:
|
||||
// if this error is a group of errors, process them all in turn
|
||||
for i := range e {
|
||||
if !isRetryable(e[i]) {
|
||||
if !IsErrorRetryable(e[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -91,7 +99,7 @@ func isRetryable(err error) bool {
|
||||
case *multierror.Error:
|
||||
// if this error is a group of errors, process them all in turn
|
||||
for i := range e.Errors {
|
||||
if !isRetryable(e.Errors[i]) {
|
||||
if !IsErrorRetryable(e.Errors[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -102,11 +110,11 @@ func isRetryable(err error) bool {
|
||||
}
|
||||
if unwrappable, ok := e.(unwrapper); ok {
|
||||
err = unwrappable.Unwrap()
|
||||
return isRetryable(err)
|
||||
return IsErrorRetryable(err)
|
||||
}
|
||||
case unwrapper: // Test this last, because various error types might implement .Unwrap()
|
||||
err = e.Unwrap()
|
||||
return isRetryable(err)
|
||||
return IsErrorRetryable(err)
|
||||
}
|
||||
|
||||
return false
|
||||
|
||||
21
vendor/github.com/containers/common/pkg/util/util.go
generated
vendored
21
vendor/github.com/containers/common/pkg/util/util.go
generated
vendored
@@ -6,6 +6,8 @@ import (
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -110,3 +112,22 @@ func StringMatchRegexSlice(s string, re []string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// FilterID is a function used to compare an id against a set of ids, if the
|
||||
// input is hex we check if the prefix matches. Otherwise we assume it is a
|
||||
// regex and try to match that.
|
||||
// see https://github.com/containers/podman/issues/18471 for why we do this
|
||||
func FilterID(id string, filters []string) bool {
|
||||
for _, want := range filters {
|
||||
isRegex := types.NotHexRegex.MatchString(want)
|
||||
if isRegex {
|
||||
match, err := regexp.MatchString(want, id)
|
||||
if err == nil && match {
|
||||
return true
|
||||
}
|
||||
} else if strings.HasPrefix(id, strings.ToLower(want)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user