Skip to content

Commit 53fcce3

Browse files
committed
allow manual-install to use harp
Signed-off-by: Anupam Kumar <[email protected]>
1 parent aa325fd commit 53fcce3

File tree

7 files changed

+239
-180
lines changed

7 files changed

+239
-180
lines changed

lib/Command/Daemon/RegisterDaemon.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ protected function configure(): void {
4949
$this->addOption('harp_shared_key', null, InputOption::VALUE_REQUIRED, 'HaRP shared key for secure communication between HaRP and AppAPI');
5050
$this->addOption('harp_docker_socket_port', null, InputOption::VALUE_REQUIRED, '\'remotePort\' of the FRP client of the remote docker socket proxy. There is one included in the harp container so this can be skipped for default setups.', '24000');
5151

52+
$this->addUsage('harp_proxy_docker "Harp Proxy (Docker)" "docker-install" "http" "appapi-harp:8780" "http://nextcloud.local" --net nextcloud --harp --harp_frp_address "appapi-harp:8782" --harp_shared_key "some_very_secure_password" --set-default --compute_device=cuda');
53+
$this->addUsage('harp_proxy_host "Harp Proxy (Host)" "docker-install" "http" "localhost:8780" "http://nextcloud.local" --harp --harp_frp_address "localhost:8782" --harp_shared_key "some_very_secure_password" --set-default --compute_device=cuda');
54+
$this->addUsage('manual_install_harp "Harp Manual Install" "manual-install" "http" "appapi-harp:8780" "http://nextcloud.local" --net nextcloud --harp --harp_frp_address "appapi-harp:8782" --harp_shared_key "some_very_secure_password"');
55+
$this->addUsage('docker_install "Docker Socket Proxy" "docker-install" "http" "nextcloud-appapi-dsp:2375" "http://nextcloud.local" --net=nextcloud --set-default --compute_device=cuda');
5256
$this->addUsage('manual_install "Manual Install" "manual-install" "http" null "http://nextcloud.local"');
5357
$this->addUsage('local_docker "Docker Local" "docker-install" "http" "/var/run/docker.sock" "http://nextcloud.local" --net=nextcloud');
5458
$this->addUsage('local_docker "Docker Local" "docker-install" "http" "/var/run/docker.sock" "http://nextcloud.local" --net=nextcloud --set-default --compute_device=cuda');
55-
$this->addUsage('docker_install "Docker Socket Proxy" "docker-install" "http" "nextcloud-appapi-dsp:2375" "http://nextcloud.local" --net=nextcloud --set-default --compute_device=cuda');
56-
$this->addUsage('harp_proxy "Harp Proxy with DSP" "docker-install" "http" "appapi-harp:8780" "http://nextcloud.local" --harp --harp_frp_address "localhost:8782" --harp_shared_key "some_very_secure_password" --set-default --compute_device=cuda');
5759
}
5860

5961
protected function execute(InputInterface $input, OutputInterface $output): int {
@@ -73,11 +75,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7375
$output->writeln('Value error: Manual-install daemon supports only `http` protocol.');
7476
return 1;
7577
}
76-
// todo:
77-
if ($acceptsDeployId === 'manual-install' && $isHarp) {
78-
$output->writeln('Value error: Manual-install daemon does not support HaRP.');
79-
return 1;
80-
}
8178
if ($isHarp && !$input->getOption('harp_shared_key')) {
8279
$output->writeln('Value error: HaRP enabled daemon requires `harp_shared_key` option.');
8380
return 1;

lib/Controller/DaemonConfigController.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ public function unregisterDaemonConfig(string $name): Response {
121121

122122
public function verifyDaemonConnection(string $name): Response {
123123
$daemonConfig = $this->daemonConfigService->getDaemonConfigByName($name);
124-
if ($daemonConfig->getAcceptsDeployId() !== $this->dockerActions->getAcceptsDeployId()) {
125-
return new JSONResponse([
126-
'error' => sprintf('Only "%s" is supported', $this->dockerActions->getAcceptsDeployId()),
127-
]);
128-
}
129124
$this->dockerActions->initGuzzleClient($daemonConfig);
130125
$dockerDaemonAccessible = $this->dockerActions->ping($this->dockerActions->buildDockerUrl($daemonConfig));
131126
return new JSONResponse([
@@ -165,11 +160,6 @@ public function checkDaemonConnection(array $daemonParams): Response {
165160
'host' => $daemonParams['host'],
166161
'deploy_config' => $daemonParams['deploy_config'],
167162
]);
168-
if ($daemonConfig->getAcceptsDeployId() !== $this->dockerActions->getAcceptsDeployId()) {
169-
return new JSONResponse([
170-
'error' => sprintf('Only "%s" is supported', $this->dockerActions->getAcceptsDeployId()),
171-
]);
172-
}
173163
$this->dockerActions->initGuzzleClient($daemonConfig);
174164
$dockerDaemonAccessible = $this->dockerActions->ping($this->dockerActions->buildDockerUrl($daemonConfig));
175165
return new JSONResponse([

lib/DeployActions/ManualActions.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ public function buildDeployEnvs(array $params, array $deployConfig): array {
4747
public function resolveExAppUrl(
4848
string $appId, string $protocol, string $host, array $deployConfig, int $port, array &$auth
4949
): string {
50+
if (boolval($deployConfig['harp'] ?? false)) {
51+
$url = rtrim($deployConfig['nextcloud_url'], '/');
52+
if (str_ends_with($url, '/index.php')) {
53+
$url = substr($url, 0, -10);
54+
}
55+
return sprintf('%s/exapps/%s', $url, $appId);
56+
}
57+
5058
$auth = [];
5159
if (isset($deployConfig['additional_options']['OVERRIDE_APP_HOST']) &&
5260
$deployConfig['additional_options']['OVERRIDE_APP_HOST'] !== ''

lib/Service/AppAPIService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ public function removeExAppsByDaemonConfigName(DaemonConfig $daemonConfig): void
713713
}
714714
foreach ($targetDaemonExApps as $exApp) {
715715
$this->disableExApp($exApp);
716-
if ($daemonConfig->getAcceptsDeployId() === 'docker-install') {
716+
if ($daemonConfig->getAcceptsDeployId() === $this->dockerActions->getAcceptsDeployId()) {
717717
$this->dockerActions->initGuzzleClient($daemonConfig);
718718
$this->dockerActions->removeContainer($this->dockerActions->buildDockerUrl($daemonConfig), $this->dockerActions->buildExAppContainerName($exApp->getAppid()));
719719
$this->dockerActions->removeVolume($this->dockerActions->buildDockerUrl($daemonConfig), $this->dockerActions->buildExAppVolumeName($exApp->getAppid()));

lib/Service/ExAppService.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ public function getAppInfo(string $appId, ?string $infoXml, ?string $jsonInfo, ?
265265
$extractedDir = '';
266266
if ($jsonInfo !== null) {
267267
$appInfo = json_decode($jsonInfo, true);
268+
if ($appInfo === false) {
269+
return ['error' => 'Invalid app info JSON'];
270+
}
268271
# fill 'id' if it is missing(this field was called `appid` in previous versions in json)
269272
$appInfo['id'] = $appInfo['id'] ?? $appId;
270273
# during manual install JSON can have all values at root level

0 commit comments

Comments
 (0)