Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(trait): revert default health enabled #5516

Merged
merged 2 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 5 additions & 1 deletion e2e/install/upgrade/cli_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ func TestCLIOperatorUpgrade(t *testing.T) {
g.Eventually(PlatformVersion(t, ctx, ns), TestTimeoutMedium).Should(Equal(defaults.Version))

// Check the Integration hasn't been upgraded
g.Consistently(IntegrationVersion(t, ctx, ns, name), 5*time.Second, 1*time.Second).Should(Equal(version))
g.Consistently(IntegrationVersion(t, ctx, ns, name), 15*time.Second, 3*time.Second).Should(Equal(version))
// Make sure that any Pod rollout is completing successfully
// otherwise we are probably in front of a non breaking compatibility change
g.Consistently(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady),
2*time.Minute, 15*time.Second).Should(Equal(corev1.ConditionTrue))

// Force the Integration upgrade
g.Expect(Kamel(t, ctx, "rebuild", name, "-n", ns).Execute()).To(Succeed())
Expand Down
11 changes: 9 additions & 2 deletions e2e/install/upgrade/olm_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ func TestOLMOperatorUpgrade(t *testing.T) {
g.Consistently(IntegrationVersion(t, ctx, ns, name), 5*time.Second, 1*time.Second).
Should(ContainSubstring(prevIPVersionPrefix))

// Make sure that any Pod rollout is completing successfully
// otherwise we are probably in front of a non breaking compatibility change
g.Consistently(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady),
2*time.Minute, 15*time.Second).Should(Equal(corev1.ConditionTrue))
g.Consistently(IntegrationConditionStatus(t, ctx, ns, kbindName, v1.IntegrationConditionReady),
2*time.Minute, 15*time.Second).Should(Equal(corev1.ConditionTrue))

// Rebuild the Integration
g.Expect(Kamel(t, ctx, "rebuild", "--all", "-n", ns).Execute()).To(Succeed())
if prevCSVVersion.Version.String() >= "2" {
Expand Down Expand Up @@ -244,9 +251,9 @@ func TestOLMOperatorUpgrade(t *testing.T) {
// Check the Integration runs correctly
g.Eventually(IntegrationPodPhase(t, ctx, ns, name)).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationPodPhase(t, ctx, ns, kbindName)).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutLong).
g.Eventually(IntegrationConditionStatus(t, ctx, ns, name, v1.IntegrationConditionReady), TestTimeoutMedium).
Should(Equal(corev1.ConditionTrue))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, kbindName, v1.IntegrationConditionReady), TestTimeoutLong).
g.Eventually(IntegrationConditionStatus(t, ctx, ns, kbindName, v1.IntegrationConditionReady), TestTimeoutMedium).
Should(Equal(corev1.ConditionTrue))

// Clean up
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)
}
Loading