Skip to content
Open
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
19 changes: 13 additions & 6 deletions lib/Controller/DaemonConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OCA\AppAPI\AppInfo\Application;
use OCA\AppAPI\Db\DaemonConfig;
use OCA\AppAPI\DeployActions\DockerActions;
use OCA\AppAPI\DeployActions\KubernetesActions;
use OCA\AppAPI\ResponseDefinitions;
use OCA\AppAPI\Service\AppAPIService;
use OCA\AppAPI\Service\DaemonConfigService;
Expand Down Expand Up @@ -41,6 +42,7 @@ public function __construct(
private readonly IAppConfig $appConfig,
private readonly DaemonConfigService $daemonConfigService,
private readonly DockerActions $dockerActions,
private readonly KubernetesActions $kubernetesActions,
private readonly AppAPIService $service,
private readonly ExAppService $exAppService,
private readonly IL10N $l10n,
Expand Down Expand Up @@ -171,10 +173,8 @@ public function unregisterDaemonConfig(string $name): Response {
*/
public function verifyDaemonConnection(string $name): Response {
$daemonConfig = $this->daemonConfigService->getDaemonConfigByName($name);
$this->dockerActions->initGuzzleClient($daemonConfig);
$dockerDaemonAccessible = $this->dockerActions->ping($this->dockerActions->buildDockerUrl($daemonConfig));
return new JSONResponse([
'success' => $dockerDaemonAccessible,
'success' => $this->daemonAccessible($daemonConfig),
]);
}

Expand Down Expand Up @@ -219,13 +219,20 @@ public function checkDaemonConnection(array $daemonParams): Response {
'host' => $daemonParams['host'],
'deploy_config' => $daemonParams['deploy_config'],
]);
$this->dockerActions->initGuzzleClient($daemonConfig);
$dockerDaemonAccessible = $this->dockerActions->ping($this->dockerActions->buildDockerUrl($daemonConfig));
return new JSONResponse([
'success' => $dockerDaemonAccessible,
'success' => $this->daemonAccessible($daemonConfig),
]);
}

private function daemonAccessible(DaemonConfig $daemonConfig): bool {
if ($daemonConfig->getAcceptsDeployId() === KubernetesActions::DEPLOY_ID) {
$this->kubernetesActions->initGuzzleClient($daemonConfig);
return $this->kubernetesActions->ping($daemonConfig) === '';
}
$this->dockerActions->initGuzzleClient($daemonConfig);
return $this->dockerActions->ping($this->dockerActions->buildDockerUrl($daemonConfig));
}

/**
* Start a test deployment on a deploy daemon
*
Expand Down
19 changes: 15 additions & 4 deletions lib/Service/ExAppsPageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace OCA\AppAPI\Service;

use OCA\AppAPI\DeployActions\DockerActions;
use OCA\AppAPI\DeployActions\KubernetesActions;
use OCA\AppAPI\Fetcher\ExAppFetcher;
use OCP\App\IAppManager;
use OCP\AppFramework\Services\IInitialState;
Expand All @@ -23,6 +24,7 @@ public function __construct(
private ExAppFetcher $exAppFetcher,
private DaemonConfigService $daemonConfigService,
private DockerActions $dockerActions,
private KubernetesActions $kubernetesActions,
private IAppConfig $appConfig,
private IAppManager $appManager,
private LoggerInterface $logger,
Expand Down Expand Up @@ -50,10 +52,19 @@ public function provideAppApiState(IInitialState $initialState): void {
if ($daemonConfig !== null) {
$defaultDaemonConfig = $daemonConfig->jsonSerialize();
unset($defaultDaemonConfig['deploy_config']['haproxy_password']);
$this->dockerActions->initGuzzleClient($daemonConfig);
$daemonConfigAccessible = $this->dockerActions->ping($this->dockerActions->buildDockerUrl($daemonConfig));
if (!$daemonConfigAccessible) {
$this->logger->warning(sprintf('Deploy daemon "%s" is not accessible by Nextcloud. Please check its configuration', $daemonConfig->getName()));
if ($daemonConfig->getAcceptsDeployId() === KubernetesActions::DEPLOY_ID) {
$this->kubernetesActions->initGuzzleClient($daemonConfig);
$pingError = $this->kubernetesActions->ping($daemonConfig);
$daemonConfigAccessible = $pingError === '';
if (!$daemonConfigAccessible) {
$this->logger->warning(sprintf('Deploy daemon "%s" is not accessible by Nextcloud: %s', $daemonConfig->getName(), $pingError));
}
} else {
$this->dockerActions->initGuzzleClient($daemonConfig);
$daemonConfigAccessible = $this->dockerActions->ping($this->dockerActions->buildDockerUrl($daemonConfig));
if (!$daemonConfigAccessible) {
$this->logger->warning(sprintf('Deploy daemon "%s" is not accessible by Nextcloud. Please check its configuration', $daemonConfig->getName()));
}
}
}
}
Expand Down
22 changes: 17 additions & 5 deletions lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use OCA\AppAPI\AppInfo\Application;
use OCA\AppAPI\DeployActions\DockerActions;
use OCA\AppAPI\DeployActions\KubernetesActions;
use OCA\AppAPI\Service\DaemonConfigService;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
Expand All @@ -25,6 +26,7 @@ public function __construct(
private DaemonConfigService $daemonConfigService,
private IAppConfig $appConfig,
private DockerActions $dockerActions,
private KubernetesActions $kubernetesActions,
private LoggerInterface $logger,
) {
}
Expand All @@ -41,11 +43,21 @@ public function getForm(): TemplateResponse {
if ($defaultDaemonConfigName !== '') {
$daemonConfig = $this->daemonConfigService->getDaemonConfigByName($defaultDaemonConfigName);
if ($daemonConfig !== null) {
$this->dockerActions->initGuzzleClient($daemonConfig);
$daemonConfigAccessible = $this->dockerActions->ping($this->dockerActions->buildDockerUrl($daemonConfig));
$adminInitialData['daemon_config_accessible'] = $daemonConfigAccessible;
if (!$daemonConfigAccessible) {
$this->logger->error(sprintf('Deploy daemon "%s" is not accessible by Nextcloud. Please check its configuration', $daemonConfig->getName()));
if ($daemonConfig->getAcceptsDeployId() === KubernetesActions::DEPLOY_ID) {
$this->kubernetesActions->initGuzzleClient($daemonConfig);
$pingError = $this->kubernetesActions->ping($daemonConfig);
$daemonConfigAccessible = $pingError === '';
$adminInitialData['daemon_config_accessible'] = $daemonConfigAccessible;
if (!$daemonConfigAccessible) {
$this->logger->error(sprintf('Deploy daemon "%s" is not accessible by Nextcloud: %s', $daemonConfig->getName(), $pingError));
}
Comment on lines +51 to +53

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use a warning for an unreachable Kubernetes daemon.

Line 52 emits an error-level log for the same reachability state that lib/Service/ExAppsPageService.php records as a warning. The PR objective specifies warning logging for inaccessible daemons. Use warning() here to keep both UI flows consistent.

Proposed fix
- $this->logger->error(sprintf('Deploy daemon "%s" is not accessible by Nextcloud: %s', $daemonConfig->getName(), $pingError));
+ $this->logger->warning(sprintf('Deploy daemon "%s" is not accessible by Nextcloud: %s', $daemonConfig->getName(), $pingError));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!$daemonConfigAccessible) {
$this->logger->error(sprintf('Deploy daemon "%s" is not accessible by Nextcloud: %s', $daemonConfig->getName(), $pingError));
}
if (!$daemonConfigAccessible) {
$this->logger->warning(sprintf('Deploy daemon "%s" is not accessible by Nextcloud: %s', $daemonConfig->getName(), $pingError));
}

} else {
$this->dockerActions->initGuzzleClient($daemonConfig);
$daemonConfigAccessible = $this->dockerActions->ping($this->dockerActions->buildDockerUrl($daemonConfig));
$adminInitialData['daemon_config_accessible'] = $daemonConfigAccessible;
if (!$daemonConfigAccessible) {
$this->logger->error(sprintf('Deploy daemon "%s" is not accessible by Nextcloud. Please check its configuration', $daemonConfig->getName()));
}
}
}
}
Expand Down