GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — providers/mongo: ping mongod before yielding from mongodb_container fixture by potiuk · Pull Request #67066 · apache/airflow

Conversation

@potiuk

@potiuk potiuk commented May 17, 2026

Copy link
Copy Markdown
Member

The Low dep tests: providers mongo job is occasionally flaky on ARM CI —
every TestMongoHook test errors at setup_method with:

pymongo.errors.ServerSelectionTimeoutError: 172.17.0.1:32769:
[Errno 111] Connection refused

while the same SHA passes on the other parallel runs (e.g. mongo-3.11
failed in run 25978857524
while every other mongo slot on that SHA was green).

Root cause: under uv --resolution lowest-direct, testcontainers is
pinned at the floor (4.12.0). MongoDbContainer.start() only waits for
the "waiting for connections" log line, and mongod can emit that line a
few milliseconds before the TCP listener is actually accepting on the
published port. The fixture yielded get_connection_url() immediately
after start() returned, so the first hook setup hit a closed port.

No testcontainers version on PyPI closes that gap — testcontainers 4.13.2
only made the log regex case-insensitive for legacy mongo 3.6 images
(see testcontainers-python#783),
which doesn't help mongo:8.0. The reliable fix is in our own conftest.

Fix: after container.start() succeeds, actively ping mongod with
pymongo.MongoClient.admin.command("ping") retried for up to 60 s, then
yield. All dependent fixtures now see a mongod that genuinely accepts
connections.

Observed failing CI job: https://github.com/apache/airflow/actions/runs/25978857524/job/76374215829


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Opus 4.7 (1M context)

Generated-by: Claude Opus 4.7 (1M context) following the guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@potiuk
providers/mongo: ping mongod before yielding from mongodb_container f…
8183fb6
…ixture

Under uv --resolution lowest-direct, testcontainers==4.12.0 is pinned and
MongoDbContainer.start() waits only for the "waiting for connections" log
line. mongod can emit that log line a few milliseconds before the TCP
listener is actually accepting connections on the published port. We
observed a low-frequency ARM CI flake where the entire TestMongoHook
suite errored at setup_method with:

    pymongo.errors.ServerSelectionTimeoutError: 172.17.0.1:32769:
    [Errno 111] Connection refused

while the same SHA passed on the other parallel runs.

No testcontainers version on PyPI closes the log-to-listener gap for
modern mongo images (4.13.2 only made the log regex case-insensitive for
mongo 3.6); the only reliable fix is to actively probe mongod from the
fixture. Add a short pymongo ping loop after get_connection_url() and
before yielding so all dependent fixtures see a mongod that actually
accepts connections.
@boring-cyborg boring-cyborg Bot added area:providers provider:mongo labels May 17, 2026
jscheffl
jscheffl approved these changes May 17, 2026
View reviewed changes
@potiuk

potiuk commented May 17, 2026

Copy link
Copy Markdown
Member Author

I'd love to get this one merged.


Drafted-by: Claude Code (Opus 4.7); reviewed by @potiuk before posting

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@potiuk
potiuk merged commit 8ee29ce into apache:main May 17, 2026
89 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@potiuk
potiuk deleted the fix-mongo-testcontainer-ping-wait branch May 17, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jscheffl jscheffl jscheffl approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

area:providers provider:mongo

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@potiuk @jscheffl
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.