Skip to content

fix(collaboration): retry soon and keep the app URLs when the WOPI discovery fails - #4007

Open
pbleser-oc wants to merge 1 commit into
opencloud-eu:mainfrom
pbleser-oc:fix/3995-collaboration-discovery-retry
Open

pbleser-oc wants to merge 1 commit into
opencloud-eu:mainfrom
pbleser-oc:fix/3995-collaboration-discovery-retry

Conversation

@pbleser-oc

Copy link
Copy Markdown
Member

A single failed fetch of the WOPI discovery, e.g. while the office app restarts, no longer makes opening documents fail for up to 30 s, and /readyz reports "not ready" until the collaboration service has the app URLs.

Fixes #3995

Changes

  • Retry soon: a failed fetch is retried after 1 s, then 2, 4, 8, 16 s, up to the registration interval (COLLABORATION_CS3API_APP_REGISTRATION_INTERVAL, 30 s by default). Before, the next try came only after the full interval.
  • Keep the app URLs while retrying: the URLs of the last successful fetch stay in use while the retries back off. They are cleared once the retries have reached the full interval, i.e. when the office app has been unreachable for about one interval (31 s with the defaults), so that it isn't offered while it is gone. The next successful fetch brings them back.
  • Timeout: a fetch gives up after 10 s, configurable with the new COLLABORATION_APP_DISCOVERY_TIMEOUT (0 disables it). Without a timeout, an office app that accepts the connection but never answers would stop the refresh, and the re-registration, for good.
  • Readiness: /readyz fails until the app URLs have been fetched once. /healthz is unchanged. Once ready, the service stays ready, also when the URLs are cleared later.
  • The refresh loop moves from the server command into helpers.RefreshAppProvider, with unit tests against a fake discovery endpoint.

Trade-off: keeping vs. clearing the app URLs

@butonic, you introduced the clearing in #1542 ("empty map to clear previous URLs"), so I'd like your opinion on this part. My understanding is that clearing keeps the registry honest: while the office app can't be reached, its mimetypes aren't advertised, and new page loads don't offer an app that would fail anyway.

The cost is that any single failed fetch removes the app for up to a full interval, although the office app may be back a second later. A web UI that is already loaded still offers the app, and opening a document then fails with a 500 ("Error contacting the requested application").

This PR keeps the clearing, but only for an outage of about one interval; shorter failures are bridged with the old URLs. During those ~30 s, opening a document fails for a really unreachable office app, as it does today. Would you prefer to keep clearing right away (with only the faster retry), or to never clear?

Deployments that probe the collaboration service

Deployments that check the collaboration service's own /readyz now see it "not ready" until the office app has answered once. In a rolling update, a new instance then only becomes ready when the office app is reachable. The CI already waits for the collaboration services' /readyz (up to 300 s), so its wait now also covers the office app being ready.

Notes

AI assistance: Claude Code (claude-opus-5-5) wrote the code and the tests, and the first draft of this description; I reviewed and adjusted them.

…scovery fails

When a fetch of the WOPI discovery failed, the collaboration service
cleared its app URLs, registered without mimetypes, and fetched again
only after the full registration interval (30 s by default). Until then,
opening documents failed, also when the WOPI app was only restarting.
Meanwhile /readyz reported ready.

- Retry a failed fetch after 1 s, doubling the delay up to the interval.
- Keep the app URLs of the last successful fetch while retrying. Clear
  them only once the retries have backed off to the full interval, i.e.
  when the WOPI app has been unreachable for about one interval, so that
  it isn't offered while it is gone.
- Limit a fetch to 10 s by default (COLLABORATION_APP_DISCOVERY_TIMEOUT),
  so a WOPI app that doesn't answer can't stop the refresh.
- /readyz reports "not ready" until the app URLs have been fetched once;
  /healthz is unchanged.

The loop moves from the server command into helpers.RefreshAppProvider,
so it can be tested.

Fixes opencloud-eu#3995

Assisted-by: Claude Code:claude-opus-5-5
@codacy-production

codacy-production Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 27 complexity

Metric Results
Complexity 27

View in Codacy

🟢 Coverage 58.82% diff coverage · +0.06% coverage variation

Metric Results
Coverage variation ✅ +0.06% coverage variation (-1.00%)
Diff coverage ✅ 58.82% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (2ff7018) 94239 28124 29.84%
Head commit (f9c6608) 94276 (+37) 28191 (+67) 29.90% (+0.06%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4007) 68 40 58.82%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

collaboration: opening documents fails for up to 30 s after a failed WOPI discovery fetch, while /readyz reports ready

1 participant