From 91a70d65d1f779a219ae8a936cf6a42e35803dde 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 --- CHANGELOG.md | 1 + lib/Service/DaemonConfigService.php | 1 + lib/Service/ExAppService.php | 7 +++++++ tests/php/Service/DaemonConfigServiceTest.php | 15 +++++++++++++-- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3e2b17b..d8893722 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - The ExApp proxy also applies a stricter route that matches the path as an ExApp may read it, as HaRP 0.4.8 does. #1182 - The ExApp proxy returns an ExApp's redirect to the browser instead of following it, as HaRP does. #1195 - `occ app_api:app:unregister --rm-data` also removes the volume of a Kubernetes ExApp whose deployment is already gone. #1130 +- ExApps use the changed settings of their deploy daemon, such as a new HaRP shared key, right away instead of cached old ones. #1205 ## [34.0.0] diff --git a/lib/Service/DaemonConfigService.php b/lib/Service/DaemonConfigService.php index 6833912b..c66b96ce 100644 --- a/lib/Service/DaemonConfigService.php +++ b/lib/Service/DaemonConfigService.php @@ -242,6 +242,7 @@ public function updateDaemonConfig(DaemonConfig $daemonConfig, DaemonConfig $pre $this->logger->error('Failed to update DaemonConfig. Error: ' . $e->getMessage(), ['exception' => $e]); return null; } + $this->exAppService->resetExAppsCache(); $changedSettings = $this->getChangedSettings($previousDaemonConfig, $daemonConfig); if ($changedSettings !== []) { $parameters = [ diff --git a/lib/Service/ExAppService.php b/lib/Service/ExAppService.php index 4eb3bdce..42575c61 100644 --- a/lib/Service/ExAppService.php +++ b/lib/Service/ExAppService.php @@ -476,6 +476,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 4cba0a99..fc0f51d6 100644 --- a/tests/php/Service/DaemonConfigServiceTest.php +++ b/tests/php/Service/DaemonConfigServiceTest.php @@ -317,7 +317,7 @@ public function testValidateNewSecretDoesNotWarnAboutAGeneratedSecret(): void { self::assertNull($result); } - private function createServiceWithMapper(DaemonConfigMapper $mapper): DaemonConfigService { + private function createServiceWithMapper(DaemonConfigMapper $mapper, ?ExAppService $exAppService = null): DaemonConfigService { $crypto = $this->createMock(ICrypto::class); $crypto->method('encrypt')->willReturnCallback(static fn (string $value): string => 'encrypted:' . $value); // Ciphertexts in these tests are `encrypted::`, so the same secret can have different ciphertexts @@ -325,7 +325,7 @@ private function createServiceWithMapper(DaemonConfigMapper $mapper): DaemonConf return new DaemonConfigService( $this->createMock(LoggerInterface::class), $mapper, - $this->createMock(ExAppService::class), + $exAppService ?? $this->createMock(ExAppService::class), $crypto, $this->auditLogger, ); @@ -447,6 +447,17 @@ public function testUpdateDaemonConfigDoesNotLogADatabaseError(): void { self::assertNull($this->createServiceWithMapper($mapper)->updateDaemonConfig($daemonConfig, clone $daemonConfig)); } + 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'); + $daemonConfig = new DaemonConfig(['name' => 'harp_proxy', 'deploy_config' => ['haproxy_password' => 'encrypted:iv2:new_secret']]); + $previous = new DaemonConfig(['name' => 'harp_proxy', 'deploy_config' => ['haproxy_password' => 'encrypted:iv1:old_secret']]); + + $this->createServiceWithMapper($mapper, $exAppService)->updateDaemonConfig($daemonConfig, $previous); + } + public static function defaultDaemonProvider(): array { return [ 'set' => ['harp_proxy', 'AppAPI setting %s was changed to %s', ['key' => 'default_daemon_config', 'value' => 'harp_proxy']],