utils

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2022 License: Apache-2.0 Imports: 20 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// PodDeletionCost can be used to set to an int32 that represent the cost of deleting
	// a pod compared to other pods belonging to the same ReplicaSet. Pods with lower
	// deletion cost are preferred to be deleted before pods with higher deletion cost.
	PodDeletionCost = "controller.kubernetes.io/pod-deletion-cost"
)

Variables

View Source
var (
	// ControllerKind is GroupVersionKind for CloneSet.
	ControllerKind      = appsv1alpha1.SchemeGroupVersion.WithKind("CloneSet")
	RevisionAdapterImpl = &revisionAdapterImpl{}
	EqualToRevisionHash = RevisionAdapterImpl.EqualToRevisionHash
	WriteRevisionHash   = RevisionAdapterImpl.WriteRevisionHash

	ScaleExpectations           = expectations.NewScaleExpectations()
	UpdateExpectations          = expectations.NewUpdateExpectations(RevisionAdapterImpl)
	ResourceVersionExpectations = expectations.NewResourceVersionExpectation()
)

Functions

func DoItSlowly

func DoItSlowly(count int, initialBatchSize int, fn func() error) (int, error)

DoItSlowly tries to call the provided function a total of 'count' times, starting slow to check for errors, then speeding up if calls succeed.

It groups the calls into batches, starting with a group of initialBatchSize. Within each batch, it may call the function multiple times concurrently.

If a whole batch succeeds, the next batch may get exponentially larger. If there are any failures in a batch, all remaining batches are skipped after waiting for the current batch to complete.

It returns the number of successful calls to the function.

func GetActivePods

func GetActivePods(reader client.Reader, opts *client.ListOptions) ([]*v1.Pod, error)

GetActivePods returns all active pods in this namespace.

func GetControllerKey

func GetControllerKey(cs *appsv1alpha1.CloneSet) string

GetControllerKey return key of CloneSet.

func GetPersistentVolumeClaims

func GetPersistentVolumeClaims(cs *appsv1alpha1.CloneSet, pod *v1.Pod) map[string]v1.PersistentVolumeClaim

GetPersistentVolumeClaims gets a map of PersistentVolumeClaims to their template names, as defined in set. The returned PersistentVolumeClaims are each constructed with a the name specific to the Pod. This name is determined by getPersistentVolumeClaimName.

func IsRunningAndAvailable added in v0.4.1

func IsRunningAndAvailable(pod *v1.Pod, minReadySeconds int32) bool

IsRunningAndAvailable returns true if pod is in the PodRunning Phase, if it is available.

func IsRunningAndReady

func IsRunningAndReady(pod *v1.Pod) bool

IsRunningAndReady returns true if pod is in the PodRunning Phase, if it is ready.

func NextRevision

func NextRevision(revisions []*apps.ControllerRevision) int64

NextRevision finds the next valid revision number based on revisions. If the length of revisions is 0 this is 1. Otherwise, it is 1 greater than the largest revision's Revision. This method assumes that revisions has been sorted by Revision.

func SplitPodsByRevision added in v0.5.0

func SplitPodsByRevision(pods []*v1.Pod, rev string) (matched, unmatched []*v1.Pod)

SplitPodsByRevision returns Pods matched and unmatched the given revision

func UpdateStorage

func UpdateStorage(cs *appsv1alpha1.CloneSet, pod *v1.Pod)

UpdateStorage insert volumes generated by cs.Spec.VolumeClaimTemplates into Pod.

Types

type ActivePodsWithRanks added in v0.10.0

type ActivePodsWithRanks struct {
	Pods          []*v1.Pod
	Ranker        Ranker
	AvailableFunc func(*v1.Pod) bool
}

ActivePodsWithRanks type allows custom sorting of pods so a controller can pick the best ones to delete.

func (ActivePodsWithRanks) Len added in v0.10.0

func (s ActivePodsWithRanks) Len() int

func (ActivePodsWithRanks) Less added in v0.10.0

func (s ActivePodsWithRanks) Less(i, j int) bool

func (ActivePodsWithRanks) Swap added in v0.10.0

func (s ActivePodsWithRanks) Swap(i, j int)

type PodSpreadConstraint added in v0.10.0

type PodSpreadConstraint struct {
	TopologyKey   string   `json:"topologyKey"`
	LimitedValues []string `json:"limitedValues,omitempty"`
}

type Ranker added in v0.10.0

type Ranker interface {
	GetRank(*v1.Pod) float64
}

func NewSameNodeRanker added in v0.10.0

func NewSameNodeRanker(pods []*v1.Pod) Ranker

func NewSpreadConstraintsRanker added in v0.10.0

func NewSpreadConstraintsRanker(pods []*v1.Pod, constraints []PodSpreadConstraint, reader client.Reader) Ranker

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL