Skip to content

Conversation

gkech
Copy link
Contributor

@gkech gkech commented May 20, 2025

K8SPSMDB-297 Powered by Pull Request Badge

CHANGE DESCRIPTION

Problem:
Currently, logs are available only for the lifecycle of the particular pods. With this PR we are introducing the support for persistent logs, 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-58

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 - directory /data/db/logs/. The logs can also be visible on stdout through the -c logs container.

As part of this pr, we moved the required configuration 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. The fluentbit configuration for fluentbit can also be provided through the cr.yaml option configuration.

Demo:
Screenshot 2025-05-25 at 9 03 34 PM
Screenshot 2025-05-25 at 9 03 10 PM
Screenshot 2025-05-25 at 9 03 06 PM

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

Connected with: percona/percona-docker#1182

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 egegunes May 29, 2025 08:34
egegunes
egegunes previously approved these changes May 29, 2025
_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.

nitpick but ${LOGCOLLECTOR_ENABLED:-} is the same with just ${LOGCOLLECTOR_ENABLED}. by default var is empty

Copy link
Contributor Author

@gkech gkech May 29, 2025

Choose a reason for hiding this comment

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

tried it without the default and it didn't work, needed ${LOGCOLLECTOR_ENABLED:-} 🤔

Comment on lines 1193 to 1202
if !cr.IsLogCollectorEnabled() {
return nil
}

if cr.Spec.LogCollector.Configuration == "" {
if err := deleteConfigMapIfExists(ctx, r.client, cr, logcollector.ConfigMapName(cr.Name)); err != nil {
return errors.Wrap(err, "failed to delete log collector config map")
}
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we delete configmap if log collector is disabled?

Copy link
Contributor Author

@gkech gkech May 30, 2025

Choose a reason for hiding this comment

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

good point, 57a014d

egegunes
egegunes previously approved these changes May 30, 2025
…bled and the config map empty, delete the config map and continue the follow
@gkech
Copy link
Contributor Author

gkech commented May 30, 2025

preparing the helm chart pr as well

@JNKPercona
Copy link
Collaborator

Test name Status
arbiter passed
balancer passed
cross-site-sharded passed
custom-replset-name passed
custom-tls passed
custom-users-roles passed
custom-users-roles-sharded passed
data-at-rest-encryption passed
data-sharded passed
demand-backup passed
demand-backup-eks-credentials-irsa passed
demand-backup-fs passed
demand-backup-incremental passed
demand-backup-incremental-sharded passed
demand-backup-physical-parallel passed
demand-backup-physical-aws passed
demand-backup-physical-azure passed
demand-backup-physical-gcp passed
demand-backup-physical-minio passed
demand-backup-physical-sharded-parallel passed
demand-backup-physical-sharded-aws passed
demand-backup-physical-sharded-azure passed
demand-backup-physical-sharded-gcp passed
demand-backup-physical-sharded-minio passed
demand-backup-sharded passed
expose-sharded passed
finalizer passed
ignore-labels-annotations passed
init-deploy passed
ldap passed
ldap-tls passed
limits passed
liveness passed
mongod-major-upgrade passed
mongod-major-upgrade-sharded passed
monitoring-2-0 passed
monitoring-pmm3 passed
multi-cluster-service passed
multi-storage passed
non-voting-and-hidden passed
one-pod passed
operator-self-healing-chaos passed
pitr passed
pitr-physical passed
pitr-sharded passed
pitr-physical-backup-source passed
preinit-updates passed
pvc-resize passed
recover-no-primary passed
replset-overrides passed
rs-shard-migration passed
scaling passed
scheduled-backup passed
security-context passed
self-healing-chaos passed
service-per-pod passed
serviceless-external-nodes passed
smart-update passed
split-horizon passed
stable-resource-version passed
storage passed
tls-issue-cert-manager passed
upgrade passed
upgrade-consistency passed
upgrade-consistency-sharded-tls passed
upgrade-sharded passed
users passed
version-service passed
We run 68 out of 68

commit: 723c4d4
image: perconalab/percona-server-mongodb-operator:PR-1936-723c4d4a

@gkech gkech merged commit 1f3b686 into main May 30, 2025
18 of 19 checks passed
@gkech gkech deleted the K8SPSMDB-297 branch May 30, 2025 14:07
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.

5 participants