Skip to content

Commit

Permalink
Temporarily take out probes
Browse files Browse the repository at this point in the history
  • Loading branch information
robbavey committed Feb 15, 2023
1 parent 8016b7b commit 6eabf4c
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 75 deletions.
7 changes: 0 additions & 7 deletions pkg/controller/common/container/defaulter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 0 additions & 6 deletions pkg/controller/common/defaults/pod_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
93 changes: 47 additions & 46 deletions pkg/controller/logstash/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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,
// },
// },
// }
//}
13 changes: 6 additions & 7 deletions test/e2e/test/logstash/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

type Builder struct {
Logstash v1alpha1.Logstash
Logstash v1alpha1.Logstash
MutatedFrom *Builder
}

Expand All @@ -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 {
Expand Down Expand Up @@ -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

Expand Down
7 changes: 3 additions & 4 deletions test/e2e/test/logstash/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
},
},
}
Expand All @@ -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 {
Expand Down
11 changes: 6 additions & 5 deletions test/e2e/test/logstash/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6eabf4c

Please sign in to comment.