MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / New

Function New

internal/cmd/manager/instance/run/lease/runnable.go:117–141  ·  view source on GitHub ↗

New creates a new Runnable.

(
	kubeClient kubernetes.Interface,
	instance *postgres.Instance,
)

Source from the content-addressed store, hash-verified

115
116// New creates a new Runnable.
117func New(
118 kubeClient kubernetes.Interface,
119 instance *postgres.Instance,
120) *Runnable {
121 return &Runnable{
122 instance: instance,
123 config: defaultConfig(),
124 lock: &resourcelock.LeaseLock{
125 LeaseMeta: metav1.ObjectMeta{
126 Namespace: instance.GetNamespaceName(),
127 Name: instance.GetClusterName(),
128 },
129 Client: kubeClient.CoordinationV1(),
130 LockConfig: resourcelock.ResourceLockConfig{
131 // Identity is the pod name alone. The operator creates Pods
132 // directly and reuses a pod name only after the previous
133 // incarnation is confirmed dead, so any process running under
134 // this Identity is the legitimate holder.
135 Identity: instance.GetPodName(),
136 },
137 },
138 activateCh: make(chan struct{}),
139 heldCh: make(chan struct{}),
140 }
141}
142
143// Acquire signals the runnable to start competing for the lease using the
144// provided configuration, then blocks until the lease is held or ctx is

Callers 2

runSubCommandFunction · 0.92
runnable_test.goFile · 0.70

Calls 4

defaultConfigFunction · 0.85
GetNamespaceNameMethod · 0.65
GetClusterNameMethod · 0.65
GetPodNameMethod · 0.65

Tested by

no test coverage detected