Skip to content

Conversation

rohara
Copy link
Contributor

@rohara rohara commented Aug 26, 2025

The haproxy-config.template must be updated to allow configuration of both HTTP and TCP log formats. Previously, only HTTP log format was configurable, and if not set, the default 'option httplog' was used. This logic is now pushed down into each frontend. The basic idea is that if access logging is enabled, we then look at the respective log format environment variable, then use either the custom log format or the default log format.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 26, 2025
@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Aug 26, 2025

@rohara: This pull request references NE-2116 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.20.0" version, but no target version was set.

In response to this:

The haproxy-config.template must be updated to allow configuration of both HTTP and TCP log formats. Previously, only HTTP log format was configurable, and if not set, the default 'option httplog' was used. This logic is now pushed down into each frontend. The basic idea is that if access logging is enabled, we then look at the respective log format environment variable, then use either the custom log format or the default log format.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from alebedev87 and rikatz August 26, 2025 14:04
Copy link
Contributor

openshift-ci bot commented Aug 26, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ironcladlou for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

openshift-ci bot commented Aug 26, 2025

@rohara: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-metal-ipi-ovn-router 5130431 link false /test e2e-metal-ipi-ovn-router
ci/prow/e2e-agnostic 5130431 link true /test e2e-agnostic
ci/prow/e2e-upgrade 5130431 link true /test e2e-upgrade
ci/prow/unit 5130431 link true /test unit
ci/prow/okd-scos-e2e-aws-ovn 5130431 link false /test okd-scos-e2e-aws-ovn
ci/prow/e2e-aws-serial 5130431 link true /test e2e-aws-serial
ci/prow/e2e-metal-ipi-ovn-ipv6 5130431 link false /test e2e-metal-ipi-ovn-ipv6
ci/prow/e2e-metal-ipi-ovn-dualstack 5130431 link false /test e2e-metal-ipi-ovn-dualstack

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@rikatz
Copy link
Member

rikatz commented Aug 26, 2025

@rohara I was having some chat with @alebedev87 and @Miciah about testing templates, are you considering adding some cases on https://github.com/openshift/router/blob/master/pkg/router/router_test.go using t.SetEnv to assert that the template rendering is working?

I don't have comments about the feature/directives, will leave this for someone with more context!

Thanks!

@Miciah
Copy link
Contributor

Miciah commented Aug 27, 2025

/assign

@candita
Copy link
Contributor

candita commented Aug 27, 2025

/assign @rikatz
/assign @rfredette

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't obvious why you keep log-format / option httplog in defaults. Is that intentional, to preserve ROUTER_SYSLOG_FORMAT as the default for frontends that (implicitly) use mode tcp when ROUTER_TCP_LOG_FORMAT or ROUTER_HTTPS_LOG_FORMAT is not specified? It would be helpful to explain this in the commit message.

Comment on lines +230 to +235
{{- if ne (env "ROUTER_SYSLOG_ADDRESS") "" }}
{{- if ne (env "ROUTER_HTTP_LOG_FORMAT") "" }}
log-format {{ env "ROUTER_HTTP_LOG_FORMAT" }}
{{- else }}
option httplog
{{- end }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look syntactically correct: You add two ifs and only one end.

Comment on lines +311 to +313
{{- if ne (env "ROUTER_TCP_LOG_FORMAT") "" }}
log-format {{ env "ROUTER_TCP_LOG_FORMAT" }}
{{- else }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, you add if/else without a matching end.

Comment on lines +355 to +360
{{- if ne (env "ROUTER_SYSLOG_ADDRESS") "" }}
{{- if ne (env "ROUTER_HTTPS_LOG_FORMAT") "" }}
log-format {{ env "ROUTER_HTTPS_LOG_FORMAT" }}
{{- else }}
option httpslog
{{- end }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing end.

Comment on lines +479 to +484
{{- if ne (env "ROUTER_SYSLOG_ADDRESS") "" }}
{{- if ne (env "ROUTER_HTTPS_LOG_FORMAT") "" }}
log-format {{ env "ROUTER_HTTPS_LOG_FORMAT" }}
{{- else }}
option httsplog
{{- end }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing end.

@@ -227,6 +227,12 @@ listen stats

{{ if .BindPorts -}}
frontend public
{{- if ne (env "ROUTER_SYSLOG_ADDRESS") "" }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider defining {{- $syslogAddress := env "ROUTER_SYSLOG_ADDRESS" }}, {{- $httpLogFormat := env "ROUTER_HTTP_LOG_FORMAT" }}, and so on for the following reasons:

  • Less performance hit from repeatedly calling into Go helpers.
  • Less risk of typos in the environment variable's name.
  • Slightly simpler and more readable if conditions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, the env helper can take additional arguments; it uses the first nonempty value, so you could do the following:

{{- $httpLogFormat := env "ROUTER_HTTP_LOG_FORMAT" (env "ROUTER_SYSLOG_FORMAT") }}
{{- $httpsLogFormat := env "ROUTER_HTTPS_LOG_FORMAT" $httpLogFormat }}
{{- $tcpLogFormat := env "ROUTER_TCP_LOG_FORMAT" $httpLogFormat }}

This also makes the defaulting behavior more explicit and clear, in my opinion.

@Miciah
Copy link
Contributor

Miciah commented Aug 28, 2025

The PR description has some useful detail that is not in the commit message. Please do make sure that the commit message has a clear description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants