Remove generation status sync

This commit is contained in:
Matej Bačo
2025-09-12 14:44:06 +02:00
parent 4c4892a214
commit b4a49107f1
3 changed files with 1 additions and 48 deletions
-1
View File
@@ -9,7 +9,6 @@ class Certificate extends Event
{
public const ACTION_VERIFICATION = 'verification';
public const ACTION_GENERATION = 'generation';
public const ACTION_GENERATION_SYNC = 'generation_sync';
protected bool $skipRenewCheck = false;
protected ?Document $domain = null;
+1 -44
View File
@@ -38,8 +38,7 @@ class Maintenance extends Action
Console::success(APP_NAME . ' maintenance process v1 has started');
$interval = (int) System::getEnv('_APP_MAINTENANCE_INTERVAL', '86400'); // 1 day
$intervalRuleVerification = (int) System::getEnv('_APP_MAINTENANCE_INTERVAL_RULE_VERIFICATION', '120'); // 2 minutes
$intervalRuleGeneration = (int) System::getEnv('_APP_MAINTENANCE_INTERVAL_RULE_GENERATION', '60'); // 1 minute
$intervalRuleVerification = (int) System::getEnv('_APP_MAINTENANCE_INTERVAL_RULE_VERIFICATION', '60'); // 1 minute
$usageStatsRetentionHourly = (int) System::getEnv('_APP_MAINTENANCE_RETENTION_USAGE_HOURLY', '8640000'); //100 days
$cacheRetention = (int) System::getEnv('_APP_MAINTENANCE_RETENTION_CACHE', '2592000'); // 30 days
@@ -107,12 +106,6 @@ class Maintenance extends Action
$this->checkRuleVerification($dbForPlatform, $queueForCertificates);
}, $intervalRuleVerification);
});
\go(function () use ($dbForPlatform, $queueForCertificates, $intervalRuleGeneration) {
Console::loop(function () use ($dbForPlatform, $queueForCertificates) {
$this->checkRuleGeneration($dbForPlatform, $queueForCertificates);
}, $intervalRuleGeneration);
});
}
private function notifyDeleteConnections(Delete $queueForDeletes): void
@@ -159,42 +152,6 @@ class Maintenance extends Action
}
}
private function checkRuleGeneration(Database $dbForPlatform, Certificate $queueForCertificate): void
{
$time = DatabaseDateTime::now();
$oldestToCheck = new DateTime();
$oldestToCheck->sub(new DateInterval('PT72H')); // -3 days
$rules = $dbForPlatform->find('rules', [
Query::createdAfter(DatabaseDateTime::format($oldestToCheck)), // max 3 days old
Query::equal('status', ['verifying']), // waiting for verification to finish
Query::orderAsc('$updatedAt'), // Pick the ones waiting for another attempt for longest
Query::limit(10), // Reasonable pagination limit, processable within a minute
]);
if (\count($rules) > 0) {
Console::info("[{$time}] Found " . \count($rules) . " rules under generation, scheduling jobs.");
foreach ($rules as $rule) {
if ($rule->getAttribute('region') !== System::getEnv('_APP_REGION', 'default')) {
continue;
}
$queueForCertificate
->setDomain(new Document([
'domain' => $rule->getAttribute('domain'),
'domainType' => $rule->getAttribute('deploymentResourceType', $rule->getAttribute('type')),
]))
->setAction(Certificate::ACTION_GENERATION_SYNC)
->trigger();
}
} else {
// Silenced because interval makes it too often
// Console::log("[{$time}] No rules for checking generation progress.");
}
}
private function renewCertificates(Database $dbForPlatform, Certificate $queueForCertificate): void
{
$time = DatabaseDateTime::now();
@@ -113,9 +113,6 @@ class Certificates extends Action
case Certificate::ACTION_VERIFICATION:
$this->executeVerification($domain, $dbForPlatform, $log, $queueForCertificates, $verificationDomainFunction, $verificationDomainApi);
break;
case Certificate::ACTION_GENERATION_SYNC:
$this->executeGenerationSync();
break;
default:
throw new Exception('Invalid action . ' . $action);
}