summaryrefslogtreecommitdiffstats
path: root/apps/federation/lib
diff options
context:
space:
mode:
authorPablo Zimdahl <pablo@nextcloud.com>2024-08-22 10:22:30 +0200
committerAndy Scherzinger <info@andy-scherzinger.de>2024-08-22 19:01:42 +0200
commit7492f7c7cb443c46254165e828fab07ef47fc272 (patch)
tree1712e984c82ebb6235e7b4ac5f67ee98193d7cb2 /apps/federation/lib
parent91649f6f39315fd10d70c4dbaef82d45392cc124 (diff)
downloadnextcloud-server-7492f7c7cb443c46254165e828fab07ef47fc272.tar.gz
nextcloud-server-7492f7c7cb443c46254165e828fab07ef47fc272.zip
fix(federation): always set server status to OK after successful runs
Previously if a server status got set to failure, it stayed that way until an addressbook-sync found changes. Now the server status is set to OK after each successful sync check (if that's not the case already), regardless of addressbook changes. This change also includes two new logging statements, which could help next time someone debugs this. Signed-off-by: Pablo Zimdahl <pablo@nextcloud.com>
Diffstat (limited to 'apps/federation/lib')
-rw-r--r--apps/federation/lib/BackgroundJob/GetSharedSecret.php1
-rw-r--r--apps/federation/lib/BackgroundJob/RequestSharedSecret.php1
-rw-r--r--apps/federation/lib/SyncFederationAddressBooks.php4
3 files changed, 6 insertions, 0 deletions
diff --git a/apps/federation/lib/BackgroundJob/GetSharedSecret.php b/apps/federation/lib/BackgroundJob/GetSharedSecret.php
index f07e0d8c2a7..1a23d58a7d1 100644
--- a/apps/federation/lib/BackgroundJob/GetSharedSecret.php
+++ b/apps/federation/lib/BackgroundJob/GetSharedSecret.php
@@ -90,6 +90,7 @@ class GetSharedSecret extends Job {
// kill job after 30 days of trying
$deadline = $currentTime - $this->maxLifespan;
if ($created < $deadline) {
+ $this->logger->warning("The job to get the shared secret job is too old and gets stopped now without retention. Setting server status of '{$target}' to failure.");
$this->retainJob = false;
$this->trustedServers->setServerStatus($target, TrustedServers::STATUS_FAILURE);
return;
diff --git a/apps/federation/lib/BackgroundJob/RequestSharedSecret.php b/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
index 07243f5c94d..a1d0d2b0df0 100644
--- a/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
+++ b/apps/federation/lib/BackgroundJob/RequestSharedSecret.php
@@ -93,6 +93,7 @@ class RequestSharedSecret extends Job {
// kill job after 30 days of trying
$deadline = $currentTime - $this->maxLifespan;
if ($created < $deadline) {
+ $this->logger->warning("The job to request the shared secret job is too old and gets stopped now without retention. Setting server status of '{$target}' to failure.");
$this->retainJob = false;
$this->trustedServers->setServerStatus($target, TrustedServers::STATUS_FAILURE);
return;
diff --git a/apps/federation/lib/SyncFederationAddressBooks.php b/apps/federation/lib/SyncFederationAddressBooks.php
index 46a6a8c40a5..1b47c92db1a 100644
--- a/apps/federation/lib/SyncFederationAddressBooks.php
+++ b/apps/federation/lib/SyncFederationAddressBooks.php
@@ -60,6 +60,10 @@ class SyncFederationAddressBooks {
$this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK, $newToken);
} else {
$this->logger->debug("Sync Token for $url unchanged from previous sync");
+ // The server status might have been changed to a failure status in previous runs.
+ if ($this->dbHandler->getServerStatus($url) !== TrustedServers::STATUS_OK) {
+ $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK);
+ }
}
} catch (\Exception $ex) {
if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) {