You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2024/03/22 09:05:23 UTC
(camel-k) 02/02: chore(trait): polish conditions
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 196020d065469b00019cd044cea02514e6665904
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Thu Mar 21 17:26:59 2024 +0100
chore(trait): polish conditions
Closes #5027
---
addons/master/master.go | 2 +-
addons/telemetry/telemetry.go | 1 +
e2e/common/runtimes/runtimes_test.go | 6 +++---
e2e/common/traits/builder_test.go | 18 +++++++++---------
pkg/controller/build/monitor_pod.go | 2 +-
pkg/trait/builder.go | 4 ++--
pkg/trait/container.go | 1 +
pkg/trait/container_probes_test.go | 6 ++++--
pkg/trait/container_test.go | 1 +
pkg/trait/cron.go | 6 +++++-
pkg/trait/cron_test.go | 6 ++++--
pkg/trait/deployment.go | 2 ++
pkg/trait/gc.go | 2 +-
pkg/trait/gc_test.go | 1 +
pkg/trait/ingress.go | 1 +
pkg/trait/ingress_test.go | 1 +
pkg/trait/jvm.go | 8 ++++----
pkg/trait/jvm_test.go | 3 +++
pkg/trait/kamelets.go | 2 +-
pkg/trait/knative.go | 2 +-
pkg/trait/knative_service.go | 4 ++++
pkg/trait/logging.go | 2 +-
pkg/trait/mount.go | 3 +++
pkg/trait/owner.go | 2 +-
pkg/trait/pod.go | 2 +-
pkg/trait/pull_secret.go | 2 +-
pkg/trait/quarkus.go | 2 +-
pkg/trait/registry.go | 1 +
pkg/trait/route.go | 1 +
pkg/trait/route_test.go | 3 ++-
pkg/trait/service.go | 4 +++-
pkg/trait/service_binding.go | 2 +-
pkg/trait/service_test.go | 15 ++++++++++-----
pkg/trait/trait_catalog.go | 3 +--
pkg/trait/trait_condition_types.go | 26 +++++++++++++++++---------
pkg/trait/trait_test.go | 1 +
36 files changed, 96 insertions(+), 52 deletions(-)
diff --git a/addons/master/master.go b/addons/master/master.go
index b28730784..476f68bf8 100644
--- a/addons/master/master.go
+++ b/addons/master/master.go
@@ -112,7 +112,7 @@ func (t *masterTrait) Configure(e *trait.Environment) (bool, *trait.TraitConditi
}
}
if !pointer.BoolDeref(t.Enabled, false) {
- return false, trait.NewIntegrationConditionUserDisabled(), nil
+ return false, trait.NewIntegrationConditionUserDisabled("Master"), nil
}
if t.IncludeDelegateDependencies == nil || *t.IncludeDelegateDependencies {
t.delegateDependencies = findAdditionalDependencies(e, meta)
diff --git a/addons/telemetry/telemetry.go b/addons/telemetry/telemetry.go
index a3975bd04..e77f8b97b 100644
--- a/addons/telemetry/telemetry.go
+++ b/addons/telemetry/telemetry.go
@@ -103,6 +103,7 @@ func (t *telemetryTrait) Configure(e *trait.Environment) (bool, *trait.TraitCond
if endpoint != "" {
t.L.Infof("Using tracing endpoint: %s", endpoint)
condition = trait.NewIntegrationCondition(
+ "Telemetry",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
"TracingEndpoint",
diff --git a/e2e/common/runtimes/runtimes_test.go b/e2e/common/runtimes/runtimes_test.go
index 45829d674..dee3ae100 100644
--- a/e2e/common/runtimes/runtimes_test.go
+++ b/e2e/common/runtimes/runtimes_test.go
@@ -54,7 +54,7 @@ func TestSourceLessIntegrations(t *testing.T) {
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "--image", "docker.io/squakez/my-camel-main:1.0.0", "--resource", "configmap:my-cm-sourceless@/tmp/app/data").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, itName), TestTimeoutShort).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, itName, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- g.Eventually(IntegrationCondition(t, ctx, ns, itName, v1.IntegrationConditionTraitInfo)().Message).Should(Equal("explicitly disabled by the platform: integration kit was not created via Camel K operator"))
+ g.Eventually(IntegrationCondition(t, ctx, ns, itName, v1.IntegrationConditionType("JVMTraitInfo"))().Message).Should(Equal("explicitly disabled by the platform: integration kit was not created via Camel K operator"))
g.Eventually(IntegrationLogs(t, ctx, ns, itName), TestTimeoutShort).Should(ContainSubstring(cmData["my-file.txt"]))
g.Eventually(IntegrationLogs(t, ctx, ns, itName), TestTimeoutShort).Should(ContainSubstring("Apache Camel (Main)"))
})
@@ -64,7 +64,7 @@ func TestSourceLessIntegrations(t *testing.T) {
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "--image", "docker.io/squakez/my-camel-sb:1.0.0", "--resource", "configmap:my-cm-sourceless@/tmp/app/data").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, itName), TestTimeoutShort).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, itName, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- g.Eventually(IntegrationCondition(t, ctx, ns, itName, v1.IntegrationConditionTraitInfo)().Message).Should(Equal("explicitly disabled by the platform: integration kit was not created via Camel K operator"))
+ g.Eventually(IntegrationCondition(t, ctx, ns, itName, v1.IntegrationConditionType("JVMTraitInfo"))().Message).Should(Equal("explicitly disabled by the platform: integration kit was not created via Camel K operator"))
g.Eventually(IntegrationLogs(t, ctx, ns, itName), TestTimeoutShort).Should(ContainSubstring(cmData["my-file.txt"]))
g.Eventually(IntegrationLogs(t, ctx, ns, itName), TestTimeoutShort).Should(ContainSubstring("Spring Boot"))
})
@@ -74,7 +74,7 @@ func TestSourceLessIntegrations(t *testing.T) {
g.Expect(KamelRunWithID(t, ctx, operatorID, ns, "--image", "docker.io/squakez/my-camel-quarkus:1.0.0", "--resource", "configmap:my-cm-sourceless@/tmp/app/data").Execute()).To(Succeed())
g.Eventually(IntegrationPodPhase(t, ctx, ns, itName), TestTimeoutShort).Should(Equal(corev1.PodRunning))
g.Eventually(IntegrationConditionStatus(t, ctx, ns, itName, v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
- g.Eventually(IntegrationCondition(t, ctx, ns, itName, v1.IntegrationConditionTraitInfo)().Message).Should(Equal("explicitly disabled by the platform: integration kit was not created via Camel K operator"))
+ g.Eventually(IntegrationCondition(t, ctx, ns, itName, v1.IntegrationConditionType("JVMTraitInfo"))().Message).Should(Equal("explicitly disabled by the platform: integration kit was not created via Camel K operator"))
g.Eventually(IntegrationLogs(t, ctx, ns, itName), TestTimeoutShort).Should(ContainSubstring(cmData["my-file.txt"]))
g.Eventually(IntegrationLogs(t, ctx, ns, itName), TestTimeoutShort).Should(ContainSubstring("powered by Quarkus"))
})
diff --git a/e2e/common/traits/builder_test.go b/e2e/common/traits/builder_test.go
index e52dc1447..b329f5c2d 100644
--- a/e2e/common/traits/builder_test.go
+++ b/e2e/common/traits/builder_test.go
@@ -185,17 +185,17 @@ func TestBuilderTrait(t *testing.T) {
// Check containers conditions
g.Eventually(Build(t, ctx, integrationKitNamespace, integrationKitName), TestTimeoutShort).ShouldNot(BeNil())
g.Eventually(
- Build(t, ctx, integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom1 succeeded")).Status,
+ Build(t, ctx, integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Containercustom1Succeeded")).Status,
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
g.Eventually(
- Build(t, ctx, integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom1 succeeded")).Message,
+ Build(t, ctx, integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Containercustom1Succeeded")).Message,
TestTimeoutShort).Should(ContainSubstring("generated-bytecode.jar"))
g.Eventually(Build(t, ctx, integrationKitNamespace, integrationKitName), TestTimeoutShort).ShouldNot(BeNil())
g.Eventually(
- Build(t, ctx, integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom2 succeeded")).Status,
+ Build(t, ctx, integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Containercustom2Succeeded")).Status,
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
g.Eventually(
- Build(t, ctx, integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom2 succeeded")).Message,
+ Build(t, ctx, integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Containercustom2Succeeded")).Message,
TestTimeoutShort).Should(ContainSubstring("</project>"))
// Check logs
@@ -215,12 +215,12 @@ func TestBuilderTrait(t *testing.T) {
// Check containers conditions
g.Eventually(Build(t, ctx, integrationKitNamespace, integrationKitName), TestTimeoutLong).ShouldNot(BeNil())
g.Eventually(BuildConditions(t, ctx, integrationKitNamespace, integrationKitName), TestTimeoutLong).ShouldNot(BeNil())
- g.Eventually(BuildCondition(t, ctx, integrationKitNamespace, integrationKitName, v1.BuildConditionType("Container custom1 succeeded")), TestTimeoutMedium).ShouldNot(BeNil())
+ g.Eventually(BuildCondition(t, ctx, integrationKitNamespace, integrationKitName, v1.BuildConditionType("Containercustom1Succeeded")), TestTimeoutMedium).ShouldNot(BeNil())
g.Eventually(
- BuildCondition(t, ctx, integrationKitNamespace, integrationKitName, v1.BuildConditionType("Container custom1 succeeded"))().Status,
+ BuildCondition(t, ctx, integrationKitNamespace, integrationKitName, v1.BuildConditionType("Containercustom1Succeeded"))().Status,
TestTimeoutShort).Should(Equal(corev1.ConditionFalse))
g.Eventually(
- BuildCondition(t, ctx, integrationKitNamespace, integrationKitName, v1.BuildConditionType("Container custom1 succeeded"))().Message,
+ BuildCondition(t, ctx, integrationKitNamespace, integrationKitName, v1.BuildConditionType("Containercustom1Succeeded"))().Message,
TestTimeoutShort).Should(ContainSubstring("No such file or directory"))
g.Expect(Kamel(t, ctx, "delete", "--all", "-n", ns).Execute()).To(Succeed())
@@ -252,10 +252,10 @@ func TestBuilderTrait(t *testing.T) {
// Check containers conditions
g.Eventually(Build(t, ctx, integrationKitNamespace, integrationKitName), TestTimeoutShort).ShouldNot(BeNil())
g.Eventually(
- Build(t, ctx, integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom1 succeeded")).Status,
+ Build(t, ctx, integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Containercustom1Succeeded")).Status,
TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
g.Eventually(
- Build(t, ctx, integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Container custom1 succeeded")).Message,
+ Build(t, ctx, integrationKitNamespace, integrationKitName)().Status.GetCondition(v1.BuildConditionType("Containercustom1Succeeded")).Message,
TestTimeoutShort).Should(ContainSubstring("</project>"))
// Check logs
diff --git a/pkg/controller/build/monitor_pod.go b/pkg/controller/build/monitor_pod.go
index 506fe105b..e58a85038 100644
--- a/pkg/controller/build/monitor_pod.go
+++ b/pkg/controller/build/monitor_pod.go
@@ -308,7 +308,7 @@ func (action *monitorPodAction) setConditionsFromTerminationMessages(ctx context
var err error
terminationMessage := t.Message
// Dynamic condition type (it depends on each container name)
- containerConditionType := v1.BuildConditionType(fmt.Sprintf("Container %s succeeded", container.Name))
+ containerConditionType := v1.BuildConditionType(fmt.Sprintf("Container%sSucceeded", container.Name))
containerSucceeded := corev1.ConditionTrue
if t.ExitCode != 0 {
containerSucceeded = corev1.ConditionFalse
diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go
index d60d4ca8a..48ad9dab0 100644
--- a/pkg/trait/builder.go
+++ b/pkg/trait/builder.go
@@ -165,7 +165,7 @@ func (t *builderTrait) adaptDeprecatedFields() *TraitCondition {
m := "The limit-memory parameter is deprecated and may be removed in future releases. Make sure to use tasks-limit-memory parameter instead."
t.L.Info(m)
if condition == nil {
- condition = NewIntegrationCondition(v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationReason, "")
+ condition = NewIntegrationCondition("Builder", v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationReason, "")
}
condition = newOrAppend(condition, m)
t.TasksLimitMemory = append(t.TasksLimitMemory, fmt.Sprintf("builder:%s", t.LimitMemory))
@@ -176,7 +176,7 @@ func (t *builderTrait) adaptDeprecatedFields() *TraitCondition {
func newOrAppend(condition *TraitCondition, message string) *TraitCondition {
if condition == nil {
- condition = NewIntegrationCondition(v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationReason, message)
+ condition = NewIntegrationCondition("Builder", v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationReason, message)
} else {
condition.message += "; " + message
}
diff --git a/pkg/trait/container.go b/pkg/trait/container.go
index e4384f25a..b58842df1 100644
--- a/pkg/trait/container.go
+++ b/pkg/trait/container.go
@@ -88,6 +88,7 @@ func (t *containerTrait) Configure(e *Environment) (bool, *TraitCondition, error
t.L.ForIntegration(e.Integration).Infof("Integration %s/%s contains knative endpoint that cannot run, as knative is not installed in the cluster.", e.Integration.Namespace, e.Integration.Name)
err := errors.New("integration cannot run, as knative is not installed in the cluster")
return false, NewIntegrationCondition(
+ "Container",
v1.IntegrationConditionKnativeAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionKnativeNotInstalledReason,
diff --git a/pkg/trait/container_probes_test.go b/pkg/trait/container_probes_test.go
index d756af65d..87a070f94 100644
--- a/pkg/trait/container_probes_test.go
+++ b/pkg/trait/container_probes_test.go
@@ -185,15 +185,17 @@ func TestProbesOnKnativeService(t *testing.T) {
env.Integration.Status.Phase = v1.IntegrationPhaseDeploying
serviceOverrideCondition := NewIntegrationCondition(
+ "Service",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
- "serviceTraitConfiguration",
+ "TraitConfiguration",
"explicitly disabled by the platform: knative-service trait has priority over this trait",
)
ctrlStrategyCondition := NewIntegrationCondition(
+ "Deployment",
v1.IntegrationConditionDeploymentAvailable,
corev1.ConditionFalse,
- "deploymentTraitConfiguration",
+ "DeploymentAvailable",
"controller strategy: knative-service",
)
diff --git a/pkg/trait/container_test.go b/pkg/trait/container_test.go
index 551503e92..6d039cda8 100644
--- a/pkg/trait/container_test.go
+++ b/pkg/trait/container_test.go
@@ -450,6 +450,7 @@ func TestRunKnativeEndpointWithKnativeNotInstalled(t *testing.T) {
},
}
expectedCondition := NewIntegrationCondition(
+ "Container",
v1.IntegrationConditionKnativeAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionKnativeNotInstalledReason,
diff --git a/pkg/trait/cron.go b/pkg/trait/cron.go
index 0a7a69cb0..adf04f0c3 100644
--- a/pkg/trait/cron.go
+++ b/pkg/trait/cron.go
@@ -78,7 +78,7 @@ func (t *cronTrait) Configure(e *Environment) (bool, *TraitCondition, error) {
return false, nil, nil
}
if !pointer.BoolDeref(t.Enabled, true) {
- return false, NewIntegrationConditionUserDisabled(), nil
+ return false, NewIntegrationConditionUserDisabled("Cron"), nil
}
if !e.IntegrationInPhase(v1.IntegrationPhaseInitialization) && !e.IntegrationInRunningPhases() {
return false, nil, nil
@@ -86,6 +86,7 @@ func (t *cronTrait) Configure(e *Environment) (bool, *TraitCondition, error) {
if _, ok := e.CamelCatalog.Runtime.Capabilities[v1.CapabilityCron]; !ok {
return false, NewIntegrationCondition(
+ "Cron",
v1.IntegrationConditionCronJobAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionCronJobNotAvailableReason,
@@ -97,6 +98,7 @@ func (t *cronTrait) Configure(e *Environment) (bool, *TraitCondition, error) {
globalCron, err := t.getGlobalCron(e)
if err != nil {
return false, NewIntegrationCondition(
+ "Cron",
v1.IntegrationConditionCronJobAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionCronJobNotAvailableReason,
@@ -140,6 +142,7 @@ func (t *cronTrait) Configure(e *Environment) (bool, *TraitCondition, error) {
var condition *TraitCondition
if e.IntegrationInPhase(v1.IntegrationPhaseDeploying) {
condition = NewIntegrationCondition(
+ "Cron",
v1.IntegrationConditionCronJobAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionCronJobNotAvailableReason,
@@ -153,6 +156,7 @@ func (t *cronTrait) Configure(e *Environment) (bool, *TraitCondition, error) {
strategy, err := e.DetermineControllerStrategy()
if err != nil {
return false, NewIntegrationCondition(
+ "Cron",
v1.IntegrationConditionCronJobAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionCronJobNotAvailableReason,
diff --git a/pkg/trait/cron_test.go b/pkg/trait/cron_test.go
index 4e446600b..1f1084469 100644
--- a/pkg/trait/cron_test.go
+++ b/pkg/trait/cron_test.go
@@ -522,9 +522,10 @@ func TestCronWithActiveDeadline(t *testing.T) {
tc := NewCatalog(c)
expectedCondition := NewIntegrationCondition(
+ "Deployment",
v1.IntegrationConditionDeploymentAvailable,
corev1.ConditionFalse,
- "deploymentTraitConfiguration",
+ "DeploymentAvailable",
"controller strategy: cron-job",
)
conditions, err := tc.apply(&environment)
@@ -610,9 +611,10 @@ func TestCronWithBackoffLimit(t *testing.T) {
tc := NewCatalog(c)
expectedCondition := NewIntegrationCondition(
+ "Deployment",
v1.IntegrationConditionDeploymentAvailable,
corev1.ConditionFalse,
- "deploymentTraitConfiguration",
+ "DeploymentAvailable",
"controller strategy: cron-job",
)
conditions, err := tc.apply(&environment)
diff --git a/pkg/trait/deployment.go b/pkg/trait/deployment.go
index 84ab52eac..600a843f0 100644
--- a/pkg/trait/deployment.go
+++ b/pkg/trait/deployment.go
@@ -57,6 +57,7 @@ func (t *deploymentTrait) Configure(e *Environment) (bool, *TraitCondition, erro
strategy, err := e.DetermineControllerStrategy()
if err != nil {
return false, NewIntegrationCondition(
+ "Deployment",
v1.IntegrationConditionDeploymentAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionDeploymentAvailableReason,
@@ -66,6 +67,7 @@ func (t *deploymentTrait) Configure(e *Environment) (bool, *TraitCondition, erro
if strategy != ControllerStrategyDeployment {
return false, NewIntegrationCondition(
+ "Deployment",
v1.IntegrationConditionDeploymentAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionDeploymentAvailableReason,
diff --git a/pkg/trait/gc.go b/pkg/trait/gc.go
index ef309c9eb..5598c1c70 100644
--- a/pkg/trait/gc.go
+++ b/pkg/trait/gc.go
@@ -66,7 +66,7 @@ func (t *gcTrait) Configure(e *Environment) (bool, *TraitCondition, error) {
return false, nil, nil
}
if !pointer.BoolDeref(t.Enabled, true) {
- return false, NewIntegrationConditionUserDisabled(), nil
+ return false, NewIntegrationConditionUserDisabled("GC"), nil
}
return e.IntegrationInPhase(v1.IntegrationPhaseInitialization) || e.IntegrationInRunningPhases(), nil, nil
diff --git a/pkg/trait/gc_test.go b/pkg/trait/gc_test.go
index 6908df715..406b00e45 100644
--- a/pkg/trait/gc_test.go
+++ b/pkg/trait/gc_test.go
@@ -44,6 +44,7 @@ func TestConfigureDisabledGCTraitDoesNotSucceed(t *testing.T) {
gcTrait.Enabled = pointer.Bool(false)
expectedCondition := NewIntegrationCondition(
+ "GC",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
"TraitConfiguration",
diff --git a/pkg/trait/ingress.go b/pkg/trait/ingress.go
index f240f10d9..a9742cfbc 100644
--- a/pkg/trait/ingress.go
+++ b/pkg/trait/ingress.go
@@ -61,6 +61,7 @@ func (t *ingressTrait) Configure(e *Environment) (bool, *TraitCondition, error)
}
if !pointer.BoolDeref(t.Enabled, true) {
return false, NewIntegrationCondition(
+ "Ingress",
v1.IntegrationConditionExposureAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionIngressNotAvailableReason,
diff --git a/pkg/trait/ingress_test.go b/pkg/trait/ingress_test.go
index df71b2d68..29e9ddc94 100644
--- a/pkg/trait/ingress_test.go
+++ b/pkg/trait/ingress_test.go
@@ -50,6 +50,7 @@ func TestConfigureDisabledIngressTraitDoesNotSucceed(t *testing.T) {
ingressTrait.Enabled = pointer.Bool(false)
expectedCondition := NewIntegrationCondition(
+ "Ingress",
v1.IntegrationConditionExposureAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionIngressNotAvailableReason,
diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go
index ab11617ff..c9e3b3264 100644
--- a/pkg/trait/jvm.go
+++ b/pkg/trait/jvm.go
@@ -57,7 +57,7 @@ func newJvmTrait() Trait {
func (t *jvmTrait) Configure(e *Environment) (bool, *TraitCondition, error) {
if !pointer.BoolDeref(t.Enabled, true) {
- return false, NewIntegrationConditionUserDisabled(), nil
+ return false, NewIntegrationConditionUserDisabled("JVM"), nil
}
if !e.IntegrationKitInPhase(v1.IntegrationKitPhaseReady) || !e.IntegrationInRunningPhases() {
return false, nil, nil
@@ -66,15 +66,15 @@ func (t *jvmTrait) Configure(e *Environment) (bool, *TraitCondition, error) {
// The JVM trait must be disabled in case the current IntegrationKit corresponds to a native build
if qt := e.Catalog.GetTrait(quarkusTraitID); qt != nil {
if quarkus, ok := qt.(*quarkusTrait); ok && quarkus.isNativeIntegration(e) {
- return false, newIntegrationConditionPlatformDisabledWithMessage("quarkus native build"), nil
+ return false, newIntegrationConditionPlatformDisabledWithMessage("JVM", "quarkus native build"), nil
}
}
if e.IntegrationKit != nil && e.IntegrationKit.IsExternal() {
if pointer.BoolDeref(t.Enabled, false) {
- return true, NewIntegrationConditionUserEnabledWithMessage("integration kit was not created via Camel K operator"), nil
+ return true, NewIntegrationConditionUserEnabledWithMessage("JVM", "integration kit was not created via Camel K operator"), nil
} else {
- return false, newIntegrationConditionPlatformDisabledWithMessage("integration kit was not created via Camel K operator"), nil
+ return false, newIntegrationConditionPlatformDisabledWithMessage("JVM", "integration kit was not created via Camel K operator"), nil
}
}
diff --git a/pkg/trait/jvm_test.go b/pkg/trait/jvm_test.go
index f48d890db..b3f33f65d 100644
--- a/pkg/trait/jvm_test.go
+++ b/pkg/trait/jvm_test.go
@@ -81,6 +81,7 @@ func TestConfigureJvmTraitInWrongJvmDisabled(t *testing.T) {
trait.Enabled = pointer.Bool(false)
expectedCondition := NewIntegrationCondition(
+ "JVM",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
"TraitConfiguration",
@@ -97,6 +98,7 @@ func TestConfigureJvmTraitInWrongIntegrationKitPhaseExternal(t *testing.T) {
trait, environment := createNominalJvmTest(v1.IntegrationKitTypeExternal)
expectedCondition := NewIntegrationCondition(
+ "JVM",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
"TraitConfiguration",
@@ -114,6 +116,7 @@ func TestConfigureJvmTraitInRightIntegrationKitPhaseExternalAndJvmEnabled(t *tes
trait.Enabled = pointer.Bool(true)
expectedCondition := NewIntegrationCondition(
+ "JVM",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
"TraitConfiguration",
diff --git a/pkg/trait/kamelets.go b/pkg/trait/kamelets.go
index 607d41a05..280501848 100644
--- a/pkg/trait/kamelets.go
+++ b/pkg/trait/kamelets.go
@@ -77,7 +77,7 @@ func (t *kameletsTrait) Configure(e *Environment) (bool, *TraitCondition, error)
return false, nil, nil
}
if !pointer.BoolDeref(t.Enabled, true) {
- return false, NewIntegrationConditionUserDisabled(), nil
+ return false, NewIntegrationConditionUserDisabled("Kamelets"), nil
}
if !e.IntegrationInPhase(v1.IntegrationPhaseInitialization) && !e.IntegrationInRunningPhases() {
return false, nil, nil
diff --git a/pkg/trait/knative.go b/pkg/trait/knative.go
index 5de71160c..312a1af4b 100644
--- a/pkg/trait/knative.go
+++ b/pkg/trait/knative.go
@@ -71,7 +71,7 @@ func (t *knativeTrait) Configure(e *Environment) (bool, *TraitCondition, error)
return false, nil, nil
}
if !pointer.BoolDeref(t.Enabled, true) {
- return false, NewIntegrationConditionUserDisabled(), nil
+ return false, NewIntegrationConditionUserDisabled("Knative"), nil
}
if !e.IntegrationInPhase(v1.IntegrationPhaseInitialization) && !e.IntegrationInRunningPhases() {
return false, nil, nil
diff --git a/pkg/trait/knative_service.go b/pkg/trait/knative_service.go
index 7d667881a..e8baaf7d6 100644
--- a/pkg/trait/knative_service.go
+++ b/pkg/trait/knative_service.go
@@ -75,6 +75,7 @@ func (t *knativeServiceTrait) Configure(e *Environment) (bool, *TraitCondition,
}
if !pointer.BoolDeref(t.Enabled, true) {
return false, NewIntegrationCondition(
+ "KnativeService",
v1.IntegrationConditionKnativeServiceAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionKnativeServiceNotAvailableReason,
@@ -89,6 +90,7 @@ func (t *knativeServiceTrait) Configure(e *Environment) (bool, *TraitCondition,
if e.Resources.GetDeploymentForIntegration(e.Integration) != nil {
// A controller is already present for the integration
return false, NewIntegrationCondition(
+ "KnativeService",
v1.IntegrationConditionKnativeServiceAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionKnativeServiceNotAvailableReason,
@@ -99,6 +101,7 @@ func (t *knativeServiceTrait) Configure(e *Environment) (bool, *TraitCondition,
strategy, err := e.DetermineControllerStrategy()
if err != nil {
return false, NewIntegrationCondition(
+ "KnativeService",
v1.IntegrationConditionKnativeServiceAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionKnativeServiceNotAvailableReason,
@@ -107,6 +110,7 @@ func (t *knativeServiceTrait) Configure(e *Environment) (bool, *TraitCondition,
}
if strategy != ControllerStrategyKnativeService {
return false, NewIntegrationCondition(
+ "KnativeService",
v1.IntegrationConditionKnativeServiceAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionKnativeServiceNotAvailableReason,
diff --git a/pkg/trait/logging.go b/pkg/trait/logging.go
index dafd331a7..97b028b85 100644
--- a/pkg/trait/logging.go
+++ b/pkg/trait/logging.go
@@ -54,7 +54,7 @@ func (l loggingTrait) Configure(e *Environment) (bool, *TraitCondition, error) {
}
if !pointer.BoolDeref(l.Enabled, true) {
- return false, NewIntegrationConditionUserDisabled(), nil
+ return false, NewIntegrationConditionUserDisabled("Logging"), nil
}
return e.IntegrationInRunningPhases(), nil, nil
diff --git a/pkg/trait/mount.go b/pkg/trait/mount.go
index e48e15353..76cd01d0e 100644
--- a/pkg/trait/mount.go
+++ b/pkg/trait/mount.go
@@ -190,6 +190,7 @@ func (t *mountTrait) addImplicitKameletsSecrets(e *Environment) *TraitCondition
kamelets, ok := trait.(*kameletsTrait)
if !ok {
return NewIntegrationCondition(
+ "Mount",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
traitConfigurationReason,
@@ -202,6 +203,7 @@ func (t *mountTrait) addImplicitKameletsSecrets(e *Environment) *TraitCondition
implicitKameletSecrets, err := kamelets.listConfigurationSecrets(e)
if err != nil {
return NewIntegrationCondition(
+ "Mount",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
traitConfigurationReason,
@@ -216,6 +218,7 @@ func (t *mountTrait) addImplicitKameletsSecrets(e *Environment) *TraitCondition
if featureUsed {
return NewIntegrationCondition(
+ "Mount",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
traitConfigurationReason,
diff --git a/pkg/trait/owner.go b/pkg/trait/owner.go
index 20bab1952..3b5c8f428 100644
--- a/pkg/trait/owner.go
+++ b/pkg/trait/owner.go
@@ -44,7 +44,7 @@ func (t *ownerTrait) Configure(e *Environment) (bool, *TraitCondition, error) {
return false, nil, nil
}
if !pointer.BoolDeref(t.Enabled, true) {
- return false, NewIntegrationConditionUserDisabled(), nil
+ return false, NewIntegrationConditionUserDisabled("Owner"), nil
}
return e.IntegrationInPhase(v1.IntegrationPhaseInitialization) || e.IntegrationInRunningPhases(), nil, nil
diff --git a/pkg/trait/pod.go b/pkg/trait/pod.go
index 5233bd513..12fc35df6 100644
--- a/pkg/trait/pod.go
+++ b/pkg/trait/pod.go
@@ -49,7 +49,7 @@ func (t *podTrait) Configure(e *Environment) (bool, *TraitCondition, error) {
return false, nil, nil
}
if !pointer.BoolDeref(t.Enabled, true) {
- return false, NewIntegrationConditionUserDisabled(), nil
+ return false, NewIntegrationConditionUserDisabled("Pod"), nil
}
if e.Integration.Spec.PodTemplate == nil {
return false, nil, nil
diff --git a/pkg/trait/pull_secret.go b/pkg/trait/pull_secret.go
index 829a7920f..c2fb33a67 100644
--- a/pkg/trait/pull_secret.go
+++ b/pkg/trait/pull_secret.go
@@ -49,7 +49,7 @@ func (t *pullSecretTrait) Configure(e *Environment) (bool, *TraitCondition, erro
return false, nil, nil
}
if !pointer.BoolDeref(t.Enabled, true) {
- return false, NewIntegrationConditionUserDisabled(), nil
+ return false, NewIntegrationConditionUserDisabled("PullSecret"), nil
}
if !e.IntegrationInRunningPhases() {
return false, nil, nil
diff --git a/pkg/trait/quarkus.go b/pkg/trait/quarkus.go
index 6b75d4b97..1140029be 100644
--- a/pkg/trait/quarkus.go
+++ b/pkg/trait/quarkus.go
@@ -161,7 +161,7 @@ func (t *quarkusTrait) adaptDeprecatedFields() *TraitCondition {
t.Modes = append(t.Modes, traitv1.JvmQuarkusMode)
}
}
- return NewIntegrationCondition(v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationReason, message)
+ return NewIntegrationCondition("Quarkus", v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationReason, message)
}
return nil
diff --git a/pkg/trait/registry.go b/pkg/trait/registry.go
index 906e6f7fa..29c9c3497 100644
--- a/pkg/trait/registry.go
+++ b/pkg/trait/registry.go
@@ -62,6 +62,7 @@ func (t *registryTrait) Configure(e *Environment) (bool, *TraitCondition, error)
enabled := e.IntegrationKitInPhase(v1.IntegrationKitPhaseBuildSubmitted)
if enabled {
condition := NewIntegrationCondition(
+ "Registry",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
traitConfigurationReason,
diff --git a/pkg/trait/route.go b/pkg/trait/route.go
index 101f5c326..6816352e7 100644
--- a/pkg/trait/route.go
+++ b/pkg/trait/route.go
@@ -60,6 +60,7 @@ func (t *routeTrait) Configure(e *Environment) (bool, *TraitCondition, error) {
}
if !pointer.BoolDeref(t.Enabled, true) {
return false, NewIntegrationCondition(
+ "Route",
v1.IntegrationConditionExposureAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionRouteNotAvailableReason,
diff --git a/pkg/trait/route_test.go b/pkg/trait/route_test.go
index 00c9527db..0c1bd2238 100644
--- a/pkg/trait/route_test.go
+++ b/pkg/trait/route_test.go
@@ -235,9 +235,10 @@ func TestRoute_Disabled(t *testing.T) {
}
expectedCondition := NewIntegrationCondition(
+ "Route",
v1.IntegrationConditionExposureAvailable,
corev1.ConditionFalse,
- "routeTraitConfiguration",
+ "RouteNotAvailable",
"explicitly disabled",
)
traitsCatalog := environment.Catalog
diff --git a/pkg/trait/service.go b/pkg/trait/service.go
index 1bcb499e5..b2e081ab2 100644
--- a/pkg/trait/service.go
+++ b/pkg/trait/service.go
@@ -49,6 +49,7 @@ func (t *serviceTrait) Configure(e *Environment) (bool, *TraitCondition, error)
}
if !pointer.BoolDeref(t.Enabled, true) {
return false, NewIntegrationCondition(
+ "Service",
v1.IntegrationConditionServiceAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionServiceNotAvailableReason,
@@ -61,7 +62,7 @@ func (t *serviceTrait) Configure(e *Environment) (bool, *TraitCondition, error)
if e.GetTrait(knativeServiceTraitID) != nil {
knativeServiceTrait, _ := e.GetTrait(knativeServiceTraitID).(*knativeServiceTrait)
if pointer.BoolDeref(knativeServiceTrait.Enabled, true) {
- return false, newIntegrationConditionPlatformDisabledWithMessage("knative-service trait has priority over this trait"), nil
+ return false, newIntegrationConditionPlatformDisabledWithMessage("Service", "knative-service trait has priority over this trait"), nil
}
}
@@ -74,6 +75,7 @@ func (t *serviceTrait) Configure(e *Environment) (bool, *TraitCondition, error)
var condition *TraitCondition
if err != nil {
condition = NewIntegrationCondition(
+ "Service",
v1.IntegrationConditionServiceAvailable,
corev1.ConditionFalse,
v1.IntegrationConditionServiceNotAvailableReason,
diff --git a/pkg/trait/service_binding.go b/pkg/trait/service_binding.go
index 2bb1758ee..5921499af 100644
--- a/pkg/trait/service_binding.go
+++ b/pkg/trait/service_binding.go
@@ -68,7 +68,7 @@ func (t *serviceBindingTrait) Configure(e *Environment) (bool, *TraitCondition,
return false, nil, nil
}
if !pointer.BoolDeref(t.Enabled, true) {
- return false, NewIntegrationConditionUserDisabled(), nil
+ return false, NewIntegrationConditionUserDisabled("ServiceBinding"), nil
}
if len(t.Services) == 0 {
return false, nil, nil
diff --git a/pkg/trait/service_test.go b/pkg/trait/service_test.go
index edbd412eb..1769110f9 100644
--- a/pkg/trait/service_test.go
+++ b/pkg/trait/service_test.go
@@ -489,15 +489,17 @@ func TestServiceWithKnativeServiceEnabled(t *testing.T) {
environment.Platform.ResyncStatusFullConfig()
deploymentCondition := NewIntegrationCondition(
+ "Deployment",
v1.IntegrationConditionDeploymentAvailable,
corev1.ConditionFalse,
- "deploymentTraitConfiguration",
+ "DeploymentAvailable",
"controller strategy: knative-service",
)
serviceCondition := NewIntegrationCondition(
+ "Service",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
- "serviceTraitConfiguration",
+ "TraitConfiguration",
"explicitly disabled by the platform: knative-service trait has priority over this trait",
)
conditions, err := traitCatalog.apply(&environment)
@@ -566,15 +568,17 @@ func TestServicesWithKnativeProfile(t *testing.T) {
environment.Platform.ResyncStatusFullConfig()
deploymentCondition := NewIntegrationCondition(
+ "Deployment",
v1.IntegrationConditionDeploymentAvailable,
corev1.ConditionFalse,
- "deploymentTraitConfiguration",
+ "DeploymentAvailable",
"controller strategy: knative-service",
)
serviceCondition := NewIntegrationCondition(
+ "Service",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
- "serviceTraitConfiguration",
+ "TraitConfiguration",
"explicitly disabled by the platform: knative-service trait has priority over this trait",
)
conditions, err := traitCatalog.apply(&environment)
@@ -651,9 +655,10 @@ func TestServiceWithKnativeServiceDisabledInIntegrationPlatform(t *testing.T) {
environment.Platform.ResyncStatusFullConfig()
expectedCondition := NewIntegrationCondition(
+ "KnativeService",
v1.IntegrationConditionKnativeServiceAvailable,
corev1.ConditionFalse,
- "knative-serviceTraitConfiguration",
+ "KnativeServiceNotAvailable",
"explicitly disabled",
)
conditions, err := traitCatalog.apply(&environment)
diff --git a/pkg/trait/trait_catalog.go b/pkg/trait/trait_catalog.go
index 8bbcf4bd3..867c75814 100644
--- a/pkg/trait/trait_catalog.go
+++ b/pkg/trait/trait_catalog.go
@@ -104,7 +104,6 @@ func (c *Catalog) apply(environment *Environment) ([]*TraitCondition, error) {
applicable = true
enabled, condition, err := trait.Configure(environment)
if condition != nil {
- condition.reason = fmt.Sprintf("%sTraitConfiguration", trait.ID())
traitsConditions = append(traitsConditions, condition)
}
if err != nil {
@@ -150,7 +149,7 @@ func (c *Catalog) executedTraitCondition(executedTrait []Trait) *TraitCondition
message := fmt.Sprintf("Applied traits: %s", strings.Join(traitIds, ","))
c.L.Debugf(message)
- return NewIntegrationCondition(v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationReason, message)
+ return NewIntegrationCondition("", v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationReason, message)
}
// GetTrait returns the trait with the given ID.
diff --git a/pkg/trait/trait_condition_types.go b/pkg/trait/trait_condition_types.go
index 05f9ac4a4..2f245ea8e 100644
--- a/pkg/trait/trait_condition_types.go
+++ b/pkg/trait/trait_condition_types.go
@@ -35,6 +35,7 @@ const (
// TraitCondition is used to get all information/warning about a trait configuration.
// It should either use an IntegrationConditionType or IntegrationKitConditionType.
type TraitCondition struct {
+ traitID string
integrationConditionType v1.IntegrationConditionType
integrationKitConditionType v1.IntegrationKitConditionType
conditionStatus corev1.ConditionStatus
@@ -42,8 +43,9 @@ type TraitCondition struct {
reason string
}
-func NewIntegrationCondition(ict v1.IntegrationConditionType, cs corev1.ConditionStatus, reason, message string) *TraitCondition {
+func NewIntegrationCondition(traitID string, ict v1.IntegrationConditionType, cs corev1.ConditionStatus, reason, message string) *TraitCondition {
return &TraitCondition{
+ traitID: traitID,
integrationConditionType: ict,
conditionStatus: cs,
reason: reason,
@@ -51,22 +53,28 @@ func NewIntegrationCondition(ict v1.IntegrationConditionType, cs corev1.Conditio
}
}
-func NewIntegrationConditionUserDisabled() *TraitCondition {
- return NewIntegrationCondition(v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationReason, userDisabledMessage)
+func NewIntegrationConditionUserDisabled(traitID string) *TraitCondition {
+ return NewIntegrationCondition(traitID, v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationReason, userDisabledMessage)
}
-func NewIntegrationConditionUserEnabledWithMessage(message string) *TraitCondition {
- return NewIntegrationCondition(v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationReason, fmt.Sprintf("%s: %s", userEnabledMessage, message))
+func NewIntegrationConditionUserEnabledWithMessage(traitID string, message string) *TraitCondition {
+ return NewIntegrationCondition(traitID, v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationReason, fmt.Sprintf("%s: %s", userEnabledMessage, message))
}
-func newIntegrationConditionPlatformDisabledWithMessage(message string) *TraitCondition {
- return NewIntegrationCondition(v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationReason, fmt.Sprintf("%s: %s", platformDisabledMessage, message))
+func newIntegrationConditionPlatformDisabledWithMessage(traitID string, message string) *TraitCondition {
+ return NewIntegrationCondition(traitID, v1.IntegrationConditionTraitInfo, corev1.ConditionTrue, traitConfigurationReason, fmt.Sprintf("%s: %s", platformDisabledMessage, message))
}
func (tc *TraitCondition) integrationCondition() (v1.IntegrationConditionType, corev1.ConditionStatus, string, string) {
- return tc.integrationConditionType, tc.conditionStatus, tc.reason, tc.message
+ return v1.IntegrationConditionType(fmt.Sprintf("%s%s", tc.traitID, tc.integrationConditionType)),
+ tc.conditionStatus,
+ tc.reason,
+ tc.message
}
func (tc *TraitCondition) integrationKitCondition() (v1.IntegrationKitConditionType, corev1.ConditionStatus, string, string) {
- return tc.integrationKitConditionType, tc.conditionStatus, tc.reason, tc.message
+ return v1.IntegrationKitConditionType(fmt.Sprintf("%s%s", tc.traitID, tc.integrationKitConditionType)),
+ tc.conditionStatus,
+ tc.reason,
+ tc.message
}
diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go
index ce750a199..db1dc7cf8 100644
--- a/pkg/trait/trait_test.go
+++ b/pkg/trait/trait_test.go
@@ -557,6 +557,7 @@ func TestExecutedTraitsCondition(t *testing.T) {
require.NoError(t, err)
expectedCondition := NewIntegrationCondition(
+ "",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
"TraitConfiguration",