Content app answers 404 instead of 502 when the remote of on-demand content is unavailable
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start in Handler._stream_content_artifact in the content app, where the loop over RemoteArtifact downloads ends by raising HTTPNotFound; SKIPPABLE_EXCEPTIONS and REMOTE_CONTENT_FETCH_FAILURE_COOLDOWN also govern that loop. Run test_delete_remote_on_demand, test_remote_artifact_url_update and test_remote_content_changed_with_on_demand, which must keep passing as 404. Done means a connection failure or 5xx from the remote yields 502 while the other failure cases stay 404, and the open question about 429 is settled.
索引モデルが issue の本文から書いたものです。
説明
Version
pulpcore 3.119.2 with pulp_file, installed from source with oci-env. The behaviour is the same on main (475caac) and dates back to 3.0.0.
Describe the bug
When a ContentArtifact has no Artifact (on-demand or streamed content, or content whose artifact was reclaimed), the content app streams it from its RemoteArtifact objects. When none of them can be fetched, Handler._stream_content_artifact raises HTTPNotFound whatever the reason: a remote that cannot be reached or answers with a server error gets the same 404 as content missing upstream.
The docstring of _stream_content_artifact contradicts itself: its description says that "if all RemoteArtifact downloads raise exceptions, an HTTP 502 error is returned to the client", while its Raises section, like the code, gives HTTPNotFound. It has been so since 3.0.0; the user documentation does not mention this case.
Clients then take a transient upstream outage for missing content. For example, pip retries 500, 502, 503, 520 and 527 but not 404, so with pulp_python packages synced with the default on_demand policy, a short outage fails the install at once, with a 404 pointing at the package.
To Reproduce
- Sync a file repository with the
on_demandpolicy from a fixture server, and distribute it. - Make the fixture server unavailable: close the connections, or answer 503 for the files.
- Download a file from the distribution: 404 Not Found.
Expected behavior
502 Bad Gateway when at least one remote could not be reached or answered with a server error (5xx). 404 for any other failure, as today, e.g. no RemoteArtifact, remotes answering 404, 410 or another 4xx, UnsupportedDigestValidationError, RemoteArtifact objects in their failure cooldown (REMOTE_CONTENT_FETCH_FAILURE_COOLDOWN).
Open question: should a 429 Too Many Requests from the remote, which is transient too, also give a 502?
Additional context
- The tests asserting a 404 (
test_delete_remote_on_demand,test_remote_artifact_url_update,test_remote_content_changed_with_on_demand) cover those other cases and pass unchanged with the fix. - pulp_container calls
_stream_content_artifactdirectly for registry blobs, which would get a 502 too. None of the active content plugins (pulp_ansible, pulp_container, pulp_deb, pulp_gem, pulp_hugging_face, pulp_maven, pulp_npm, pulp_python, pulp_r, pulp_rpm, pulp_rust, pulp_trustify, pulp_workflow) nor pulp-service catches this 404 or asserts it in its tests. - Nothing in pulpcore catches this 404 to fall back elsewhere: the content cache stores neither response, and the instrumentation middleware records the status, so the
content.request_durationmetrics and deployments alerting on the 5xx rate of the content app will count upstream outages there. TimeoutException, raised by the downloader on timeouts, is not one of the exceptions skipped by this loop (SKIPPABLE_EXCEPTIONS) and is left unchanged.
I reproduced it in an oci-env container with pulpcore 3.119.2 and pulp_file installed from source: once the remote closed the connections or answered 503, the distribution answered 404 for the on-demand file.
Drafted with AI assistance, reviewed by me.
- 主要言語
- Python
- スター
- 606
- フォーク
- 174
- 平均マージ
- 16時間 44分
- マージ済み PR(30日)
- 107
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
pulp/pulpcore のほかの issue
-
Issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
Feature
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
pulp/pulpcore#5802 · コメント 10 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 28/100
pulp/pulpcore#8214 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Performance Task Triage-Needed
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
pulp/pulpcore#8206 · コメント 3 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Issue Triage-Needed
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
cathrynlavery/diagram-design#441 ·
メンテナーはふだん 2 日以内に返信
-
[Cleanup] Include the public header in work_split.cpp対応中かも @blozano-tt が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
tenstorrent/tt-metal#60850 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
backend::sglang bug language::python observability
難易度 2/5 半日 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
OpenShot/openshot-qt#6202 ·
メンテナーはふだん 1 日以内に返信