diff --git a/pkg/controller/common/container/defaulter.go b/pkg/controller/common/container/defaulter.go index 0b03d42aa0..c007b0be79 100644 --- a/pkg/controller/common/container/defaulter.go +++ b/pkg/controller/common/container/defaulter.go @@ -96,13 +96,6 @@ func (d Defaulter) WithReadinessProbe(readinessProbe *corev1.Probe) Defaulter { return d } -func (d Defaulter) WithLivenessProbe(livenessProbe *corev1.Probe) Defaulter { - if d.base.LivenessProbe == nil { - d.base.LivenessProbe = livenessProbe - } - return d -} - // envExists checks if an env var with the given name already exists in the provided slice. func (d Defaulter) envExists(name string) bool { for _, v := range d.base.Env { diff --git a/pkg/controller/common/defaults/pod_template.go b/pkg/controller/common/defaults/pod_template.go index 073223a0c0..81cfea9331 100644 --- a/pkg/controller/common/defaults/pod_template.go +++ b/pkg/controller/common/defaults/pod_template.go @@ -121,12 +121,6 @@ func (b *PodTemplateBuilder) WithReadinessProbe(readinessProbe corev1.Probe) *Po return b } -// WithLivenessProbe sets up the given liveness probe, unless already provided in the template. -func (b *PodTemplateBuilder) WithLivenessProbe(livenessProbe corev1.Probe) *PodTemplateBuilder { - b.containerDefaulter.WithLivenessProbe(&livenessProbe) - return b -} - // WithAffinity sets a default affinity, unless already provided in the template. // An empty affinity in the spec is not overridden. func (b *PodTemplateBuilder) WithAffinity(affinity *corev1.Affinity) *PodTemplateBuilder { diff --git a/pkg/controller/logstash/pod.go b/pkg/controller/logstash/pod.go index d6c139b83a..281757d135 100644 --- a/pkg/controller/logstash/pod.go +++ b/pkg/controller/logstash/pod.go @@ -11,7 +11,8 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" - "k8s.io/apimachinery/pkg/util/intstr" + + // "k8s.io/apimachinery/pkg/util/intstr" logstashv1alpha1 "github.com/elastic/cloud-on-k8s/v2/pkg/apis/logstash/v1alpha1" "github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/container" @@ -81,8 +82,8 @@ func buildPodTemplate(params Params, configHash hash.Hash32) corev1.PodTemplateS WithDockerImage(spec.Image, container.ImageRepository(container.LogstashImage, spec.Version)). WithAutomountServiceAccountToken(). WithPorts(ports). - //WithReadinessProbe(readinessProbe(false)). - //WithLivenessProbe(livenessProbe(false)). + // WithReadinessProbe(readinessProbe(false)). + // WithLivenessProbe(livenessProbe(false)). WithVolumeLikes(vols...) // TODO integrate with api.ssl.enabled @@ -102,46 +103,46 @@ func getDefaultContainerPorts(logstash logstashv1alpha1.Logstash) []corev1.Conta } } -// readinessProbe is the readiness probe for the Logstash container -func readinessProbe(useTLS bool) corev1.Probe { - scheme := corev1.URISchemeHTTP - if useTLS { - scheme = corev1.URISchemeHTTPS - } - return corev1.Probe{ - FailureThreshold: 3, - InitialDelaySeconds: 30, - PeriodSeconds: 10, - SuccessThreshold: 1, - TimeoutSeconds: 5, - ProbeHandler: corev1.ProbeHandler{ - HTTPGet: &corev1.HTTPGetAction{ - Port: intstr.FromInt(network.HTTPPort), - Path: "/", - Scheme: scheme, - }, - }, - } -} - -// livenessProbe is the liveness probe for the Logstash container -func livenessProbe(useTLS bool) corev1.Probe { - scheme := corev1.URISchemeHTTP - if useTLS { - scheme = corev1.URISchemeHTTPS - } - return corev1.Probe{ - FailureThreshold: 3, - InitialDelaySeconds: 60, - PeriodSeconds: 10, - SuccessThreshold: 1, - TimeoutSeconds: 5, - ProbeHandler: corev1.ProbeHandler{ - HTTPGet: &corev1.HTTPGetAction{ - Port: intstr.FromInt(network.HTTPPort), - Path: "/", - Scheme: scheme, - }, - }, - } -} +//// readinessProbe is the readiness probe for the Logstash container +// func readinessProbe(useTLS bool) corev1.Probe { +// scheme := corev1.URISchemeHTTP +// if useTLS { +// scheme = corev1.URISchemeHTTPS +// } +// return corev1.Probe{ +// FailureThreshold: 3, +// InitialDelaySeconds: 30, +// PeriodSeconds: 10, +// SuccessThreshold: 1, +// TimeoutSeconds: 5, +// ProbeHandler: corev1.ProbeHandler{ +// HTTPGet: &corev1.HTTPGetAction{ +// Port: intstr.FromInt(network.HTTPPort), +// Path: "/", +// Scheme: scheme, +// }, +// }, +// } +//} +// +//// livenessProbe is the liveness probe for the Logstash container +// func livenessProbe(useTLS bool) corev1.Probe { +// scheme := corev1.URISchemeHTTP +// if useTLS { +// scheme = corev1.URISchemeHTTPS +// } +// return corev1.Probe{ +// FailureThreshold: 3, +// InitialDelaySeconds: 60, +// PeriodSeconds: 10, +// SuccessThreshold: 1, +// TimeoutSeconds: 5, +// ProbeHandler: corev1.ProbeHandler{ +// HTTPGet: &corev1.HTTPGetAction{ +// Port: intstr.FromInt(network.HTTPPort), +// Path: "/", +// Scheme: scheme, +// }, +// }, +// } +//} diff --git a/test/e2e/test/logstash/builder.go b/test/e2e/test/logstash/builder.go index 8b08b9119d..8ae6cd1678 100644 --- a/test/e2e/test/logstash/builder.go +++ b/test/e2e/test/logstash/builder.go @@ -18,7 +18,7 @@ import ( ) type Builder struct { - Logstash v1alpha1.Logstash + Logstash v1alpha1.Logstash MutatedFrom *Builder } @@ -40,15 +40,15 @@ func newBuilder(name, randSuffix string) Builder { Logstash: v1alpha1.Logstash{ ObjectMeta: meta, Spec: v1alpha1.LogstashSpec{ - Count: 1, + Count: 1, Version: def.Version, }, }, }. - WithImage(def.Image). - WithSuffix(randSuffix). - WithLabel(run.TestNameLabel, name). - WithPodLabel(run.TestNameLabel, name) + WithImage(def.Image). + WithSuffix(randSuffix). + WithLabel(run.TestNameLabel, name). + WithPodLabel(run.TestNameLabel, name) } func (b Builder) WithImage(image string) Builder { @@ -134,7 +134,6 @@ func (b Builder) ListOptions() []client.ListOption { return test.LogstashPodListOptions(b.Logstash.Namespace, b.Logstash.Name) } - func (b Builder) SkipTest() bool { supportedVersions := version.SupportedLogstashVersions diff --git a/test/e2e/test/logstash/checks.go b/test/e2e/test/logstash/checks.go index 2e50f486d2..6c8ed2d188 100644 --- a/test/e2e/test/logstash/checks.go +++ b/test/e2e/test/logstash/checks.go @@ -13,7 +13,6 @@ import ( "github.com/elastic/cloud-on-k8s/v2/test/e2e/test" ) - // CheckSecrets checks that expected secrets have been created. func CheckSecrets(b Builder, k *test.K8sClient) test.Step { return test.CheckSecretsContent(k, b.Logstash.Namespace, func() []test.ExpectedSecret { @@ -25,7 +24,7 @@ func CheckSecrets(b Builder, k *test.K8sClient) test.Step { Keys: []string{"logstash.yml"}, Labels: map[string]string{ "eck.k8s.elastic.co/credentials": "true", - "logstash.k8s.elastic.co/name": logstashName, + "logstash.k8s.elastic.co/name": logstashName, }, }, } @@ -45,8 +44,8 @@ func CheckStatus(b Builder, k *test.K8sClient) test.Step { logstash.Status.ObservedGeneration = 0 expected := logstashv1alpha1.LogstashStatus{ - ExpectedNodes: b.Logstash.Spec.Count, - AvailableNodes: b.Logstash.Spec.Count, + ExpectedNodes: b.Logstash.Spec.Count, + AvailableNodes: b.Logstash.Spec.Count, Version: b.Logstash.Spec.Version, } if logstash.Status != expected { diff --git a/test/e2e/test/logstash/steps.go b/test/e2e/test/logstash/steps.go index 2c66762429..44f2a5f4e0 100644 --- a/test/e2e/test/logstash/steps.go +++ b/test/e2e/test/logstash/steps.go @@ -10,12 +10,13 @@ import ( corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" - //"k8s.io/apimachinery/pkg/types" + + // "k8s.io/apimachinery/pkg/types" logstashv1alpha1 "github.com/elastic/cloud-on-k8s/v2/pkg/apis/logstash/v1alpha1" - //mapsv1alpha1 "github.com/elastic/cloud-on-k8s/v2/pkg/apis/maps/v1alpha1" - //"github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/certificates" - //"github.com/elastic/cloud-on-k8s/v2/pkg/controller/logstash" + // mapsv1alpha1 "github.com/elastic/cloud-on-k8s/v2/pkg/apis/maps/v1alpha1" + // "github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/certificates" + // "github.com/elastic/cloud-on-k8s/v2/pkg/controller/logstash" "github.com/elastic/cloud-on-k8s/v2/pkg/utils/k8s" "github.com/elastic/cloud-on-k8s/v2/test/e2e/cmd/run" "github.com/elastic/cloud-on-k8s/v2/test/e2e/test" @@ -52,7 +53,7 @@ func (b Builder) InitTestSteps(k *test.K8sClient) test.StepList { return k.Client.List(context.Background(), crd) }), }, - { + { Name: "Remove Logstash if it already exists", Test: test.Eventually(func() error { err := k.Client.Delete(context.Background(), &b.Logstash)