lock

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LeaseDurationSeconds = int32(5)

LeaseDurationSeconds is the default duration for the Lease object. This defines the duration for how long a given xpdb is locked. The value should be higher than the sum of the following durations:

  • the round-trip latency across all clusters (1-2 seconds)
  • the processing time of the x-pdb http server (<1 second)
  • the time kube-apiserver needs to process the x-pdb admission control response and the time it takes until the desired action (evict/delete pod) is observable through the kube-apiserver (1-2 seconds)
  • a generous surcharge (1-... seconds)

Functions

func CreateLeaseHolderIdentity

func CreateLeaseHolderIdentity(clusterID, xpdbPodID, podNamespace, podName string) string

CreateLeaseHolderIdentity creates the leaseHolderIdentity for the lease used to perform the locking mechanism of the xpdb disruptions.

Types

type Service

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

Service is responsible to manage the locks used to guarantee that there are no race conditions when doing disruptions across clusters.

func NewService

func NewService(
	logger *logr.Logger,
	client client.Client,
	reader client.Reader,
	stateClientPool *stateclient.ClientPool,
	leaseNamespace string,
	remoteEndpoints []string,
) *Service

NewService creates a new Service instance.

func (*Service) LocalLock

func (s *Service) LocalLock(ctx context.Context, leaseHolderIdentity, namespace string, selector *metav1.LabelSelector) error

LocalLock creates / updates leases on the local cluster to disallow concurrent pod disruptions for a given namespace and selector.

func (*Service) LocalUnlock

func (s *Service) LocalUnlock(ctx context.Context, leaseHolderIdentity, namespace string, selector *metav1.LabelSelector) error

LocalUnlock deletes leases on the local cluster to allow pod disruptions to happen.

func (*Service) Lock

func (s *Service) Lock(ctx context.Context, leaseHolderIdentity, namespace string, selector *metav1.LabelSelector) error

Lock creates / updates leases on the local and remote clusters to disallow concurrent pod disruptions for a given namespace and selector.

func (*Service) Unlock

func (s *Service) Unlock(ctx context.Context, leaseHolderIdentity, namespace string, selector *metav1.LabelSelector) error

Unlock deletes leases on local and remote clusters to allow pod disruptions to happen.

Jump to

Keyboard shortcuts

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