Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Service/DaemonConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions lib/Service/ExAppService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions tests/php/Service/DaemonConfigServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']]));
}
}
Loading