Skip to content

Conversation

nammn
Copy link
Collaborator

@nammn nammn commented Sep 1, 2025

Summary

This pull request improves the reliability of several end-to-end and integration tests in the MongoDB Kubernetes test suite by replacing custom retry logic with standardized pytest flakiness handling. The changes primarily remove manual retry loops from test cases and instead use the pytest.mark.flaky decorator to automatically rerun flaky tests, making the code cleaner and more maintainable.

Test stability improvements:

  • Added pytest.mark.flaky decorators to multiple test cases to automatically rerun tests on failure, replacing custom retry logic.
  • Only replaced those simple try and catch cases and kept the total wait time to be the same
  • Added this decorator to e2e_replica_set and e2e_replica_set_pv which is racy/flaky

Dependency and import adjustments:

  • Added missing pytest imports to test files to support the use of the flaky marker.

Proof of Work

  • green ci

Checklist

  • Have you linked a jira ticket and/or is the ticket in the title?
  • Have you checked whether your jira ticket required DOCSP changes?
  • Have you added changelog file?

@nammn nammn added the skip-changelog Use this label in Pull Request to not require new changelog entry file label Sep 1, 2025
Copy link

github-actions bot commented Sep 1, 2025

⚠️ (this preview might not be accurate if the PR is not rebased on current master branch)

MCK 1.3.0 Release Notes

New Features

Multi-Architecture Support

We've added comprehensive multi-architecture support for the kubernetes operator. This enhancement enables deployment on IBM Power (ppc64le) and IBM Z (s390x) architectures alongside
existing x86_64 support. Core images (operator, agent, init containers, database, readiness probe) now support multiple architectures. We do not add support IBM and ARM support for Ops-Manager and the init-ops-manager image.

  • MongoDB Agent images have been migrated to new container repository: quay.io/mongodb/mongodb-agent.
    • the agents in the new repository will support the x86-64, ARM64, s390x, and ppc64le architectures. More can be read in the public docs.
    • operator running >=MCK1.3.0 and static cannot use the agent images from the old container repository quay.io/mongodb/mongodb-agent-ubi.
  • quay.io/mongodb/mongodb-agent-ubi should not be used anymore, it's only there for backwards compatibility.

Bug Fixes

  • This change fixes the current complex and difficult-to-maintain architecture for stateful set containers, which relies on an "agent matrix" to map operator and agent versions which led to a sheer amount of images.
  • We solve this by shifting to a 3-container setup. This new design eliminates the need for the operator-version/agent-version matrix by adding one additional container containing all required binaries. This architecture maps to what we already do with the mongodb-database container.
  • Fixed an issue where the readiness probe reported the node as ready even when its authentication mechanism was not in sync with the other nodes, potentially causing premature restarts.

Other Changes

  • Optional permissions for PersistentVolumeClaim moved to a separate role. When managing the operator with Helm it is possible to disable permissions for PersistentVolumeClaim resources by setting operator.enablePVCResize value to false (true by default). When enabled, previously these permissions were part of the primary operator role. With this change, permissions have a separate role.
  • subresourceEnabled Helm value was removed. This setting used to be true by default and made it possible to exclude subresource permissions from the operator role by specifying false as the value. We are removing this configuration option, making the operator roles always have subresource permissions. This setting was introduced as a temporary solution for this OpenShift issue. The issue has since been resolved and the setting is no longer needed.
  • We have deliberately not published the container images for OpsManager versions 7.0.16, 8.0.8, 8.0.9 and 8.0.10 due to a bug in the OpsManager which prevents MCK customers to upgrade their OpsManager deployments to those versions.

@@ -22,6 +22,7 @@ def test_replica_set_sts_exists(self):
sts = self.appsv1.read_namespaced_stateful_set("rs001-pv", self.namespace)
assert sts

@pytest.mark.flaky(reruns=3, reruns_delay=2)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The statefulset might be ready and then quickly not. Its an intermittent error and we should retry here

https://parsley.mongodb.com/test/mongodb_kubernetes_e2e_mdb_openshift_ubi_cloudqa_e2e_replica_set_pv_patch_6b4107dea46c730d5f2d7a287a94d9850db7123c_68b1e4da263ed10007acf334_25_08_29_17_35_24/0/3d077fd8276a13067e76935d5d189254?bookmarks=0,642&shareLine=0

[2025/08/29 20:27:31.171] FAILURE: assert 2 == 3
[2025/08/29 20:27:31.171]  +  where 2 = {'available_replicas': 2,\n 'collision_count': 0,\n 'conditions': None,\n 'current_replicas': 3,\n 'current_revision': 'rs001-pv-56c4dc5d86',\n 'observed_generation': 1,\n 'ready_replicas': 2,\n 'replicas': 3,\n 'update_revision': 'rs001-pv-56c4dc5d86',\n 'updated_replicas': 3}.ready_replicas
[2025/08/29 20:27:31.17

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@nammn nammn marked this pull request as ready for review September 1, 2025 09:10
@nammn nammn requested a review from a team as a code owner September 1, 2025 09:10
@nammn nammn changed the title [flakiness] pytest - use rerunfailures [flakiness] pytest - use rerunfailures for retries Sep 1, 2025
@nammn nammn requested review from lsierant and mircea-cosbuc and removed request for lsierant September 1, 2025 09:34
Copy link
Collaborator

@MaciejKaras MaciejKaras left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Use this label in Pull Request to not require new changelog entry file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants