mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 02:33:34 +00:00
rebase: update all k8s packages to 0.27.2
Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
07b05616a0
commit
2551a0b05f
92
vendor/k8s.io/apiserver/pkg/registry/generic/registry/store.go
generated
vendored
92
vendor/k8s.io/apiserver/pkg/registry/generic/registry/store.go
generated
vendored
@ -25,6 +25,7 @@ import (
|
||||
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/api/validation"
|
||||
"k8s.io/apimachinery/pkg/api/validation/path"
|
||||
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@ -110,6 +111,9 @@ type Store struct {
|
||||
// See qualifiedResourceFromContext for details.
|
||||
DefaultQualifiedResource schema.GroupResource
|
||||
|
||||
// SingularQualifiedResource is the singular name of the resource.
|
||||
SingularQualifiedResource schema.GroupResource
|
||||
|
||||
// KeyRootFunc returns the root etcd key for this resource; should not
|
||||
// include trailing "/". This is used for operations that work on the
|
||||
// entire collection (listing and watching).
|
||||
@ -229,6 +233,8 @@ var _ rest.StandardStorage = &Store{}
|
||||
var _ rest.TableConvertor = &Store{}
|
||||
var _ GenericStore = &Store{}
|
||||
|
||||
var _ rest.SingularNameProvider = &Store{}
|
||||
|
||||
const (
|
||||
OptimisticLockErrorMsg = "the object has been modified; please apply your changes to the latest version and try again"
|
||||
resourceCountPollPeriodJitter = 1.2
|
||||
@ -359,6 +365,16 @@ func (e *Store) ListPredicate(ctx context.Context, p storage.SelectionPredicate,
|
||||
Predicate: p,
|
||||
Recursive: true,
|
||||
}
|
||||
|
||||
// if we're not already namespace-scoped, see if the field selector narrows the scope of the watch
|
||||
if requestNamespace, _ := genericapirequest.NamespaceFrom(ctx); len(requestNamespace) == 0 {
|
||||
if selectorNamespace, ok := p.MatchesSingleNamespace(); ok {
|
||||
if len(validation.ValidateNamespaceName(selectorNamespace, false)) == 0 {
|
||||
ctx = genericapirequest.WithNamespace(ctx, selectorNamespace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if name, ok := p.MatchesSingle(); ok {
|
||||
if key, err := e.KeyFunc(ctx, name); err == nil {
|
||||
storageOpts.Recursive = false
|
||||
@ -1122,11 +1138,6 @@ func (e *Store) DeleteReturnsDeletedObject() bool {
|
||||
// DeleteCollection is currently NOT atomic. It can happen that only subset of objects
|
||||
// will be deleted from storage, and then an error will be returned.
|
||||
// In case of success, the list of deleted objects will be returned.
|
||||
//
|
||||
// TODO: Currently, there is no easy way to remove 'directory' entry from storage (if we
|
||||
// are removing all objects of a given type) with the current API (it's technically
|
||||
// possibly with storage API, but watch is not delivered correctly then).
|
||||
// It will be possible to fix it with v3 etcd API.
|
||||
func (e *Store) DeleteCollection(ctx context.Context, deleteValidation rest.ValidateObjectFunc, options *metav1.DeleteOptions, listOptions *metainternalversion.ListOptions) (runtime.Object, error) {
|
||||
if listOptions == nil {
|
||||
listOptions = &metainternalversion.ListOptions{}
|
||||
@ -1162,23 +1173,6 @@ func (e *Store) DeleteCollection(ctx context.Context, deleteValidation rest.Vali
|
||||
toProcess := make(chan int, 2*workersNumber)
|
||||
errs := make(chan error, workersNumber+1)
|
||||
workersExited := make(chan struct{})
|
||||
distributorExited := make(chan struct{})
|
||||
|
||||
go func() {
|
||||
defer utilruntime.HandleCrash(func(panicReason interface{}) {
|
||||
errs <- fmt.Errorf("DeleteCollection distributor panicked: %v", panicReason)
|
||||
})
|
||||
defer close(distributorExited)
|
||||
for i := 0; i < len(items); i++ {
|
||||
select {
|
||||
case toProcess <- i:
|
||||
case <-workersExited:
|
||||
klog.V(4).InfoS("workers already exited, and there are some items waiting to be processed", "finished", i, "total", len(items))
|
||||
return
|
||||
}
|
||||
}
|
||||
close(toProcess)
|
||||
}()
|
||||
|
||||
wg.Add(workersNumber)
|
||||
for i := 0; i < workersNumber; i++ {
|
||||
@ -1207,10 +1201,31 @@ func (e *Store) DeleteCollection(ctx context.Context, deleteValidation rest.Vali
|
||||
}
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
// notify distributor to exit
|
||||
close(workersExited)
|
||||
<-distributorExited
|
||||
// In case of all workers exit, notify distributor.
|
||||
go func() {
|
||||
defer utilruntime.HandleCrash(func(panicReason interface{}) {
|
||||
errs <- fmt.Errorf("DeleteCollection workers closer panicked: %v", panicReason)
|
||||
})
|
||||
wg.Wait()
|
||||
close(workersExited)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer close(toProcess)
|
||||
|
||||
for i := 0; i < len(items); i++ {
|
||||
select {
|
||||
case toProcess <- i:
|
||||
case <-workersExited:
|
||||
klog.V(4).InfoS("workers already exited, and there are some items waiting to be processed", "finished", i, "total", len(items))
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// Wait for all workers to exist.
|
||||
<-workersExited
|
||||
|
||||
select {
|
||||
case err := <-errs:
|
||||
return nil, err
|
||||
@ -1268,12 +1283,21 @@ func (e *Store) Watch(ctx context.Context, options *metainternalversion.ListOpti
|
||||
resourceVersion = options.ResourceVersion
|
||||
predicate.AllowWatchBookmarks = options.AllowWatchBookmarks
|
||||
}
|
||||
return e.WatchPredicate(ctx, predicate, resourceVersion)
|
||||
return e.WatchPredicate(ctx, predicate, resourceVersion, options.SendInitialEvents)
|
||||
}
|
||||
|
||||
// WatchPredicate starts a watch for the items that matches.
|
||||
func (e *Store) WatchPredicate(ctx context.Context, p storage.SelectionPredicate, resourceVersion string) (watch.Interface, error) {
|
||||
storageOpts := storage.ListOptions{ResourceVersion: resourceVersion, Predicate: p, Recursive: true}
|
||||
func (e *Store) WatchPredicate(ctx context.Context, p storage.SelectionPredicate, resourceVersion string, sendInitialEvents *bool) (watch.Interface, error) {
|
||||
storageOpts := storage.ListOptions{ResourceVersion: resourceVersion, Predicate: p, Recursive: true, SendInitialEvents: sendInitialEvents}
|
||||
|
||||
// if we're not already namespace-scoped, see if the field selector narrows the scope of the watch
|
||||
if requestNamespace, _ := genericapirequest.NamespaceFrom(ctx); len(requestNamespace) == 0 {
|
||||
if selectorNamespace, ok := p.MatchesSingleNamespace(); ok {
|
||||
if len(validation.ValidateNamespaceName(selectorNamespace, false)) == 0 {
|
||||
ctx = genericapirequest.WithNamespace(ctx, selectorNamespace)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
key := e.KeyRootFunc(ctx)
|
||||
if name, ok := p.MatchesSingle(); ok {
|
||||
@ -1320,6 +1344,12 @@ func (e *Store) CompleteWithOptions(options *generic.StoreOptions) error {
|
||||
if e.DefaultQualifiedResource.Empty() {
|
||||
return fmt.Errorf("store %#v must have a non-empty qualified resource", e)
|
||||
}
|
||||
if e.SingularQualifiedResource.Empty() {
|
||||
return fmt.Errorf("store %#v must have a non-empty singular qualified resource", e)
|
||||
}
|
||||
if e.DefaultQualifiedResource.Group != e.SingularQualifiedResource.Group {
|
||||
return fmt.Errorf("store for %#v, singular and plural qualified resource's group name's must match", e)
|
||||
}
|
||||
if e.NewFunc == nil {
|
||||
return fmt.Errorf("store for %s must have NewFunc set", e.DefaultQualifiedResource.String())
|
||||
}
|
||||
@ -1515,6 +1545,10 @@ func (e *Store) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
|
||||
return e.ResetFieldsStrategy.GetResetFields()
|
||||
}
|
||||
|
||||
func (e *Store) GetSingularName() string {
|
||||
return e.SingularQualifiedResource.Resource
|
||||
}
|
||||
|
||||
// validateIndexers will check the prefix of indexers.
|
||||
func validateIndexers(indexers *cache.Indexers) error {
|
||||
if indexers == nil {
|
||||
|
13
vendor/k8s.io/apiserver/pkg/registry/rest/rest.go
generated
vendored
13
vendor/k8s.io/apiserver/pkg/registry/rest/rest.go
generated
vendored
@ -89,6 +89,12 @@ type CategoriesProvider interface {
|
||||
Categories() []string
|
||||
}
|
||||
|
||||
// SingularNameProvider returns singular name of resources. This is used by kubectl discovery to have singular
|
||||
// name representation of resources. In case of shortcut conflicts(with CRD shortcuts) singular name should always map to this resource.
|
||||
type SingularNameProvider interface {
|
||||
GetSingularName() string
|
||||
}
|
||||
|
||||
// GroupVersionKindProvider is used to specify a particular GroupVersionKind to discovery. This is used for polymorphic endpoints
|
||||
// which generally point to foreign versions. Scale refers to Scale.v1beta1.extensions for instance.
|
||||
// This trumps KindProvider since it is capable of providing the information required.
|
||||
@ -203,6 +209,13 @@ type NamedCreater interface {
|
||||
Create(ctx context.Context, name string, obj runtime.Object, createValidation ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error)
|
||||
}
|
||||
|
||||
// SubresourceObjectMetaPreserver adds configuration options to a Creater for subresources.
|
||||
type SubresourceObjectMetaPreserver interface {
|
||||
// PreserveRequestObjectMetaSystemFieldsOnSubresourceCreate indicates that a
|
||||
// handler should preserve fields of ObjectMeta that are managed by the system.
|
||||
PreserveRequestObjectMetaSystemFieldsOnSubresourceCreate() bool
|
||||
}
|
||||
|
||||
// UpdatedObjectInfo provides information about an updated object to an Updater.
|
||||
// It requires access to the old object in order to return the newly updated object.
|
||||
type UpdatedObjectInfo interface {
|
||||
|
Reference in New Issue
Block a user