Skip to content

K8SPXC-1798 | support configuring logrotate#2400

Draft
mayankshah1607 wants to merge 16 commits intomainfrom
K8SPXC-1789
Draft

K8SPXC-1798 | support configuring logrotate#2400
mayankshah1607 wants to merge 16 commits intomainfrom
K8SPXC-1789

Conversation

@mayankshah1607
Copy link
Copy Markdown
Member

@mayankshah1607 mayankshah1607 commented Mar 16, 2026

CHANGE DESCRIPTION

Summary

  • Introduce a new section .spec.logcollector.logRotate, allowing users to customize logrotate schedule, configuration, and supply extra config via ConfigMaps
  • Migrate logcollector scripts and configs from percona-docker into the operator image, copied to PXC pods via init container at v1.20.0+
  • Add config hash tracking for logcollector and logrotate ConfigMaps so PXC pods restart automatically when log configuration changes

Examples

Example 1: Custom schedule

spec:
  logCollector:
    logRotate:
      schedule: "0 */6 * * *"

Example 2: Override default logrotate config (specify inline)

spec:
  logCollector:
    logRotate:
      schedule: "0 0 * * *"
      configuration: |
        /var/lib/mysql/[!G]*.log {
          daily
          minsize 5M
          maxsize 50M
          rotate 5
          missingok
          compress
          delaycompress
          notifempty
          sharedscripts
          postrotate
            /opt/percona/logcollector/logrotate/postrotate-mysql.sh
          endscript
        }

Example 3: Specify additional logrotate configs

First create a ConfigMap with .conf extension keys:

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-logrotate-config
data:
  gra-logs.conf: |
    /var/lib/mysql/GRA_*.log {
      daily
      rotate 7
      missingok
      notifempty
      compress
      delaycompress
    }
  audit-log.conf: |
    /var/lib/mysql/audit.log {
      daily
      rotate 14
      minsize 10M
      maxsize 200M
      missingok
      compress
      delaycompress
      notifempty
    }

Then reference it in the CR:

spec:
  logCollector:
    logRotate:
      extraConfig:
        name: my-logrotate-config

Field reference

Field Type Default Description
logRotate.schedule string "0 0 * * *" (daily at midnight) Cron expression for logrotate execution schedule
logRotate.configuration string (built-in default) Inline logrotate config that replaces the default logrotate-mysql.conf
logRotate.extraConfig.name string Name of a ConfigMap with additional .conf files to include alongside the main config

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?

Signed-off-by: Mayank Shah <mayank.shah@percona.com>
Signed-off-by: Mayank Shah <mayank.shah@percona.com>
Signed-off-by: Mayank Shah <mayank.shah@percona.com>
@pull-request-size pull-request-size bot added the size/XL 500-999 lines label Mar 16, 2026
Signed-off-by: Mayank Shah <mayank.shah@percona.com>
Signed-off-by: Mayank Shah <mayank.shah@percona.com>
Signed-off-by: Mayank Shah <mayank.shah@percona.com>
Signed-off-by: Mayank Shah <mayank.shah@percona.com>
Signed-off-by: Mayank Shah <mayank.shah@percona.com>
@pull-request-size pull-request-size bot added size/XXL 1000+ lines and removed size/XL 500-999 lines labels Mar 17, 2026
Signed-off-by: Mayank Shah <mayank.shah@percona.com>
mayankshah1607 and others added 6 commits March 18, 2026 09:54
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@JNKPercona
Copy link
Copy Markdown
Collaborator

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

commit: bd0b43e
image: perconalab/percona-xtradb-cluster-operator:PR-2400-bd0b43e6

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

Labels

size/XXL 1000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants