mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
rebase: update replaced k8s.io modules to v0.33.0
Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
dd77e72800
commit
107407b44b
73
e2e/vendor/k8s.io/kubernetes/pkg/controller/controller_utils.go
generated
vendored
73
e2e/vendor/k8s.io/kubernetes/pkg/controller/controller_utils.go
generated
vendored
@ -83,6 +83,16 @@ const (
|
||||
// The number of batches is given by:
|
||||
// 1+floor(log_2(ceil(N/SlowStartInitialBatchSize)))
|
||||
SlowStartInitialBatchSize = 1
|
||||
|
||||
// PodNodeNameKeyIndex is the name of the index used by PodInformer to index pods by their node name.
|
||||
PodNodeNameKeyIndex = "spec.nodeName"
|
||||
|
||||
// OrphanPodIndexKey is used to index all Orphan pods to this key
|
||||
OrphanPodIndexKey = "_ORPHAN_POD"
|
||||
|
||||
// podControllerUIDIndex is the name for the Pod store's index function,
|
||||
// which is to index by pods's controllerUID.
|
||||
PodControllerUIDIndex = "podControllerUID"
|
||||
)
|
||||
|
||||
var UpdateTaintBackoff = wait.Backoff{
|
||||
@ -973,14 +983,27 @@ func compareMaxContainerRestarts(pi *v1.Pod, pj *v1.Pod) *bool {
|
||||
return nil
|
||||
}
|
||||
|
||||
// FilterClaimedPods returns pods that are controlled by the controller and match the selector.
|
||||
func FilterClaimedPods(controller metav1.Object, selector labels.Selector, pods []*v1.Pod) []*v1.Pod {
|
||||
var result []*v1.Pod
|
||||
for _, pod := range pods {
|
||||
if !metav1.IsControlledBy(pod, controller) {
|
||||
// It's an orphan or owned by someone else.
|
||||
continue
|
||||
}
|
||||
if selector.Matches(labels.Set(pod.Labels)) {
|
||||
result = append(result, pod)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// FilterActivePods returns pods that have not terminated.
|
||||
func FilterActivePods(logger klog.Logger, pods []*v1.Pod) []*v1.Pod {
|
||||
var result []*v1.Pod
|
||||
for _, p := range pods {
|
||||
if IsPodActive(p) {
|
||||
result = append(result, p)
|
||||
} else {
|
||||
logger.V(4).Info("Ignoring inactive pod", "pod", klog.KObj(p), "phase", p.Status.Phase, "deletionTime", klog.SafePtr(p.DeletionTimestamp))
|
||||
}
|
||||
}
|
||||
return result
|
||||
@ -1038,6 +1061,52 @@ func FilterReplicaSets(RSes []*apps.ReplicaSet, filterFn filterRS) []*apps.Repli
|
||||
return filtered
|
||||
}
|
||||
|
||||
// AddPodNodeNameIndexer adds an indexer for Pod's nodeName to the given PodInformer.
|
||||
// This indexer is used to efficiently look up pods by their node name.
|
||||
func AddPodNodeNameIndexer(podInformer cache.SharedIndexInformer) error {
|
||||
if _, exists := podInformer.GetIndexer().GetIndexers()[PodNodeNameKeyIndex]; exists {
|
||||
// indexer already exists, do nothing
|
||||
return nil
|
||||
}
|
||||
|
||||
return podInformer.AddIndexers(cache.Indexers{
|
||||
PodNodeNameKeyIndex: func(obj interface{}) ([]string, error) {
|
||||
pod, ok := obj.(*v1.Pod)
|
||||
if !ok {
|
||||
return []string{}, nil
|
||||
}
|
||||
if len(pod.Spec.NodeName) == 0 {
|
||||
return []string{}, nil
|
||||
}
|
||||
return []string{pod.Spec.NodeName}, nil
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// AddPodControllerUIDIndexer adds an indexer for Pod's controllerRef.UID to the given PodInformer.
|
||||
// This indexer is used to efficiently look up pods by their ControllerRef.UID
|
||||
func AddPodControllerUIDIndexer(podInformer cache.SharedIndexInformer) error {
|
||||
if _, exists := podInformer.GetIndexer().GetIndexers()[PodControllerUIDIndex]; exists {
|
||||
// indexer already exists, do nothing
|
||||
return nil
|
||||
}
|
||||
return podInformer.AddIndexers(cache.Indexers{
|
||||
PodControllerUIDIndex: func(obj interface{}) ([]string, error) {
|
||||
pod, ok := obj.(*v1.Pod)
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
// Get the ControllerRef of the Pod to check if it's managed by a controller
|
||||
if ref := metav1.GetControllerOf(pod); ref != nil {
|
||||
return []string{string(ref.UID)}, nil
|
||||
}
|
||||
// If the Pod has no controller (i.e., it's orphaned), index it with the OrphanPodIndexKey
|
||||
// This helps identify orphan pods for reconciliation and adoption by controllers
|
||||
return []string{OrphanPodIndexKey}, nil
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// PodKey returns a key unique to the given pod within a cluster.
|
||||
// It's used so we consistently use the same key scheme in this module.
|
||||
// It does exactly what cache.MetaNamespaceKeyFunc would have done
|
||||
|
20
e2e/vendor/k8s.io/kubernetes/pkg/controller/deployment/util/deployment_util.go
generated
vendored
20
e2e/vendor/k8s.io/kubernetes/pkg/controller/deployment/util/deployment_util.go
generated
vendored
@ -714,6 +714,26 @@ func GetAvailableReplicaCountForReplicaSets(replicaSets []*apps.ReplicaSet) int3
|
||||
return totalAvailableReplicas
|
||||
}
|
||||
|
||||
// GetTerminatingReplicaCountForReplicaSets returns the number of terminating pods for all replica sets
|
||||
// or returns an error if any replica sets have been synced by the controller but do not report their terminating count.
|
||||
func GetTerminatingReplicaCountForReplicaSets(replicaSets []*apps.ReplicaSet) *int32 {
|
||||
terminatingReplicas := int32(0)
|
||||
for _, rs := range replicaSets {
|
||||
switch {
|
||||
case rs == nil:
|
||||
// No-op
|
||||
case rs.Status.ObservedGeneration == 0 && rs.Status.TerminatingReplicas == nil:
|
||||
// Replicasets that have never been synced by the controller don't contribute to TerminatingReplicas
|
||||
case rs.Status.TerminatingReplicas == nil:
|
||||
// If any replicaset synced by the controller hasn't reported TerminatingReplicas, we cannot calculate a sum
|
||||
return nil
|
||||
default:
|
||||
terminatingReplicas += *rs.Status.TerminatingReplicas
|
||||
}
|
||||
}
|
||||
return &terminatingReplicas
|
||||
}
|
||||
|
||||
// IsRollingUpdate returns true if the strategy type is a rolling update.
|
||||
func IsRollingUpdate(deployment *apps.Deployment) bool {
|
||||
return deployment.Spec.Strategy.Type == apps.RollingUpdateDeploymentStrategyType
|
||||
|
2
e2e/vendor/k8s.io/kubernetes/pkg/controller/doc.go
generated
vendored
2
e2e/vendor/k8s.io/kubernetes/pkg/controller/doc.go
generated
vendored
@ -16,4 +16,4 @@ limitations under the License.
|
||||
|
||||
// Package controller contains code for controllers (like the replication
|
||||
// controller).
|
||||
package controller // import "k8s.io/kubernetes/pkg/controller"
|
||||
package controller
|
||||
|
Reference in New Issue
Block a user