Skip to content

K8SPSMDB-1296: improve readiness probe #1917

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 23 commits into
base: main
Choose a base branch
from
Open

K8SPSMDB-1296: improve readiness probe #1917

wants to merge 23 commits into from

Conversation

pooknull
Copy link
Contributor

@pooknull pooknull commented May 12, 2025

K8SPSMDB-1296 Powered by Pull Request Badge

https://perconadev.atlassian.net/browse/K8SPSMDB-1296

DESCRIPTION

This PR improves readiness probe by verifying the stateStr field in the replSetGetStatus output. If it's not possible to execute the command, the readiness probe will not fail, because otherwise it wouldn't be possible to deploy a mongod statefulset. The readiness probe will fail if the value of the stateStr is not equal to Primary, Secondary or Arbiter

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/XXL 1000+ lines label May 12, 2025
@github-actions github-actions bot added the tests label May 12, 2025
@pooknull pooknull marked this pull request as ready for review May 26, 2025 12:00
"github.com/percona/percona-server-mongodb-operator/pkg/psmdb/mongo"
)

func getStatus(ctx context.Context, client mongo.Client) (ReplSetStatus, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we have all the mongo client-related functions together as part of the type Client interface? I understand that we are not committing to the interface segregation rule by doing that, but that interface is already containing everything (almost in terms of functionality).

Also the response type seems related to the generic mongo model and maybe can be moved to the mongo model file.

type ReplSetStatus struct {
...
}

This removes the need to have a utils file completely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 60 to 62
if err != nil {
log.Error(err, "Failed to get replset status")
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.

i wonder if we should ignore all errors or only this node is not a member of replset?

@pooknull pooknull requested a review from valmiranogueira as a code owner May 27, 2025 05:21
@hors hors added this to the v1.21.0 milestone May 27, 2025
gkech
gkech previously approved these changes May 29, 2025
gkech
gkech previously approved these changes May 30, 2025
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.

4 participants