Skip to content

Commit 2088d85

Browse files
committed
cr: add comments on the upstream code
1 parent 1663433 commit 2088d85

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

internal/patroni/reconcile.go

+12
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ func instanceProbes(cluster *v1beta1.PostgresCluster, container *corev1.Containe
150150
// TODO(cbandy): Consider if a PreStop hook is necessary.
151151
container.LivenessProbe = probeTiming(cluster.Spec.Patroni)
152152
container.LivenessProbe.InitialDelaySeconds = 3
153+
// Create the probe handler through a constructor for the liveness probe.
154+
// Introduced with K8SPG-708.
153155
container.LivenessProbe.ProbeHandler = livenessProbe(cluster)
154156

155157
// Readiness is reflected in the controlling object's status (e.g. ReadyReplicas)
@@ -159,9 +161,15 @@ func instanceProbes(cluster *v1beta1.PostgresCluster, container *corev1.Containe
159161
// of the leader Pod in the leader Service.
160162
container.ReadinessProbe = probeTiming(cluster.Spec.Patroni)
161163
container.ReadinessProbe.InitialDelaySeconds = 3
164+
// Create the probe handler through a constructor for the readiness probe.
165+
// Introduced with K8SPG-708.
162166
container.ReadinessProbe.ProbeHandler = readinessProbe(cluster)
163167
}
164168

169+
// livenessProbe is a custom constructor for the liveness probe.
170+
// This allows for more sophisticated logic to determine whether
171+
// the database container is considered "alive" beyond basic checks.
172+
// Introduced with K8SPG-708.
165173
func livenessProbe(cluster *v1beta1.PostgresCluster) corev1.ProbeHandler {
166174
if cluster.CompareVersion("2.7.0") >= 0 {
167175
return corev1.ProbeHandler{
@@ -179,6 +187,10 @@ func livenessProbe(cluster *v1beta1.PostgresCluster) corev1.ProbeHandler {
179187
}
180188
}
181189

190+
// readinessProbe is a custom constructor for the liveness probe.
191+
// This allows for more sophisticated logic to determine whether
192+
// the database container is considered "alive" beyond basic checks.
193+
// Introduced with K8SPG-708.
182194
func readinessProbe(cluster *v1beta1.PostgresCluster) corev1.ProbeHandler {
183195
if cluster.CompareVersion("2.7.0") >= 0 {
184196
return corev1.ProbeHandler{

internal/patroni/reconcile_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ func TestInstanceConfigMap(t *testing.T) {
114114
func TestInstancePod(t *testing.T) {
115115
t.Parallel()
116116

117+
// K8SPG-708 introduced the refactoring to this unit test.
117118
tests := map[string]struct {
118119
expectedSpec string
119120
labels map[string]string

0 commit comments

Comments
 (0)