Fix waiting-file jobs in Cloudflare Tunnel self-hosted deployments / 修复Cloudflare Tunnel自托管部署中等待文件的任务 - #17
Open
thinktraveller wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a deployment-level patch to unblock self-hosted LocalStack SNS subscription confirmation in Cloudflare Tunnel setups where the public S3 endpoint differs from the internal LocalStack endpoint, preventing jobs from getting stuck in waiting-file.
Changes:
- Add a patched
subscription_service.pythat rewrites/validates LocalStack SNS confirmation URLs using internal self-hosted endpoint settings. - Prefer
SELF_HOSTED_AWS_ENDPOINT_URLandS3_PRIVATE_DOMAINahead ofS3_ENDPOINT_URLwhen determining the trusted LocalStack endpoint. - Mount the patched service into the app container via
compose.yaml.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| patches/knowhere/subscription_service.py | Adds LocalStack-aware URL rewrite/validation and a custom resolution path for SNS subscription confirmation. |
| compose.yaml | Mounts the patched service file into the Knowhere container to override the upstream implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
21
to
+23
| - knowhere_model_cache:/data/models | ||
| - knowhere_secrets:/data/secrets | ||
| - ./patches/knowhere/subscription_service.py:/opt/knowhere/source/api/apps/api/app/services/s3_events/subscription_service.py:ro |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR fixes self-hosted LocalStack SNS subscription confirmation when the public
S3 endpoint differs from the internal LocalStack endpoint.
In Cloudflare Tunnel deployments,
S3_ENDPOINT_URLmay point to a public HTTPSdomain such as
https://storage-knowhere.example.com, while the app should stilltrust LocalStack's internal confirmation URL such as
http://localstack:4566.Previously, the app only used
S3_ENDPOINT_URLto validate SNS subscriptionconfirmation URLs, causing LocalStack SNS subscriptions to remain in
PendingConfirmationand uploaded files to stay stuck inwaiting-file.Changes
subscription_service.pythat validates LocalStack SNSconfirmation URLs against internal self-hosted endpoints.
SELF_HOSTED_AWS_ENDPOINT_URLandS3_PRIVATE_DOMAINbefore falling backto
S3_ENDPOINT_URL.compose.yaml.Root Cause
When using a public storage domain for uploads, the app rejects LocalStack SNS
subscription confirmation URLs because their host is
localstack, whileS3_ENDPOINT_URLpoints to the public Cloudflare domain.As a result:
PendingConfirmation=truewaiting-fileJOB_EXPIREDVerification
Verified on a self-hosted deployment with Cloudflare Tunnel:
PendingConfirmation=false/v1/internal/s3-eventsdoneresults/<job_id>.zipNotes
This is currently implemented as a deployment-level patch mounted through Docker
Compose. A future upstream-native fix could move the endpoint selection logic
directly into the application source instead of using an overlay patch.
摘要
本PR修复了当公共S3端点与内部LocalStack端点不同时,自托管LocalStack SNS订阅确认的问题。
在Cloudflare Tunnel部署中,
S3_ENDPOINT_URL可能指向公共HTTPS域名(如https://storage-knowhere.example.com),而应用仍应信任LocalStack的内部确认URL(如http://localstack:4566)。此前,应用仅使用S3_ENDPOINT_URL验证SNS订阅确认URL,导致LocalStack SNS订阅停留在PendingConfirmation状态,上传文件也卡在waiting-file状态。变更内容
subscription_service.py,使LocalStack SNS确认URL能针对内部自托管端点进行验证SELF_HOSTED_AWS_ENDPOINT_URL和S3_PRIVATE_DOMAIN,再回退到S3_ENDPOINT_URLcompose.yaml将修补后的服务文件挂载到应用容器中根本原因
当使用公共存储域名进行上传时,应用会拒绝LocalStack SNS订阅确认URL,因为其主机名为
localstack,而S3_ENDPOINT_URL指向公共Cloudflare域名。结果导致:
PendingConfirmation=true状态waiting-file状态JOB_EXPIRED而失败验证结果
已在使用Cloudflare Tunnel的自托管部署中验证:
PendingConfirmation=false/v1/internal/s3-eventsdoneresults/<job_id>.zip路径下生成结果对象备注
当前方案通过Docker Compose挂载的部署级补丁实现。未来的上游原生修复可将端点选择逻辑直接移入应用程序源码,而非使用覆盖补丁。