You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2020/06/03 08:52:51 UTC

[camel-k] branch master updated (f13873c -> 726d849)

This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git.


    from f13873c  chore(client): generate client interface for catalog
     new 7742ef8  fix(prometheus): Assume service exposition is enabled when a service already exists
     new 56569d9  fix(prometheus): Do not name Prometheus container port
     new d557e19  fix(prometheus): Do not use same name for Prometheus service than Knative service
     new 38e1d2a  fix(prometheus): Do not declare Prometheus container port when Knative is enabled
     new 726d849  fix: Remove Prometheus container port name from condition message

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pkg/trait/prometheus.go      | 31 +++++++++++++++++++++----------
 pkg/trait/prometheus_test.go |  9 ++++-----
 2 files changed, 25 insertions(+), 15 deletions(-)


[camel-k] 01/05: fix(prometheus): Assume service exposition is enabled when a service already exists

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 7742ef8b6a8dd8f057da55f7b8542fccc6ffc8cf
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Fri May 29 17:43:14 2020 +0200

    fix(prometheus): Assume service exposition is enabled when a service already exists
---
 pkg/trait/prometheus.go      | 2 ++
 pkg/trait/prometheus_test.go | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/pkg/trait/prometheus.go b/pkg/trait/prometheus.go
index e4b0e34..94bb988 100644
--- a/pkg/trait/prometheus.go
+++ b/pkg/trait/prometheus.go
@@ -139,6 +139,8 @@ func (t *prometheusTrait) Apply(e *Environment) (err error) {
 			service = getServiceFor(e)
 			e.Resources.Add(service)
 		}
+	} else {
+		serviceEnabled = true
 	}
 
 	// Add the service port and service monitor resource
diff --git a/pkg/trait/prometheus_test.go b/pkg/trait/prometheus_test.go
index 579b159..53a8179 100644
--- a/pkg/trait/prometheus_test.go
+++ b/pkg/trait/prometheus_test.go
@@ -103,7 +103,7 @@ func TestApplyPrometheusTraitWithoutContainerDoesNotSucceed(t *testing.T) {
 	assert.Equal(t, corev1.ConditionFalse, condition.Status)
 }
 
-func TestApplyPrometheusTraitWithServiceDoesNotSucceed(t *testing.T) {
+func TestApplyPrometheusTraitWithServiceDoesSucceed(t *testing.T) {
 	trait, environment := createNominalPrometheusTest()
 	environment.Resources = kubernetes.NewCollection(
 		&appsv1.Deployment{
@@ -146,8 +146,8 @@ func TestApplyPrometheusTraitWithServiceDoesNotSucceed(t *testing.T) {
 
 	assert.Len(t, environment.Integration.Status.Conditions, 1)
 	condition := environment.Integration.Status.Conditions[0]
-	assert.Equal(t, v1.IntegrationConditionServiceNotAvailableReason, condition.Reason)
-	assert.Equal(t, corev1.ConditionFalse, condition.Status)
+	assert.Equal(t, v1.IntegrationConditionPrometheusAvailableReason, condition.Reason)
+	assert.Equal(t, corev1.ConditionTrue, condition.Status)
 }
 
 func TestPrometheusTraitGetServiceMonitor(t *testing.T) {


[camel-k] 02/05: fix(prometheus): Do not name Prometheus container port

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 56569d91ef1112bfaa0ae7cd58ec4861f63d1a35
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Fri May 29 17:47:12 2020 +0200

    fix(prometheus): Do not name Prometheus container port
    
    Knative enforces specific values used for content negotiation.
    The Prometheus port is not to be exposed anyway when Knative profile
    is enabled, as Knative also enforces a single container port.
---
 pkg/trait/prometheus.go      | 10 +++++-----
 pkg/trait/prometheus_test.go |  1 -
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/pkg/trait/prometheus.go b/pkg/trait/prometheus.go
index 94bb988..8a6dd8f 100644
--- a/pkg/trait/prometheus.go
+++ b/pkg/trait/prometheus.go
@@ -170,7 +170,6 @@ func (t *prometheusTrait) Apply(e *Environment) (err error) {
 
 func (t *prometheusTrait) getContainerPort() *corev1.ContainerPort {
 	containerPort := corev1.ContainerPort{
-		Name:          prometheusPortName,
 		ContainerPort: int32(t.Port),
 		Protocol:      corev1.ProtocolTCP,
 	}
@@ -179,10 +178,11 @@ func (t *prometheusTrait) getContainerPort() *corev1.ContainerPort {
 
 func (t *prometheusTrait) getServicePort() *corev1.ServicePort {
 	servicePort := corev1.ServicePort{
-		Name:       prometheusPortName,
-		Port:       int32(t.Port),
-		Protocol:   corev1.ProtocolTCP,
-		TargetPort: intstr.FromString(prometheusPortName),
+		Name:     prometheusPortName,
+		Port:     int32(t.Port),
+		Protocol: corev1.ProtocolTCP,
+		// Avoid relying on named port, as Knative enforces specific values used for content negotiation
+		TargetPort: intstr.FromInt(t.Port),
 	}
 	return &servicePort
 }
diff --git a/pkg/trait/prometheus_test.go b/pkg/trait/prometheus_test.go
index 53a8179..30a676f 100644
--- a/pkg/trait/prometheus_test.go
+++ b/pkg/trait/prometheus_test.go
@@ -68,7 +68,6 @@ func TestApplyNominalPrometheusTraitDoesSucceed(t *testing.T) {
 
 	ports := container.Ports
 	assert.Len(t, ports, 1)
-	assert.Equal(t, "prometheus", ports[0].Name)
 	assert.Equal(t, int32(9779), ports[0].ContainerPort)
 	assert.Equal(t, corev1.ProtocolTCP, ports[0].Protocol)
 


[camel-k] 04/05: fix(prometheus): Do not declare Prometheus container port when Knative is enabled

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 38e1d2ae9633dfe2da9c4e9c368e6641b9829b7e
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Fri May 29 18:58:55 2020 +0200

    fix(prometheus): Do not declare Prometheus container port when Knative is enabled
---
 pkg/trait/prometheus.go | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/pkg/trait/prometheus.go b/pkg/trait/prometheus.go
index e1e1f9e..c20f054 100644
--- a/pkg/trait/prometheus.go
+++ b/pkg/trait/prometheus.go
@@ -121,9 +121,16 @@ func (t *prometheusTrait) Apply(e *Environment) (err error) {
 	options := []string{strconv.Itoa(t.Port), path.Join(prometheusJmxExporterConfigMountPath, prometheusJmxExporterConfigFileName)}
 	container.Args = append(container.Args, "-javaagent:dependencies/io.prometheus.jmx.jmx_prometheus_javaagent-0.3.1.jar="+strings.Join(options, ":"))
 
-	// Add the container port
+	// Configure the Prometheus container port
 	containerPort := t.getContainerPort()
-	container.Ports = append(container.Ports, *containerPort)
+	controller, err := e.DetermineControllerStrategy(t.Ctx, t.Client)
+	if err != nil {
+		return err
+	}
+	// Skip declaring the Prometheus port when Knative is enabled, as only one container port is supported
+	if controller != ControllerStrategyKnativeService {
+		container.Ports = append(container.Ports, *containerPort)
+	}
 	condition.Message = fmt.Sprintf("%s(%s/%d)", container.Name, containerPort.Name, containerPort.ContainerPort)
 
 	// Retrieve the service or create a new one if the service trait is enabled


[camel-k] 03/05: fix(prometheus): Do not use same name for Prometheus service than Knative service

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit d557e19ba8a643624926353935166aad26575d71
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Fri May 29 18:32:37 2020 +0200

    fix(prometheus): Do not use same name for Prometheus service than Knative service
---
 pkg/trait/prometheus.go      | 6 ++++--
 pkg/trait/prometheus_test.go | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/pkg/trait/prometheus.go b/pkg/trait/prometheus.go
index 8a6dd8f..e1e1f9e 100644
--- a/pkg/trait/prometheus.go
+++ b/pkg/trait/prometheus.go
@@ -135,8 +135,11 @@ func (t *prometheusTrait) Apply(e *Environment) (err error) {
 			serviceEnabled = serviceTrait.isEnabled()
 		}
 		if serviceEnabled {
-			// add a new service if not already created
+			// Add a new service if not already created
 			service = getServiceFor(e)
+			// Override the service name if none exists.
+			// This is required for Knative Serving, that checks no standard eponymous service exist
+			service.Name = service.Name + "-prometheus"
 			e.Resources.Add(service)
 		}
 	} else {
@@ -144,7 +147,6 @@ func (t *prometheusTrait) Apply(e *Environment) (err error) {
 	}
 
 	// Add the service port and service monitor resource
-	// A better strategy may be needed when the Knative profile is active
 	if serviceEnabled {
 		servicePort := t.getServicePort()
 		service.Spec.Ports = append(service.Spec.Ports, *servicePort)
diff --git a/pkg/trait/prometheus_test.go b/pkg/trait/prometheus_test.go
index 30a676f..9d5e921 100644
--- a/pkg/trait/prometheus_test.go
+++ b/pkg/trait/prometheus_test.go
@@ -72,7 +72,7 @@ func TestApplyNominalPrometheusTraitDoesSucceed(t *testing.T) {
 	assert.Equal(t, corev1.ProtocolTCP, ports[0].Protocol)
 
 	service := environment.Resources.GetService(func(service *corev1.Service) bool {
-		return service.Name == "integration-name"
+		return service.Name == "integration-name-prometheus"
 	})
 	assert.NotNil(t, service)
 	assert.Len(t, service.Spec.Ports, 1)


[camel-k] 05/05: fix: Remove Prometheus container port name from condition message

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 726d849cd2fa2e31dfd74a3e46d07f74c2eb8c85
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Tue Jun 2 12:00:49 2020 +0200

    fix: Remove Prometheus container port name from condition message
---
 pkg/trait/prometheus.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pkg/trait/prometheus.go b/pkg/trait/prometheus.go
index c20f054..03b89f7 100644
--- a/pkg/trait/prometheus.go
+++ b/pkg/trait/prometheus.go
@@ -131,7 +131,7 @@ func (t *prometheusTrait) Apply(e *Environment) (err error) {
 	if controller != ControllerStrategyKnativeService {
 		container.Ports = append(container.Ports, *containerPort)
 	}
-	condition.Message = fmt.Sprintf("%s(%s/%d)", container.Name, containerPort.Name, containerPort.ContainerPort)
+	condition.Message = fmt.Sprintf("%s(%d)", container.Name, containerPort.ContainerPort)
 
 	// Retrieve the service or create a new one if the service trait is enabled
 	serviceEnabled := false