Skip to content

Commit

Permalink
chore(trait): revert default health enabled
Browse files Browse the repository at this point in the history
It turned out to be a breaking compatibility change as the switch would require a forcefully rebuild that is not done automatically by the operator during upgrade procedures.
  • Loading branch information
squakez committed May 17, 2024
1 parent bb7fcfb commit 65e02b8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
33 changes: 16 additions & 17 deletions e2e/common/traits/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,12 @@ func TestHealthTrait(t *testing.T) {

g.Eventually(SelectedPlatformPhase(t, ctx, ns, operatorID), TestTimeoutMedium).Should(Equal(v1.IntegrationPlatformPhaseReady))

t.Run("Disabled health trait", func(t *testing.T) {
name := RandomizedSuffixName("java")
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/Java.java", "-t", "health.enabled=false", "--name", name).Execute()).To(Succeed())

g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationPhase(t, ctx, ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutShort).
Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationLogs(t, ctx, ns, name), TestTimeoutShort).Should(ContainSubstring("Magicstring!"))

// Clean-up
g.Expect(Kamel(t, ctx, "delete", "--all", "-n", ns).Execute()).To(Succeed())
})

t.Run("Readiness condition with stopped route scaled", func(t *testing.T) {
name := RandomizedSuffixName("java")
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/Java.java", "-t", "jolokia.enabled=true", "-t", "jolokia.use-ssl-client-authentication=false", "-t", "jolokia.protocol=http", "--name", name).Execute()).To(Succeed())
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/Java.java",
"-t", "health.enabled=true",
"-t", "jolokia.enabled=true", "-t", "jolokia.use-ssl-client-authentication=false",
"-t", "jolokia.protocol=http", "--name", name).Execute()).To(Succeed())

g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationPhase(t, ctx, ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
Expand Down Expand Up @@ -158,7 +147,10 @@ func TestHealthTrait(t *testing.T) {

t.Run("Readiness condition with stopped route", func(t *testing.T) {
name := RandomizedSuffixName("java")
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/Java.java", "-t", "jolokia.enabled=true", "-t", "jolokia.use-ssl-client-authentication=false", "-t", "jolokia.protocol=http", "--name", name).Execute()).To(Succeed())
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/Java.java",
"-t", "health.enabled=true",
"-t", "jolokia.enabled=true", "-t", "jolokia.use-ssl-client-authentication=false",
"-t", "jolokia.protocol=http", "--name", name).Execute()).To(Succeed())

g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationPhase(t, ctx, ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
Expand Down Expand Up @@ -251,7 +243,12 @@ func TestHealthTrait(t *testing.T) {
g.Expect(CreateTimerKamelet(t, ctx, operatorID, ns, source)()).To(Succeed())
g.Expect(CreateLogKamelet(t, ctx, operatorID, ns, sink)()).To(Succeed())

g.Expect(KamelBindWithID(t, ctx, operatorID, ns, source, sink, "-p", "source.message=Magicstring!", "-p", "sink.loggerName=binding", "--annotation", "trait.camel.apache.org/health.enabled=true", "--annotation", "trait.camel.apache.org/jolokia.enabled=true", "--annotation", "trait.camel.apache.org/jolokia.use-ssl-client-authentication=false", "--annotation", "trait.camel.apache.org/jolokia.protocol=http", "--name", name).Execute()).To(Succeed())
g.Expect(KamelBindWithID(t, ctx, operatorID, ns, source, sink, "-p",
"source.message=Magicstring!", "-p", "sink.loggerName=binding",
"--annotation", "trait.camel.apache.org/health.enabled=true",
"--annotation", "trait.camel.apache.org/jolokia.enabled=true",
"--annotation", "trait.camel.apache.org/jolokia.use-ssl-client-authentication=false",
"--annotation", "trait.camel.apache.org/jolokia.protocol=http", "--name", name).Execute()).To(Succeed())

g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutLong).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationPhase(t, ctx, ns, name), TestTimeoutShort).Should(Equal(v1.IntegrationPhaseRunning))
Expand Down Expand Up @@ -414,6 +411,7 @@ func TestHealthTrait(t *testing.T) {
name := RandomizedSuffixName("startup-probe-never-ready-route")

g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/NeverReady.java", "--name", name,
"-t", "health.enabled=true",
"-t", "health.startup-probe-enabled=true", "-t", "health.startup-timeout=60").Execute()).To(Succeed())

g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
Expand Down Expand Up @@ -463,6 +461,7 @@ func TestHealthTrait(t *testing.T) {
name := RandomizedSuffixName("startup-probe-ready-route")

g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "files/Java.java", "--name", name,
"-t", "health.enabled=true",
"-t", "health.startup-probe-enabled=true", "-t", "health.startup-timeout=60").Execute()).To(Succeed())

g.Eventually(IntegrationPodPhase(t, ctx, ns, name), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/camel/v1/trait/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package trait

// The health trait is responsible for configuring the health probes on the integration container.
//
// NOTE: this trait is enabled by default.
// NOTE: this trait is disabled by default.
//
// +camel-k:trait=health.
type HealthTrait struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/trait/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (t *healthTrait) Configure(e *Environment) (bool, *TraitCondition, error) {
}
}

return pointer.BoolDeref(t.Enabled, true), nil, nil
return pointer.BoolDeref(t.Enabled, false), nil, nil
}

func (t *healthTrait) Apply(e *Environment) error {
Expand Down
14 changes: 9 additions & 5 deletions pkg/trait/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,28 +119,30 @@ func TestHealthTrait(t *testing.T) {
assert.Equal(t, "/q/health/started", d.Spec.Template.Spec.Containers[0].StartupProbe.HTTPGet.Path)
}

func TestConfigureHealthTraitDoesSucceed(t *testing.T) {
func TestConfigureHealthTraitDefault(t *testing.T) {
ht, environment := createNominalHealthTrait(t)
configured, condition, err := ht.Configure(environment)

assert.True(t, configured)
assert.False(t, configured)
assert.Nil(t, err)
assert.Nil(t, condition)
}

func TestConfigureHealthTraitDisabled(t *testing.T) {
enabled := false
func TestConfigureHealthTraitEnabled(t *testing.T) {
enabled := true
ht, environment := createNominalHealthTrait(t)
ht.Enabled = &enabled
configured, condition, err := ht.Configure(environment)

assert.False(t, configured)
assert.True(t, configured)
assert.Nil(t, err)
assert.Nil(t, condition)
}

func TestApplyHealthTraitDefault(t *testing.T) {
enabled := true
ht, environment := createNominalHealthTrait(t)
ht.Enabled = &enabled
configured, condition, err := ht.Configure(environment)
assert.True(t, configured)
assert.Nil(t, err)
Expand All @@ -155,6 +157,7 @@ func TestApplyHealthTraitDefault(t *testing.T) {
func TestApplyHealthTraitLivenessDefault(t *testing.T) {
enabled := true
ht, environment := createNominalHealthTrait(t)
ht.Enabled = &enabled
ht.LivenessProbeEnabled = &enabled
configured, condition, err := ht.Configure(environment)
assert.True(t, configured)
Expand All @@ -171,6 +174,7 @@ func TestApplyHealthTraitLivenessDefault(t *testing.T) {
func TestApplyHealthTraitStartupDefault(t *testing.T) {
enabled := true
ht, environment := createNominalHealthTrait(t)
ht.Enabled = &enabled
ht.StartupProbeEnabled = &enabled
configured, condition, err := ht.Configure(environment)
assert.True(t, configured)
Expand Down
2 changes: 1 addition & 1 deletion pkg/trait/trait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ func TestExecutedTraitsCondition(t *testing.T) {
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
"TraitConfiguration",
"Applied traits: camel,environment,logging,deployer,deployment,gc,container,security-context,mount,health,quarkus,jvm,owner",
"Applied traits: camel,environment,logging,deployer,deployment,gc,container,security-context,mount,quarkus,jvm,owner",
)
assert.Contains(t, conditions, expectedCondition)
}

0 comments on commit 65e02b8

Please sign in to comment.