Documentation ¶
Overview ¶
Package lock implements a ConfigMap lock similar to the one found in github.com/operator-framework/operator-sdk/pkg/leader.
The main difference is that it provides a Release mechanism as opposed to the Leader-for-life strategy the operator-sdk uses. This is useful for getting temporary locks on K8s resources. Also, since the user of the lock will not always dissapear, an expiration key is placed in the configMap to signal to another process when it's okay to release a stale lock.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock implements a simple locking mechanism backed by a configmap. When the lock is acquired, a configmap is made with an owner reference to the running pod. Another lock attempt will block until it can create the configmap with the same name, or if the lock expires.
func New ¶
New returns a new lock. If timeout is a value less than zero, then no expiration is placed on the lock. A safeguard for deadlocks is still in place due to the OwnerReference to the pod that holds the lock on the configmap.
func (*Lock) Acquire ¶
Acquire will attempt to acquire the lock, retrying until the lock is either acquired or the timeout is reached.
func (*Lock) GetTimeout ¶
GetTimeout returns the timeout for this lock.