Skip to content

Commit 168c12a

Browse files
gkechhors
andauthored
K8SPS-465 adjust probes for haproxy (#1027)
* K8SPS-465 adjust probes for haproxy * remove error word from info log * update e2e test for haproxy --------- Co-authored-by: Viacheslav Sarzhan <[email protected]>
1 parent 03bbdff commit 168c12a

File tree

4 files changed

+33
-23
lines changed

4 files changed

+33
-23
lines changed

api/v1alpha1/perconaservermysql_types.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -790,30 +790,36 @@ func (cr *PerconaServerMySQL) CheckNSetDefaults(_ context.Context, serverVersion
790790
cr.Spec.Proxy.HAProxy = new(HAProxySpec)
791791
}
792792

793-
if cr.Spec.Proxy.HAProxy.LivenessProbe.PeriodSeconds == 0 {
794-
cr.Spec.Proxy.HAProxy.LivenessProbe.PeriodSeconds = 5
793+
if cr.Spec.Proxy.HAProxy.LivenessProbe.InitialDelaySeconds == 0 {
794+
cr.Spec.Proxy.HAProxy.LivenessProbe.InitialDelaySeconds = 60
795795
}
796-
if cr.Spec.Proxy.HAProxy.LivenessProbe.FailureThreshold == 0 {
797-
cr.Spec.Proxy.HAProxy.LivenessProbe.FailureThreshold = 3
796+
if cr.Spec.Proxy.HAProxy.LivenessProbe.TimeoutSeconds == 0 {
797+
cr.Spec.Proxy.HAProxy.LivenessProbe.TimeoutSeconds = 3
798+
}
799+
if cr.Spec.Proxy.HAProxy.LivenessProbe.PeriodSeconds == 0 {
800+
cr.Spec.Proxy.HAProxy.LivenessProbe.PeriodSeconds = 30
798801
}
799802
if cr.Spec.Proxy.HAProxy.LivenessProbe.SuccessThreshold == 0 {
800803
cr.Spec.Proxy.HAProxy.LivenessProbe.SuccessThreshold = 1
801804
}
802-
if cr.Spec.Proxy.HAProxy.LivenessProbe.TimeoutSeconds == 0 {
803-
cr.Spec.Proxy.HAProxy.LivenessProbe.TimeoutSeconds = 3
805+
if cr.Spec.Proxy.HAProxy.LivenessProbe.FailureThreshold == 0 {
806+
cr.Spec.Proxy.HAProxy.LivenessProbe.FailureThreshold = 4
804807
}
805808

809+
if cr.Spec.Proxy.HAProxy.ReadinessProbe.InitialDelaySeconds == 0 {
810+
cr.Spec.Proxy.HAProxy.ReadinessProbe.InitialDelaySeconds = 15
811+
}
812+
if cr.Spec.Proxy.HAProxy.ReadinessProbe.TimeoutSeconds == 0 {
813+
cr.Spec.Proxy.HAProxy.ReadinessProbe.TimeoutSeconds = 1
814+
}
806815
if cr.Spec.Proxy.HAProxy.ReadinessProbe.PeriodSeconds == 0 {
807816
cr.Spec.Proxy.HAProxy.ReadinessProbe.PeriodSeconds = 5
808817
}
809-
if cr.Spec.Proxy.HAProxy.ReadinessProbe.FailureThreshold == 0 {
810-
cr.Spec.Proxy.HAProxy.ReadinessProbe.FailureThreshold = 3
811-
}
812818
if cr.Spec.Proxy.HAProxy.ReadinessProbe.SuccessThreshold == 0 {
813819
cr.Spec.Proxy.HAProxy.ReadinessProbe.SuccessThreshold = 1
814820
}
815-
if cr.Spec.Proxy.HAProxy.ReadinessProbe.TimeoutSeconds == 0 {
816-
cr.Spec.Proxy.HAProxy.ReadinessProbe.TimeoutSeconds = 3
821+
if cr.Spec.Proxy.HAProxy.ReadinessProbe.FailureThreshold == 0 {
822+
cr.Spec.Proxy.HAProxy.ReadinessProbe.FailureThreshold = 3
817823
}
818824

819825
var fsgroup *int64

e2e-tests/tests/haproxy/01-assert.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ spec:
4444
- name: LIVENESS_CHECK_TIMEOUT
4545
value: "30"
4646
- name: READINESS_CHECK_TIMEOUT
47-
value: "3"
47+
value: "1"
4848
image: perconalab/percona-server-mysql-operator:main-haproxy
4949
imagePullPolicy: Always
5050
livenessProbe:
5151
exec:
5252
command:
5353
- /opt/percona/haproxy_liveness_check.sh
54-
failureThreshold: 3
54+
initialDelaySeconds: 60
55+
failureThreshold: 4
5556
periodSeconds: 10
5657
successThreshold: 1
5758
timeoutSeconds: 30
@@ -73,10 +74,11 @@ spec:
7374
exec:
7475
command:
7576
- /opt/percona/haproxy_readiness_check.sh
77+
initialDelaySeconds: 15
7678
failureThreshold: 40
7779
periodSeconds: 5
7880
successThreshold: 10
79-
timeoutSeconds: 3
81+
timeoutSeconds: 1
8082
resources:
8183
requests:
8284
cpu: 600m

pkg/haproxy/haproxy_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,21 @@ func TestStatefulset(t *testing.T) {
153153
ProbeHandler: corev1.ProbeHandler{
154154
Exec: &corev1.ExecAction{Command: []string{"/opt/percona/haproxy_readiness_check.sh"}},
155155
},
156-
TimeoutSeconds: 3,
157-
PeriodSeconds: 5,
158-
FailureThreshold: 3,
159-
SuccessThreshold: 1,
156+
InitialDelaySeconds: 15,
157+
TimeoutSeconds: 1,
158+
PeriodSeconds: 5,
159+
SuccessThreshold: 1,
160+
FailureThreshold: 3,
160161
}
161162
expectedLivenessProbe := corev1.Probe{
162163
ProbeHandler: corev1.ProbeHandler{
163164
Exec: &corev1.ExecAction{Command: []string{"/opt/percona/haproxy_liveness_check.sh"}},
164165
},
165-
TimeoutSeconds: 3,
166-
PeriodSeconds: 5,
167-
FailureThreshold: 3,
168-
SuccessThreshold: 1,
166+
InitialDelaySeconds: 60,
167+
TimeoutSeconds: 3,
168+
PeriodSeconds: 30,
169+
SuccessThreshold: 1,
170+
FailureThreshold: 4,
169171
}
170172

171173
assert.Equal(t, expectedReadinessProbe, *hContainer.ReadinessProbe)

pkg/topology/topology.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func GroupReplication(ctx context.Context, cli client.Client, cliCmd clientcmd.C
3434

3535
pod, err := getReadyPod(ctx, cli, cluster)
3636
if err != nil {
37-
logger.Info(errors.Wrap(err, "error getting ready pod").Error())
37+
logger.Info(errors.Wrap(err, "getting ready pod").Error())
3838
return Topology{}, nil
3939
}
4040

0 commit comments

Comments
 (0)