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
The following commit(s) were added to refs/heads/main by this push: new 36a63891b fix(trait): workaround Knative h2c port name 36a63891b is described below commit 36a63891b398c737da5449aee7b53826a17b5f34 Author: Pasquale Congiusti <pasquale.congiu...@gmail.com> AuthorDate: Thu Jan 16 18:22:27 2025 +0100 fix(trait): workaround Knative h2c port name Closes #6014 --- pkg/trait/prometheus.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/trait/prometheus.go b/pkg/trait/prometheus.go index ba11aaa55..2bf706a84 100644 --- a/pkg/trait/prometheus.go +++ b/pkg/trait/prometheus.go @@ -87,7 +87,7 @@ func (t *prometheusTrait) Apply(e *Environment) error { // Add the PodMonitor resource if ptr.Deref(t.PodMonitor, true) { - portName := containerPort.Name + portName := getPortName(containerPort.Name) podMonitor, err := t.getPodMonitorFor(e, portName) if err != nil { return err @@ -103,6 +103,15 @@ func (t *prometheusTrait) Apply(e *Environment) error { return nil } +func getPortName(portName string) string { + // This is a workaround to fix Knative behavior + // as described in https://github.com/apache/camel-k/issues/6014 + if portName == defaultKnativeContainerPortName { + return "user-port" + } + return portName +} + func (t *prometheusTrait) getPodMonitorFor(e *Environment, portName string) (*monitoringv1.PodMonitor, error) { labels, err := keyValuePairArrayAsStringMap(t.PodMonitorLabels) if err != nil {