Skip to content

Conversation

@oksana-grishchenko
Copy link

@oksana-grishchenko oksana-grishchenko commented Dec 5, 2025

K8SPXC-1734 Powered by Pull Request Badge

Fix haproxy env vars conflict

Problem:
Setting cr.Spec.HAProxy.EnvVarsSecretName does not take any effect

Cause:
With #2207 now we always define the HA_SERVER_OPTIONS env var in the .env section of the sidecar container, however there is another mechanism of defining env variables that conflicts with it - defining via cr.Spec.HAProxy.EnvVarsSecretName. In that case the env vars defined in the secret go into the .envFrom section of the sidecar container, for which:

Values defined by an Env with a duplicate key will take precedence.

Solution:
Check if the actual secret cr.Spec.HAProxy.EnvVarsSecretName contains the HA_SERVER_OPTIONS env var and use the value preferably over the value from the cr.Spec.HAProxy.HealthCheck (wether default or explicitly set)

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?
  • Are OpenShift compare files changed for E2E tests (compare/*-oc.yml)?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported PXC version?
  • Does the change support oldest and newest supported Kubernetes version?

@it-percona-cla
Copy link

it-percona-cla commented Dec 5, 2025

CLA assistant check
All committers have signed the CLA.

@pull-request-size pull-request-size bot added the size/L 100-499 lines label Dec 5, 2025
@oksana-grishchenko oksana-grishchenko marked this pull request as ready for review December 5, 2025 07:53
@JNKPercona
Copy link
Collaborator

Test Name Result Time
auto-tuning-8-0 passed 00:00:00
allocator-8-0 passed 00:00:00
backup-storage-tls-8-0 passed 00:00:00
cross-site-8-0 passed 00:00:00
custom-users-8-0 passed 00:00:00
demand-backup-cloud-8-0 passed 00:57:07
demand-backup-encrypted-with-tls-8-0 passed 00:00:00
demand-backup-encrypted-with-tls-8-4 passed 00:45:43
demand-backup-8-0 passed 00:00:00
demand-backup-flow-control-8-0 passed 00:00:00
demand-backup-parallel-8-0 passed 00:00:00
demand-backup-without-passwords-8-0 passed 00:00:00
extra-pvc-8-0 passed 00:00:00
haproxy-5-7 passed 00:00:00
haproxy-8-0 passed 00:00:00
init-deploy-5-7 passed 00:16:30
init-deploy-8-0 passed 00:17:07
limits-8-0 passed 00:13:00
monitoring-2-0-8-0 passed 00:22:37
monitoring-pmm3-8-0 passed 00:18:26
one-pod-5-7 passed 00:14:36
one-pod-8-0 passed 00:14:12
pitr-8-0 passed 00:44:39
pitr-gap-errors-8-0 passed 00:56:58
proxy-protocol-8-0 passed 00:09:18
proxy-switch-8-0 passed 00:14:59
proxysql-sidecar-res-limits-8-0 passed 00:08:35
proxysql-scheduler-8-0 passed 00:17:23
pvc-resize-5-7 passed 00:16:01
pvc-resize-8-0 passed 00:16:13
recreate-8-0 passed 00:16:57
restore-to-encrypted-cluster-8-0 passed 00:25:45
restore-to-encrypted-cluster-8-4 passed 00:25:54
scaling-proxysql-8-0 passed 00:08:49
scaling-8-0 passed 00:10:45
scheduled-backup-5-7 passed 01:04:07
scheduled-backup-8-0 passed 01:03:02
security-context-8-0 passed 00:25:57
smart-update1-8-0 passed 00:31:09
smart-update2-8-0 passed 00:38:15
storage-8-0 passed 00:10:41
tls-issue-cert-manager-ref-8-0 passed 00:08:45
tls-issue-cert-manager-8-0 passed 00:09:37
tls-issue-self-8-0 passed 00:12:53
upgrade-consistency-8-0 passed 00:11:04
upgrade-haproxy-5-7 passed 00:23:42
upgrade-haproxy-8-0 passed 00:25:06
upgrade-proxysql-5-7 passed 00:14:39
upgrade-proxysql-8-0 passed 00:14:23
users-5-7 passed 00:24:31
users-8-0 passed 00:24:35
validation-hook-8-0 passed 00:01:55
Summary Value
Tests Run 52/52
Job Duration 02:32:32
Total Test Time 14:56:18

commit: 9639857
image: perconalab/percona-xtradb-cluster-operator:PR-2290-96398578

Copy link
Contributor

@gkech gkech left a comment

Choose a reason for hiding this comment

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

leaving some small comments

if cr.Spec.HAProxy != nil {
container.Env = append(container.Env, buildHAProxyHealthCheckEnvVars(cr.Spec.HAProxy.HealthCheck)...)
// check if the haproxy config is defined in EnvVarsSecretName, if so - it should be prioritized
// despite the fact the same env could have beren already applied above in the .EnvFrom section from the secret
Copy link
Contributor

Choose a reason for hiding this comment

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

beren maybe should be -> env could have already been applied

}

haproxy := &HAProxy{cr: cr}
ctx := context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

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

ctx can be defined outside the test loop, at the beginning of the test, or use t.Context()

}

haproxy := &HAProxy{cr: cr}
ctx := context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

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

same as another comment

}

proxySQL := &Proxy{cr: cr}
ctx := context.Background()
Copy link
Contributor

Choose a reason for hiding this comment

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

same as another comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L 100-499 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants