-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes: #122 1. Made sending the "init" request in a separate process 2. If "init" request fails with STATUS_NOT_IMPLEMENTED or STATUS_NOT_FOUND sets the progress to 100 3. Added `wait-finish` optional parameter to `app_api:app:register` occ command. What is missing: - [x] Global option: how long the "/init" request can be proceed. - [x] Docs update for this - [x] Update nc_py_api CI for this - [x] Added test for registering ExApp that does not have "/init" endpoint. This allows to implement ExApp without "/init" endpoint and made it optional. --------- Signed-off-by: Alexander Piskun <[email protected]> Signed-off-by: Andrey Borysenko <[email protected]> Co-authored-by: Andrey Borysenko <[email protected]>
- Loading branch information
1 parent
9ce6fc3
commit ec0324b
Showing
15 changed files
with
390 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OCA\AppAPI\BackgroundJob; | ||
|
||
use OCA\AppAPI\AppInfo\Application; | ||
use OCA\AppAPI\Db\ExAppMapper; | ||
use OCA\AppAPI\Service\AppAPIService; | ||
use OCP\AppFramework\Utility\ITimeFactory; | ||
use OCP\BackgroundJob\TimedJob; | ||
use OCP\DB\Exception; | ||
use OCP\IConfig; | ||
|
||
class ExAppInitStatusCheckJob extends TimedJob { | ||
private const everyMinuteInterval = 60; | ||
|
||
public function __construct( | ||
ITimeFactory $time, | ||
private ExAppMapper $mapper, | ||
private AppAPIService $service, | ||
private IConfig $config, | ||
) { | ||
parent::__construct($time); | ||
|
||
$this->setInterval(self::everyMinuteInterval); | ||
} | ||
|
||
protected function run($argument): void { | ||
// Iterate over all ExApp and check for status.init_start_time if it is older than ex_app_init_timeout minutes | ||
// set status.progress=0 and status.error message with timeout error | ||
try { | ||
$exApps = $this->mapper->findAll(); | ||
$initTimeoutMinutes = intval($this->config->getAppValue(Application::APP_ID, 'ex_app_init_timeout', '40')); | ||
foreach ($exApps as $exApp) { | ||
$status = json_decode($exApp->getStatus(), true); | ||
if (!isset($status['init_start_time'])) { | ||
continue; | ||
} | ||
if (($status['init_start_time'] + $initTimeoutMinutes * 60) > time()) { | ||
$this->service->setAppInitProgress( | ||
$exApp->getAppId(), 0, sprintf('ExApp %s initialization timed out (%sm)', $exApp->getAppid(), $initTimeoutMinutes * 60) | ||
); | ||
} | ||
} | ||
} catch (Exception) { | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OCA\AppAPI\Command\ExApp; | ||
|
||
use OCA\AppAPI\Service\AppAPIService; | ||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class DispatchInit extends Command { | ||
|
||
public function __construct( | ||
private AppAPIService $service, | ||
) { | ||
parent::__construct(); | ||
} | ||
|
||
protected function configure(): void { | ||
$this->setHidden(true); | ||
$this->setName('app_api:app:dispatch_init'); | ||
$this->setDescription('Internal command to dispatch init command'); | ||
|
||
$this->addArgument('appid', InputArgument::REQUIRED); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output): int { | ||
$appId = $input->getArgument('appid'); | ||
$exApp = $this->service->getExApp($appId); | ||
if ($exApp === null) { | ||
$output->writeln(sprintf('ExApp %s not found. Failed to dispatch init.', $appId)); | ||
return 1; | ||
} | ||
$this->service->dispatchExAppInitInternal($exApp); | ||
return 0; | ||
} | ||
} |
Oops, something went wrong.