petset

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const MaxBatchSize = 500

Realistic value for maximum in-flight requests when processing in parallel mode.

Variables

This section is empty.

Functions

func ApplyRevision

func ApplyRevision(set *api.PetSet, revision *apps.ControllerRevision) (*api.PetSet, error)

ApplyRevision returns a new PetSet constructed by restoring the state in revision to set. If the returned error is nil, the returned PetSet is valid.

Types

type PetSetControlInterface

type PetSetControlInterface interface {
	// UpdatePetSet implements the control logic for Pod creation, update, and deletion, and
	// persistent volume creation, update, and deletion.
	// If an implementation returns a non-nil error, the invocation will be retried using a rate-limited strategy.
	// Implementors should sink any errors that they do not wish to trigger a retry, and they may feel free to
	// exit exceptionally at any point provided they wish the update to be re-run at a later point in time.
	UpdatePetSet(ctx context.Context, set *api.PetSet, pods []*v1.Pod) (*apps.StatefulSetStatus, error)
	// ListRevisions returns a array of the ControllerRevisions that represent the revisions of set. If the returned
	// error is nil, the returns slice of ControllerRevisions is valid.
	ListRevisions(set *api.PetSet) ([]*apps.ControllerRevision, error)
	// AdoptOrphanRevisions adopts any orphaned ControllerRevisions that match set's Selector. If all adoptions are
	// successful the returned error is nil.
	AdoptOrphanRevisions(set *api.PetSet, revisions []*apps.ControllerRevision) error
}

PetSetControl implements the control logic for updating PetSets and their children Pods. It is implemented as an interface to allow for extensions that provide different semantics. Currently, there is only one implementation.

func NewDefaultPetSetControl

func NewDefaultPetSetControl(
	podControl *StatefulPodControl,
	statusUpdater StatefulSetStatusUpdaterInterface,
	controllerHistory history.Interface,
	recorder record.EventRecorder,
) PetSetControlInterface

NewDefaultPetSetControl returns a new instance of the default implementation PetSetControlInterface that implements the documented semantics for PetSets. podControl is the PodControlInterface used to create, update, and delete Pods and to create PersistentVolumeClaims. statusUpdater is the StatefulSetStatusUpdaterInterface used to update the status of PetSets. You should use an instance returned from NewRealStatefulPodControl() for any scenario other than testing.

type PetSetController

type PetSetController struct {
	// contains filtered or unexported fields
}

PetSetController controls petsets.

func NewPetSetController

NewPetSetController creates a new petset controller.

func (*PetSetController) Run

func (ssc *PetSetController) Run(ctx context.Context, workers int)

Run runs the petset controller.

type StatefulPodControl

type StatefulPodControl struct {
	// contains filtered or unexported fields
}

StatefulPodControl defines the interface that PetSetController uses to create, update, and delete Pods, and to update the Status of a PetSet. It follows the design paradigms used for PodControl, but its implementation provides for PVC creation, ordered Pod creation, ordered Pod termination, and Pod identity enforcement. Manipulation of objects is provided through objectMgr, which allows the k8s API to be mocked out for testing.

func NewStatefulPodControl

func NewStatefulPodControl(
	client clientset.Interface,
	podLister corelisters.PodLister,
	placementLister appslisters.PlacementPolicyLister,
	claimLister corelisters.PersistentVolumeClaimLister,
	recorder record.EventRecorder,
) *StatefulPodControl

NewStatefulPodControl constructs a StatefulPodControl using a realStatefulPodControlObjectManager with the given clientset, listers and EventRecorder.

func NewStatefulPodControlFromManager

func NewStatefulPodControlFromManager(om StatefulPodControlObjectManager, recorder record.EventRecorder) *StatefulPodControl

NewStatefulPodControlFromManager creates a StatefulPodControl using the given StatefulPodControlObjectManager and recorder.

func (*StatefulPodControl) ClaimsMatchRetentionPolicy

func (spc *StatefulPodControl) ClaimsMatchRetentionPolicy(ctx context.Context, set *api.PetSet, pod *v1.Pod) (bool, error)

ClaimsMatchRetentionPolicy returns false if the PVCs for pod are not consistent with set's PVC deletion policy. An error is returned if something is not consistent. This is expected if the pod is being otherwise updated, but a problem otherwise (see usage of this method in UpdateStatefulPod).

func (*StatefulPodControl) CreateStatefulPod

func (spc *StatefulPodControl) CreateStatefulPod(ctx context.Context, set *api.PetSet, pod *v1.Pod) error

func (*StatefulPodControl) DeleteStatefulPod

func (spc *StatefulPodControl) DeleteStatefulPod(set *api.PetSet, pod *v1.Pod) error

func (*StatefulPodControl) PodClaimIsStale

func (spc *StatefulPodControl) PodClaimIsStale(set *api.PetSet, pod *v1.Pod) (bool, error)

PodClaimIsStale returns true for a stale PVC that should block pod creation. If the scaling policy is deletion, and a PVC has an ownerRef that does not match the pod, the PVC is stale. This includes pods whose UID has not been created.

func (*StatefulPodControl) UpdatePodClaimForRetentionPolicy

func (spc *StatefulPodControl) UpdatePodClaimForRetentionPolicy(ctx context.Context, set *api.PetSet, pod *v1.Pod) error

UpdatePodClaimForRetentionPolicy updates the PVCs used by pod to match the PVC deletion policy of set.

func (*StatefulPodControl) UpdateStatefulPod

func (spc *StatefulPodControl) UpdateStatefulPod(ctx context.Context, set *api.PetSet, pod *v1.Pod) error

type StatefulPodControlObjectManager

type StatefulPodControlObjectManager interface {
	CreatePod(ctx context.Context, pod *v1.Pod) error
	GetPod(namespace, podName string) (*v1.Pod, error)
	UpdatePod(pod *v1.Pod) error
	DeletePod(pod *v1.Pod) error
	ListPods(ns, labels string) (*v1.PodList, error)
	CreateClaim(claim *v1.PersistentVolumeClaim) error
	GetClaim(namespace, claimName string) (*v1.PersistentVolumeClaim, error)
	UpdateClaim(claim *v1.PersistentVolumeClaim) error
	GetPlacementPolicy(name string) (*api.PlacementPolicy, error)
}

StatefulPodControlObjectManager abstracts the manipulation of Pods and PVCs. The real controller implements this with a clientset for writes and listers for reads; for tests we provide stubs.

type StatefulSetStatusUpdaterInterface

type StatefulSetStatusUpdaterInterface interface {
	// UpdateStatefulSetStatus sets the set's Status to status. Implementations are required to retry on conflicts,
	// but fail on other errors. If the returned error is nil set's Status has been successfully set to status.
	UpdateStatefulSetStatus(ctx context.Context, set *api.PetSet, status *apps.StatefulSetStatus) error
}

StatefulSetStatusUpdaterInterface is an interface used to update the StatefulSetStatus associated with a PetSet. For any use other than testing, clients should create an instance using NewRealStatefulSetStatusUpdater.

func NewRealStatefulSetStatusUpdater

func NewRealStatefulSetStatusUpdater(
	client versioned.Interface,
	setLister apilisters.PetSetLister,
) StatefulSetStatusUpdaterInterface

NewRealStatefulSetStatusUpdater returns a StatefulSetStatusUpdaterInterface that updates the Status of a PetSet, using the supplied client and setLister.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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