Skip to content

K8SPSMDB-297 support persistent logs #1936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

K8SPSMDB-297 support persistent logs #1936

wants to merge 5 commits into from

Conversation

gkech
Copy link
Contributor

@gkech gkech commented May 20, 2025

K8SPSMDB-297 Powered by Pull Request Badge

CHANGE DESCRIPTION

Problem:
Logs are available only for the lifecycle of the particular pods. With this PR we are introducing the support for persistent logs in PVC (separate from the PVC used for actual mongo data), focusing for now only on the mongod logs.

Cause:
Short explanation of the root cause of the issue if applicable.

Solution:
Image: perconalab/percona-server-mongodb-operator:K8SPSMDB-297-22

The solution utilises FluentBit to manage the log pipeline, appending the appropriate metadata and storing the logs in a single file in a log-specific PVC for each pod. The logs can also be visible on stdout.

As part of this pr, we moved the required files for fluentbit from here: https://github.com/percona/percona-docker/tree/main/fluentbit to this repo and we mount them to the logs and logrotation containers.

Screenshot 2025-05-21 at 12 32 21 PM

Screenshot 2025-05-21 at 12 38 32 PM

In terms of documentation, the functionality is similar to this: https://docs.percona.com/percona-operator-for-mysql/pxc/debug-logs.html

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 MongoDB version?
  • Does the change support oldest and newest supported Kubernetes version?

@pull-request-size pull-request-size bot added the size/XL 500-999 lines label May 20, 2025
@gkech gkech force-pushed the K8SPSMDB-297 branch 6 times, most recently from c3e53e6 to 63f5e16 Compare May 20, 2025 16:21
@pull-request-size pull-request-size bot added size/XXL 1000+ lines and removed size/XL 500-999 lines labels May 20, 2025
@gkech gkech force-pushed the K8SPSMDB-297 branch 5 times, most recently from 93f17f2 to 18f9557 Compare May 21, 2025 08:41
@pull-request-size pull-request-size bot added size/XL 500-999 lines and removed size/XXL 1000+ lines labels May 21, 2025
@gkech gkech force-pushed the K8SPSMDB-297 branch 3 times, most recently from 535245f to d72b63f Compare May 21, 2025 09:09
@pull-request-size pull-request-size bot added size/XXL 1000+ lines and removed size/XL 500-999 lines labels May 21, 2025
@gkech gkech marked this pull request as ready for review May 21, 2025 09:31
@gkech gkech requested a review from nmarukovich as a code owner May 21, 2025 09:31
@gkech gkech force-pushed the K8SPSMDB-297 branch 3 times, most recently from 11516e8 to 1ade2b4 Compare May 21, 2025 10:40
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this? if yes, we need to fix the typo in the file name

@@ -743,3 +743,10 @@ spec:
# storageName: s3-us-west
# compressionType: gzip
# compressionLevel: 6
logcollector:
enabled: true
image: perconalab/percona-xtradb-cluster-operator:main-logcollector
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to fix this image, is this temporary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Until the new images for Fluentbit are ready, I think we should keep this as is. We can change it with a new PR once these new images are ready.

fluentbit_opt+='-c /opt/percona/logcollector/fluentbit/fluentbit.conf'
fi

exec "$@" $fluentbit_opt
Copy link
Contributor

Choose a reason for hiding this comment

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

[shellcheck (suggestion)] reported by reviewdog 🐶

Suggested change
exec "$@" $fluentbit_opt
exec "$@" "$fluentbit_opt"

@@ -480,6 +480,11 @@ if [[ $originalArgOne == mongo* ]]; then
_mongod_hack_rename_arg_save_val --sslDisabledProtocols --tlsDisabledProtocols "${mongodHackedArgs[@]}"
fi

if [[ $originalArgOne == "mongod" && "${LOGCOLLECTOR_ENABLED:-}" == "true" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

[shfmt] reported by reviewdog 🐶

Suggested change
if [[ $originalArgOne == "mongod" && "${LOGCOLLECTOR_ENABLED:-}" == "true" ]]; then
if [[ $originalArgOne == "mongod" && ${LOGCOLLECTOR_ENABLED:-} == "true" ]]; then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants