diff --git a/lib/Service/DaemonConfigService.php b/lib/Service/DaemonConfigService.php index 7050be19..a6b8c653 100644 --- a/lib/Service/DaemonConfigService.php +++ b/lib/Service/DaemonConfigService.php @@ -168,11 +168,13 @@ public function updateDaemonConfig(DaemonConfig $daemonConfig): ?DaemonConfig { } try { - return $this->mapper->update($daemonConfig); + $daemonConfig = $this->mapper->update($daemonConfig); } catch (Exception $e) { $this->logger->error('Failed to update DaemonConfig. Error: ' . $e->getMessage(), ['exception' => $e]); return null; } + $this->exAppService->resetExAppsCache(); + return $daemonConfig; } public function addDockerRegistry(DaemonConfig $daemonConfig, array $registryMap): DaemonConfig|array|null { diff --git a/lib/Service/ExAppService.php b/lib/Service/ExAppService.php index 48c7e426..40df22f8 100644 --- a/lib/Service/ExAppService.php +++ b/lib/Service/ExAppService.php @@ -429,6 +429,13 @@ public function getExApps(): array { } } + /** + * Drop the cached list of ExApps, which also holds the settings of their deploy daemons + */ + public function resetExAppsCache(): void { + $this->cache?->remove('/ex_apps'); + } + public function registerExAppRoutes(ExApp $exApp, array $routes): ?ExApp { try { $this->exAppMapper->registerExAppRoutes($exApp, $routes); diff --git a/tests/php/Service/DaemonConfigServiceTest.php b/tests/php/Service/DaemonConfigServiceTest.php index 5d0f4361..c15ab0f6 100644 --- a/tests/php/Service/DaemonConfigServiceTest.php +++ b/tests/php/Service/DaemonConfigServiceTest.php @@ -212,4 +212,19 @@ public function testRemoveDockerRegistryToleratesMalformedEntries(): void { self::assertInstanceOf(DaemonConfig::class, $result); self::assertSame(['junk', ['from' => 'quay.io'], $second], $result->getDeployConfig()['registries']); } + + public function testUpdateDaemonConfigResetsTheExAppsCache(): void { + $mapper = $this->createMock(DaemonConfigMapper::class); + $mapper->method('update')->willReturnArgument(0); + $exAppService = $this->createMock(ExAppService::class); + $exAppService->expects(self::once())->method('resetExAppsCache'); + $service = new DaemonConfigService( + $this->createMock(LoggerInterface::class), + $mapper, + $exAppService, + $this->createMock(ICrypto::class), + ); + + $service->updateDaemonConfig(new DaemonConfig(['name' => 'harp_proxy', 'deploy_config' => ['haproxy_password' => 'new_secret']])); + } }