Skip to content

Commit 9e12be0

Browse files
authored
Removed the extra handling of readinessProbe for nonHA cluster. (#1193)
* Removed the extra handling of readinessProbe for nonHA cluster. Now, nonHA cluster readinessProbe will use /readyz endpoint. * Removed unnecessary type arguments.
1 parent e74d8d9 commit 9e12be0

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

internal/component/statefulset/builder.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const (
4141
defaultPodManagementPolicy = appsv1.ParallelPodManagement
4242
rootUser = int64(0)
4343
nonRootUser = int64(65532)
44+
etcdWrapperReadyEndpoint = "/readyz"
4445
)
4546

4647
var (
@@ -136,7 +137,7 @@ func (b *stsBuilder) getStatefulSetLabels() map[string]string {
136137

137138
func (b *stsBuilder) createStatefulSetSpec(ctx component.OperatorContext) error {
138139
err := b.createPodTemplateSpec(ctx)
139-
b.sts.Spec.Replicas = ptr.To(utils.IfConditionOr[int32](druidv1alpha1.IsEtcdRuntimeComponentCreationEnabled(b.etcd.ObjectMeta), b.replicas, 0))
140+
b.sts.Spec.Replicas = ptr.To(utils.IfConditionOr(druidv1alpha1.IsEtcdRuntimeComponentCreationEnabled(b.etcd.ObjectMeta), b.replicas, 0))
140141
b.logger.Info("Creating StatefulSet spec", "replicas", b.sts.Spec.Replicas, "name", b.sts.Name, "namespace", b.sts.Namespace)
141142
b.sts.Spec.UpdateStrategy = defaultUpdateStrategy
142143
if err != nil {
@@ -593,16 +594,12 @@ func (b *stsBuilder) getEtcdContainerReadinessProbe() *corev1.Probe {
593594
}
594595

595596
func (b *stsBuilder) getEtcdContainerReadinessHandler() corev1.ProbeHandler {
596-
multiNodeCluster := b.etcd.Spec.Replicas > 1
597-
598597
scheme := utils.IfConditionOr(b.etcd.Spec.Backup.TLS == nil, corev1.URISchemeHTTP, corev1.URISchemeHTTPS)
599-
path := utils.IfConditionOr(multiNodeCluster, "/readyz", "/healthz")
600-
port := utils.IfConditionOr(multiNodeCluster, b.wrapperPort, b.backupPort)
601598

602599
return corev1.ProbeHandler{
603600
HTTPGet: &corev1.HTTPGetAction{
604-
Path: path,
605-
Port: intstr.FromInt32(port),
601+
Path: etcdWrapperReadyEndpoint,
602+
Port: intstr.FromInt32(b.wrapperPort),
606603
Scheme: scheme,
607604
},
608605
}

internal/component/statefulset/stsmatcher.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,12 @@ func (s StatefulSetMatcher) matchBackupRestoreContainer() gomegatypes.GomegaMatc
259259

260260
func (s StatefulSetMatcher) matchEtcdContainerReadinessHandler() gomegatypes.GomegaMatcher {
261261
scheme := utils.IfConditionOr(s.etcd.Spec.Backup.TLS == nil, corev1.URISchemeHTTP, corev1.URISchemeHTTPS)
262-
path := utils.IfConditionOr(s.etcd.Spec.Replicas > 1, "/readyz", "/healthz")
263-
port := utils.IfConditionOr(s.etcd.Spec.Replicas > 1, s.wrapperPort, s.backupPort)
264262
return MatchFields(IgnoreExtras|IgnoreMissing, Fields{
265263
"HTTPGet": PointTo(MatchFields(IgnoreExtras|IgnoreMissing, Fields{
266-
"Path": Equal(path),
264+
"Path": Equal(etcdWrapperReadyEndpoint),
267265
"Port": MatchFields(IgnoreExtras|IgnoreMissing, Fields{
268266
"Type": Equal(intstr.Int),
269-
"IntVal": Equal(port),
267+
"IntVal": Equal(s.wrapperPort),
270268
}),
271269
"Scheme": Equal(scheme),
272270
})),

0 commit comments

Comments
 (0)