From 261059619f6b38487bc30834cb641d70354944f7 Mon Sep 17 00:00:00 2001 From: Oleksandr Piskun Date: Fri, 13 Nov 2026 09:18:47 +0000 Subject: [PATCH] fix(daemon): drop the cached ExApps when a deploy daemon is updated Signed-off-by: Oleksandr Piskun --- lib/Service/DaemonConfigService.php | 4 +++- lib/Service/ExAppService.php | 7 +++++++ tests/php/Service/DaemonConfigServiceTest.php | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/Service/DaemonConfigService.php b/lib/Service/DaemonConfigService.php index 7050be19b..a6b8c6534 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 48c7e4264..40df22f8c 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 5d0f4361e..c15ab0f6c 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']])); + } }