Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid requesting remote endpoints during bootstrap #3749

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

juliushaertl
Copy link
Member

@juliushaertl juliushaertl commented Jun 11, 2024

This will add some abstraction layer for cached request data as used by
capabilities and discovery endpoints. By default it will always return
the cached data which will never expire (backed by a file in app data in
case the memory cache vanishes).

In short the logic is:

  • Fetch the endpoints when configuring Collabora
  • Refetch them every hour with the background job
  • When trying to get the data we will (in order)
    • Check the memory cache
    • Check the file in appdata (and set the memory cache again)

There is still a use of fetch for richdocumentscode but that needs some more refactoring to work differently. Does not affect instances where richdocumentscode is not enabled.

Also decreasing the timeout to 5 seconds which should be more then enough.

  • Resolves: #
  • Target version: main

Summary

TODO

  • ...

Checklist

  • Code is properly formatted
  • Sign-off message is added to all commits
  • Documentation (manuals or wiki) has been updated or is not required

@juliushaertl juliushaertl added bug Something isn't working 3. to review Ready to be reviewed labels Jun 11, 2024
@juliushaertl
Copy link
Member Author

/backport to stable29

try {
$capabilitiesService->fetch();
$discoveryService->fetch();
} catch (\Exception $e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to do anything here with the caught error? Is it OK to catch it and just throw it away?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just ignored it as I fear spamming the log here for instances that use richdocumentscode, so I'd rather silence them. The cronjob would still trigger logging of potential errors then.

Will probably look into refactoring that part tomorrow to get rid of those calls.

This will add some abstraction layer for cached request data as used by
capabilities and discovery endpoints. By default it will always return
the cached data which will never expire (backed by a file in app data in
case the memory cache vanishes).

Signed-off-by: Julius Härtl <jus@bitgrid.net>
$isCODEInstalled = $this->appManager->isEnabledForUser($CODEAppID);
$isCODEEnabled = strpos($this->config->getAppValue('richdocuments', 'wopi_url'), 'proxy.php?req=') !== false;
$shouldRecheckCODECapabilities = $isCODEInstalled && $isCODEEnabled && ($this->capabilities === null || count($this->capabilities) === 0);
if ($this->capabilities === null || $shouldRecheckCODECapabilities) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is what has actually caused the issue, as the cache was only there for an hour every request after it expired triggered a new request to the capabilities endpoint, which was unreachable

Copy link
Member

@blizzz blizzz left a comment

Choose a reason for hiding this comment

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

Quick review, did not test

@juliushaertl
Copy link
Member Author

Cypress failure also on main, likely some upstream change

@juliushaertl
Copy link
Member Author

/backport to stable29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Ready to be reviewed bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants