mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rebase: update Kubernetes modules to v1.27.4
Dependabot complains about Ceph-CSI being vulnerable to GHSA-f4w6-3rh6-6q4q . This is an old and addressed CSI sidecar issue, not related to the k8s.io/kubernetes module listed in go.mod. Is it possible that updating the Kubernetes modules helps? Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
3bc3aa5f1e
commit
30da273e5e
4
vendor/k8s.io/apimachinery/pkg/runtime/converter.go
generated
vendored
4
vendor/k8s.io/apimachinery/pkg/runtime/converter.go
generated
vendored
@ -231,7 +231,7 @@ func (c *fromUnstructuredContext) pushKey(key string) {
|
||||
|
||||
}
|
||||
|
||||
// FromUnstructuredWIthValidation converts an object from map[string]interface{} representation into a concrete type.
|
||||
// FromUnstructuredWithValidation converts an object from map[string]interface{} representation into a concrete type.
|
||||
// It uses encoding/json/Unmarshaler if object implements it or reflection if not.
|
||||
// It takes a validationDirective that indicates how to behave when it encounters unknown fields.
|
||||
func (c *unstructuredConverter) FromUnstructuredWithValidation(u map[string]interface{}, obj interface{}, returnUnknownFields bool) error {
|
||||
@ -465,7 +465,7 @@ func sliceFromUnstructured(sv, dv reflect.Value, ctx *fromUnstructuredContext) e
|
||||
}
|
||||
dv.SetBytes(data)
|
||||
} else {
|
||||
dv.Set(reflect.Zero(dt))
|
||||
dv.Set(reflect.MakeSlice(dt, 0, 0))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
19
vendor/k8s.io/apimachinery/pkg/util/wait/loop.go
generated
vendored
19
vendor/k8s.io/apimachinery/pkg/util/wait/loop.go
generated
vendored
@ -27,9 +27,11 @@ import (
|
||||
// the provided timer until the provided context is cancelled, the condition returns
|
||||
// true, or the condition returns an error. If sliding is true, the period is computed
|
||||
// after condition runs. If it is false then period includes the runtime for condition.
|
||||
// If immediate is false the first delay happens before any call to condition. The
|
||||
// returned error is the error returned by the last condition or the context error if
|
||||
// the context was terminated.
|
||||
// If immediate is false the first delay happens before any call to condition, if
|
||||
// immediate is true the condition will be invoked before waiting and guarantees that
|
||||
// the condition is invoked at least once, regardless of whether the context has been
|
||||
// cancelled. The returned error is the error returned by the last condition or the
|
||||
// context error if the context was terminated.
|
||||
//
|
||||
// This is the common loop construct for all polling in the wait package.
|
||||
func loopConditionUntilContext(ctx context.Context, t Timer, immediate, sliding bool, condition ConditionWithContextFunc) error {
|
||||
@ -38,8 +40,17 @@ func loopConditionUntilContext(ctx context.Context, t Timer, immediate, sliding
|
||||
var timeCh <-chan time.Time
|
||||
doneCh := ctx.Done()
|
||||
|
||||
// if immediate is true the condition is
|
||||
// guaranteed to be executed at least once,
|
||||
// if we haven't requested immediate execution, delay once
|
||||
if !immediate {
|
||||
if immediate {
|
||||
if ok, err := func() (bool, error) {
|
||||
defer runtime.HandleCrash()
|
||||
return condition(ctx)
|
||||
}(); err != nil || ok {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
timeCh = t.C()
|
||||
select {
|
||||
case <-doneCh:
|
||||
|
8
vendor/k8s.io/apiserver/pkg/server/options/etcd.go
generated
vendored
8
vendor/k8s.io/apiserver/pkg/server/options/etcd.go
generated
vendored
@ -444,6 +444,10 @@ func (s *SimpleStorageFactory) ResourcePrefix(resource schema.GroupResource) str
|
||||
return resource.Group + "/" + resource.Resource
|
||||
}
|
||||
|
||||
func (s *SimpleStorageFactory) Configs() []storagebackend.Config {
|
||||
return serverstorage.Configs(s.StorageConfig)
|
||||
}
|
||||
|
||||
func (s *SimpleStorageFactory) Backends() []serverstorage.Backend {
|
||||
// nothing should ever call this method but we still provide a functional implementation
|
||||
return serverstorage.Backends(s.StorageConfig)
|
||||
@ -474,6 +478,10 @@ func (t *transformerStorageFactory) ResourcePrefix(resource schema.GroupResource
|
||||
return t.delegate.ResourcePrefix(resource)
|
||||
}
|
||||
|
||||
func (t *transformerStorageFactory) Configs() []storagebackend.Config {
|
||||
return t.delegate.Configs()
|
||||
}
|
||||
|
||||
func (t *transformerStorageFactory) Backends() []serverstorage.Backend {
|
||||
return t.delegate.Backends()
|
||||
}
|
||||
|
49
vendor/k8s.io/apiserver/pkg/server/storage/storage_factory.go
generated
vendored
49
vendor/k8s.io/apiserver/pkg/server/storage/storage_factory.go
generated
vendored
@ -22,14 +22,13 @@ import (
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apiserver/pkg/features"
|
||||
"k8s.io/apiserver/pkg/storage/storagebackend"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
// Backend describes the storage servers, the information here should be enough
|
||||
@ -52,8 +51,12 @@ type StorageFactory interface {
|
||||
// centralized control over the shape of etcd directories
|
||||
ResourcePrefix(groupResource schema.GroupResource) string
|
||||
|
||||
// Configs gets configurations for all of registered storage destinations.
|
||||
Configs() []storagebackend.Config
|
||||
|
||||
// Backends gets all backends for all registered storage destinations.
|
||||
// Used for getting all instances for health validations.
|
||||
// Deprecated: Use Configs instead
|
||||
Backends() []Backend
|
||||
}
|
||||
|
||||
@ -276,14 +279,52 @@ func (s *DefaultStorageFactory) NewConfig(groupResource schema.GroupResource) (*
|
||||
return storageConfig.ForResource(groupResource), nil
|
||||
}
|
||||
|
||||
// Backends returns all backends for all registered storage destinations.
|
||||
// Used for getting all instances for health validations.
|
||||
// Configs implements StorageFactory.
|
||||
func (s *DefaultStorageFactory) Configs() []storagebackend.Config {
|
||||
return configs(s.StorageConfig, s.Overrides)
|
||||
}
|
||||
|
||||
// Configs gets configurations for all of registered storage destinations.
|
||||
func Configs(storageConfig storagebackend.Config) []storagebackend.Config {
|
||||
return configs(storageConfig, nil)
|
||||
}
|
||||
|
||||
// Returns all storage configurations including those for group resource overrides
|
||||
func configs(storageConfig storagebackend.Config, grOverrides map[schema.GroupResource]groupResourceOverrides) []storagebackend.Config {
|
||||
locations := sets.NewString()
|
||||
configs := []storagebackend.Config{}
|
||||
for _, loc := range storageConfig.Transport.ServerList {
|
||||
// copy
|
||||
newConfig := storageConfig
|
||||
newConfig.Transport.ServerList = []string{loc}
|
||||
configs = append(configs, newConfig)
|
||||
locations.Insert(loc)
|
||||
}
|
||||
|
||||
for _, override := range grOverrides {
|
||||
for _, loc := range override.etcdLocation {
|
||||
if locations.Has(loc) {
|
||||
continue
|
||||
}
|
||||
// copy
|
||||
newConfig := storageConfig
|
||||
override.Apply(&newConfig, &StorageCodecConfig{})
|
||||
newConfig.Transport.ServerList = []string{loc}
|
||||
configs = append(configs, newConfig)
|
||||
locations.Insert(loc)
|
||||
}
|
||||
}
|
||||
return configs
|
||||
}
|
||||
|
||||
// Backends implements StorageFactory.
|
||||
func (s *DefaultStorageFactory) Backends() []Backend {
|
||||
return backends(s.StorageConfig, s.Overrides)
|
||||
}
|
||||
|
||||
// Backends returns all backends for all registered storage destinations.
|
||||
// Used for getting all instances for health validations.
|
||||
// Deprecated: Validate health by passing storagebackend.Config directly to storagefactory.CreateProber.
|
||||
func Backends(storageConfig storagebackend.Config) []Backend {
|
||||
return backends(storageConfig, nil)
|
||||
}
|
||||
|
1
vendor/k8s.io/apiserver/pkg/storage/etcd3/healthcheck.go
generated
vendored
1
vendor/k8s.io/apiserver/pkg/storage/etcd3/healthcheck.go
generated
vendored
@ -28,6 +28,7 @@ type etcdHealth struct {
|
||||
}
|
||||
|
||||
// EtcdHealthCheck decodes data returned from etcd /healthz handler.
|
||||
// Deprecated: Validate health by passing storagebackend.Config directly to storagefactory.CreateProber.
|
||||
func EtcdHealthCheck(data []byte) error {
|
||||
obj := etcdHealth{}
|
||||
if err := json.Unmarshal(data, &obj); err != nil {
|
||||
|
61
vendor/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go
generated
vendored
61
vendor/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go
generated
vendored
@ -153,18 +153,18 @@ func newETCD3Check(c storagebackend.Config, timeout time.Duration, stopCh <-chan
|
||||
// retry in a loop in the background until we successfully create the client, storing the client or error encountered
|
||||
|
||||
lock := sync.RWMutex{}
|
||||
var client *clientv3.Client
|
||||
var prober *etcd3Prober
|
||||
clientErr := fmt.Errorf("etcd client connection not yet established")
|
||||
|
||||
go wait.PollUntil(time.Second, func() (bool, error) {
|
||||
newClient, err := newETCD3Client(c.Transport)
|
||||
newProber, err := newETCD3Prober(c)
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
// Ensure that server is already not shutting down.
|
||||
select {
|
||||
case <-stopCh:
|
||||
if err == nil {
|
||||
newClient.Close()
|
||||
newProber.Close()
|
||||
}
|
||||
return true, nil
|
||||
default:
|
||||
@ -173,7 +173,7 @@ func newETCD3Check(c storagebackend.Config, timeout time.Duration, stopCh <-chan
|
||||
clientErr = err
|
||||
return false, nil
|
||||
}
|
||||
client = newClient
|
||||
prober = newProber
|
||||
clientErr = nil
|
||||
return true, nil
|
||||
}, stopCh)
|
||||
@ -185,8 +185,8 @@ func newETCD3Check(c storagebackend.Config, timeout time.Duration, stopCh <-chan
|
||||
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
if client != nil {
|
||||
client.Close()
|
||||
if prober != nil {
|
||||
prober.Close()
|
||||
clientErr = fmt.Errorf("server is shutting down")
|
||||
}
|
||||
}()
|
||||
@ -214,17 +214,56 @@ func newETCD3Check(c storagebackend.Config, timeout time.Duration, stopCh <-chan
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
// See https://github.com/etcd-io/etcd/blob/c57f8b3af865d1b531b979889c602ba14377420e/etcdctl/ctlv3/command/ep_command.go#L118
|
||||
now := time.Now()
|
||||
_, err := client.Get(ctx, path.Join("/", c.Prefix, "health"))
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error getting data from etcd: %w", err)
|
||||
}
|
||||
err := prober.Probe(ctx)
|
||||
lastError.Store(err, now)
|
||||
return err
|
||||
}, nil
|
||||
}
|
||||
|
||||
func newETCD3Prober(c storagebackend.Config) (*etcd3Prober, error) {
|
||||
client, err := newETCD3Client(c.Transport)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &etcd3Prober{
|
||||
client: client,
|
||||
prefix: c.Prefix,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type etcd3Prober struct {
|
||||
prefix string
|
||||
|
||||
mux sync.RWMutex
|
||||
client *clientv3.Client
|
||||
closed bool
|
||||
}
|
||||
|
||||
func (p *etcd3Prober) Close() error {
|
||||
p.mux.Lock()
|
||||
defer p.mux.Unlock()
|
||||
if !p.closed {
|
||||
p.closed = true
|
||||
return p.client.Close()
|
||||
}
|
||||
return fmt.Errorf("prober was closed")
|
||||
}
|
||||
|
||||
func (p *etcd3Prober) Probe(ctx context.Context) error {
|
||||
p.mux.RLock()
|
||||
defer p.mux.RUnlock()
|
||||
if p.closed {
|
||||
return fmt.Errorf("prober was closed")
|
||||
}
|
||||
// See https://github.com/etcd-io/etcd/blob/c57f8b3af865d1b531b979889c602ba14377420e/etcdctl/ctlv3/command/ep_command.go#L118
|
||||
_, err := p.client.Get(ctx, path.Join("/", p.prefix, "health"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("error getting data from etcd: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var newETCD3Client = func(c storagebackend.TransportConfig) (*clientv3.Client, error) {
|
||||
tlsInfo := transport.TLSInfo{
|
||||
CertFile: c.CertFile,
|
||||
|
18
vendor/k8s.io/apiserver/pkg/storage/storagebackend/factory/factory.go
generated
vendored
18
vendor/k8s.io/apiserver/pkg/storage/storagebackend/factory/factory.go
generated
vendored
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package factory
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
@ -61,3 +62,20 @@ func CreateReadyCheck(c storagebackend.Config, stopCh <-chan struct{}) (func() e
|
||||
return nil, fmt.Errorf("unknown storage type: %s", c.Type)
|
||||
}
|
||||
}
|
||||
|
||||
func CreateProber(c storagebackend.Config) (Prober, error) {
|
||||
switch c.Type {
|
||||
case storagebackend.StorageTypeETCD2:
|
||||
return nil, fmt.Errorf("%s is no longer a supported storage backend", c.Type)
|
||||
case storagebackend.StorageTypeUnset, storagebackend.StorageTypeETCD3:
|
||||
return newETCD3Prober(c)
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown storage type: %s", c.Type)
|
||||
}
|
||||
}
|
||||
|
||||
// Prober is an interface that defines the Probe function for doing etcd readiness/liveness checks.
|
||||
type Prober interface {
|
||||
Probe(ctx context.Context) error
|
||||
Close() error
|
||||
}
|
||||
|
27
vendor/k8s.io/client-go/util/cert/cert.go
generated
vendored
27
vendor/k8s.io/client-go/util/cert/cert.go
generated
vendored
@ -25,6 +25,7 @@ import (
|
||||
"crypto/x509/pkix"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
"net"
|
||||
"os"
|
||||
@ -57,8 +58,14 @@ type AltNames struct {
|
||||
// NewSelfSignedCACert creates a CA certificate
|
||||
func NewSelfSignedCACert(cfg Config, key crypto.Signer) (*x509.Certificate, error) {
|
||||
now := time.Now()
|
||||
// returns a uniform random value in [0, max-1), then add 1 to serial to make it a uniform random value in [1, max).
|
||||
serial, err := cryptorand.Int(cryptorand.Reader, new(big.Int).SetInt64(math.MaxInt64-1))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
serial = new(big.Int).Add(serial, big.NewInt(1))
|
||||
tmpl := x509.Certificate{
|
||||
SerialNumber: new(big.Int).SetInt64(0),
|
||||
SerialNumber: serial,
|
||||
Subject: pkix.Name{
|
||||
CommonName: cfg.CommonName,
|
||||
Organization: cfg.Organization,
|
||||
@ -116,9 +123,14 @@ func GenerateSelfSignedCertKeyWithFixtures(host string, alternateIPs []net.IP, a
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// returns a uniform random value in [0, max-1), then add 1 to serial to make it a uniform random value in [1, max).
|
||||
serial, err := cryptorand.Int(cryptorand.Reader, new(big.Int).SetInt64(math.MaxInt64-1))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
serial = new(big.Int).Add(serial, big.NewInt(1))
|
||||
caTemplate := x509.Certificate{
|
||||
SerialNumber: big.NewInt(1),
|
||||
SerialNumber: serial,
|
||||
Subject: pkix.Name{
|
||||
CommonName: fmt.Sprintf("%s-ca@%d", host, time.Now().Unix()),
|
||||
},
|
||||
@ -144,9 +156,14 @@ func GenerateSelfSignedCertKeyWithFixtures(host string, alternateIPs []net.IP, a
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// returns a uniform random value in [0, max-1), then add 1 to serial to make it a uniform random value in [1, max).
|
||||
serial, err = cryptorand.Int(cryptorand.Reader, new(big.Int).SetInt64(math.MaxInt64-1))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
serial = new(big.Int).Add(serial, big.NewInt(1))
|
||||
template := x509.Certificate{
|
||||
SerialNumber: big.NewInt(2),
|
||||
SerialNumber: serial,
|
||||
Subject: pkix.Name{
|
||||
CommonName: fmt.Sprintf("%s@%d", host, time.Now().Unix()),
|
||||
},
|
||||
|
Reference in New Issue
Block a user