mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
refactor: pass build timeout when creating deployments
This commit is contained in:
1 parent
87feca2757
commit
f09dae08db
18 files changed
+74
-29
No files matched your search
@@ -207,8 +207,9 @@ return function (Container $context): void {
|
||||
// Builds a Deployments bound to a given project — webhook handlers resolve
|
||||
// their tenant projects mid-request, after this container is initialized.
|
||||
$context->set('deploymentsFactory', function (Jobs $jobs, array $platform) {
|
||||
return fn (Database $dbForProject, Document $project): Deployments => new Deployments($jobs, $dbForProject, $project, $platform, (int) System::getEnv('_APP_COMPUTE_BUILD_TIMEOUT', 900));
|
||||
return fn (Database $dbForProject, Document $project): Deployments => new Deployments($jobs, $dbForProject, $project, $platform);
|
||||
}, ['jobs', 'platform']);
|
||||
$context->set('buildTimeout', fn () => (int) System::getEnv('_APP_COMPUTE_BUILD_TIMEOUT', 900));
|
||||
$context->set('deployments', fn (callable $deploymentsFactory, Database $dbForProject, Document $project) => $deploymentsFactory($dbForProject, $project), ['deploymentsFactory', 'dbForProject', 'project']);
|
||||
$context->set('eventProcessor', fn () => new EventProcessor(), []);
|
||||
$context->set('databaseFactory', fn (Group $pools, Cache $cache, Authorization $authorization) => new DatabaseFactory(
|
||||
|
||||
@@ -174,7 +174,7 @@ return function (Container $container): void {
|
||||
// Only the Builds worker uses this, handing template-into-repo pushes to
|
||||
// the jobs-service.
|
||||
$container->set('deployments', function (Jobs $jobs, Database $dbForProject, Document $project, array $platform) {
|
||||
return new Deployments($jobs, $dbForProject, $project, $platform, (int) System::getEnv('_APP_COMPUTE_BUILD_TIMEOUT', 900));
|
||||
return new Deployments($jobs, $dbForProject, $project, $platform);
|
||||
}, ['jobs', 'dbForProject', 'project', 'platform']);
|
||||
|
||||
$container->set('getAudit', function (Database $dbForPlatform, callable $getProjectDB) {
|
||||
|
||||
@@ -62,7 +62,6 @@ readonly class Deployments
|
||||
protected Database $dbForProject,
|
||||
protected Document $project,
|
||||
private array $platform,
|
||||
private int $timeout,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -99,9 +98,9 @@ readonly class Deployments
|
||||
* queued is left canceled and never dispatched. Returns the persisted,
|
||||
* updated deployment.
|
||||
*/
|
||||
public function createFromUpload(Document $resource, Document $deployment): Document
|
||||
public function createFromUpload(Document $resource, Document $deployment, int $timeout): Document
|
||||
{
|
||||
return $this->submit($resource, $deployment, null);
|
||||
return $this->submit($resource, $deployment, $timeout, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,6 +113,7 @@ readonly class Deployments
|
||||
public function createFromRef(
|
||||
Document $resource,
|
||||
Document $deployment,
|
||||
int $timeout,
|
||||
string $owner,
|
||||
string $repository,
|
||||
string $type,
|
||||
@@ -125,7 +125,7 @@ readonly class Deployments
|
||||
// tag; codeload only understands one ref per tarball, not a range.
|
||||
$url = "https://codeload.github.com/{$owner}/{$repository}/tar.gz/{$reference}";
|
||||
|
||||
return $this->submit($resource, $deployment, ['url' => $url, 'subdir' => $rootDirectory]);
|
||||
return $this->submit($resource, $deployment, $timeout, ['url' => $url, 'subdir' => $rootDirectory]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,11 +139,12 @@ readonly class Deployments
|
||||
public function createFromUrl(
|
||||
Document $resource,
|
||||
Document $deployment,
|
||||
int $timeout,
|
||||
string $url,
|
||||
string $rootDirectory = '',
|
||||
array $headers = [],
|
||||
): Document {
|
||||
return $this->submit($resource, $deployment, ['url' => $url, 'subdir' => $rootDirectory, 'headers' => $headers]);
|
||||
return $this->submit($resource, $deployment, $timeout, ['url' => $url, 'subdir' => $rootDirectory, 'headers' => $headers]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,6 +158,7 @@ readonly class Deployments
|
||||
public function createFromVcs(
|
||||
Document $resource,
|
||||
Document $deployment,
|
||||
int $timeout,
|
||||
Git $vcs,
|
||||
string $owner,
|
||||
string $repository,
|
||||
@@ -167,13 +169,14 @@ readonly class Deployments
|
||||
return $this->createFromUrl(
|
||||
$resource,
|
||||
$deployment,
|
||||
$timeout,
|
||||
$vcs->getRepositoryPresignedUrl($owner, $repository, $ref),
|
||||
$rootDirectory,
|
||||
$vcs->getRepositoryPresignedUrlHeaders(),
|
||||
);
|
||||
}
|
||||
|
||||
return $this->submit($resource, $deployment, [
|
||||
return $this->submit($resource, $deployment, $timeout, [
|
||||
'clone' => $vcs->getRepositoryCloneUrl($owner, $repository),
|
||||
'ref' => $ref,
|
||||
'subdir' => $rootDirectory,
|
||||
@@ -181,7 +184,7 @@ readonly class Deployments
|
||||
]);
|
||||
}
|
||||
|
||||
private function submit(Document $resource, Document $deployment, ?array $source): Document
|
||||
private function submit(Document $resource, Document $deployment, int $timeout, ?array $source): Document
|
||||
{
|
||||
// The caller may have been holding this deployment for a while (the
|
||||
// Builds worker pushes a template commit first), so its status is stale
|
||||
@@ -222,7 +225,7 @@ readonly class Deployments
|
||||
}
|
||||
|
||||
try {
|
||||
$this->jobs->create(...static::payload($this->project, $resource, $deployment, $this->platform, $this->timeout, $source));
|
||||
$this->jobs->create(...static::payload($this->project, $resource, $deployment, $this->platform, $timeout, $source));
|
||||
} catch (\Throwable $error) {
|
||||
// A refused variable key is the owner's to fix, so the build log
|
||||
// carries the actual reason; anything else stays a generic
|
||||
|
||||
@@ -94,7 +94,7 @@ class Base extends Action
|
||||
}
|
||||
}
|
||||
|
||||
public function redeployVcsFunction(Request $request, Document $function, Document $project, Document $installation, Database $dbForProject, BuildPublisher $publisherForBuilds, Document $template, Git $vcs, bool $activate, Deployments $deployments, array $platform = [], string $referenceType = 'branch', string $reference = ''): Document
|
||||
public function redeployVcsFunction(Request $request, Document $function, Document $project, Document $installation, Database $dbForProject, BuildPublisher $publisherForBuilds, Document $template, Git $vcs, bool $activate, Deployments $deployments, int $buildTimeout, array $platform = [], string $referenceType = 'branch', string $reference = ''): Document
|
||||
{
|
||||
$deploymentId = ID::unique();
|
||||
$entrypoint = $function->getAttribute('entrypoint', '');
|
||||
@@ -178,6 +178,7 @@ class Base extends Action
|
||||
$deployment = $deployments->createFromVcs(
|
||||
$function,
|
||||
$deployment,
|
||||
$buildTimeout,
|
||||
$vcs,
|
||||
$owner,
|
||||
$repositoryName,
|
||||
@@ -208,7 +209,7 @@ class Base extends Action
|
||||
return $deployment;
|
||||
}
|
||||
|
||||
public function redeployVcsSite(Request $request, Document $site, Document $project, Document $installation, Database $dbForProject, Database $dbForPlatform, BuildPublisher $publisherForBuilds, Document $template, Git $vcs, bool $activate, Authorization $authorization, Deployments $deployments, Bus $bus, array $platform, string $referenceType = 'branch', string $reference = ''): Document
|
||||
public function redeployVcsSite(Request $request, Document $site, Document $project, Document $installation, Database $dbForProject, Database $dbForPlatform, BuildPublisher $publisherForBuilds, Document $template, Git $vcs, bool $activate, Authorization $authorization, Deployments $deployments, int $buildTimeout, Bus $bus, array $platform, string $referenceType = 'branch', string $reference = ''): Document
|
||||
{
|
||||
$deploymentId = ID::unique();
|
||||
$providerInstallationId = $installation->getAttribute('providerInstallationId', '');
|
||||
@@ -405,6 +406,7 @@ class Base extends Action
|
||||
$deployment = $deployments->createFromVcs(
|
||||
$site,
|
||||
$deployment,
|
||||
$buildTimeout,
|
||||
$vcs,
|
||||
$owner,
|
||||
$repositoryName,
|
||||
|
||||
@@ -87,6 +87,7 @@ class Create extends Action
|
||||
->inject('deviceForFunctions')
|
||||
->inject('deviceForLocal')
|
||||
->inject('deployments')
|
||||
->inject('buildTimeout')
|
||||
->inject('plan')
|
||||
->inject('authorization')
|
||||
->inject('locks')
|
||||
@@ -107,6 +108,7 @@ class Create extends Action
|
||||
Device $deviceForFunctions,
|
||||
Device $deviceForLocal,
|
||||
Deployments $deployments,
|
||||
int $buildTimeout,
|
||||
array $plan,
|
||||
Authorization $authorization,
|
||||
callable $locks
|
||||
@@ -274,7 +276,7 @@ class Create extends Action
|
||||
}
|
||||
|
||||
try {
|
||||
$locks($lockKey, 600, function () use ($activate, $chunk, &$chunks, $commands, $dbForProject, $deploymentId, $deviceForFunctions, $deviceForLocal, $entrypoint, $fileSize, $fileTmpName, &$function, $path, &$metadata, $mergeUploadMetadata, $deployments, $queueForEvents, $response, $type): void {
|
||||
$locks($lockKey, 600, function () use ($buildTimeout, $activate, $chunk, &$chunks, $commands, $dbForProject, $deploymentId, $deviceForFunctions, $deviceForLocal, $entrypoint, $fileSize, $fileTmpName, &$function, $path, &$metadata, $mergeUploadMetadata, $deployments, $queueForEvents, $response, $type): void {
|
||||
$deployment = $dbForProject->getDocument('deployments', $deploymentId);
|
||||
$uploaded = 0;
|
||||
|
||||
@@ -335,7 +337,7 @@ class Create extends Action
|
||||
'activate' => $activate,
|
||||
'sourceMetadata' => $metadata,
|
||||
'type' => $type,
|
||||
]));
|
||||
]), $buildTimeout);
|
||||
} else {
|
||||
$deployment = $deployments->upload($function, $deployment->setAttributes([
|
||||
'sourceChunksUploaded' => $chunksUploaded,
|
||||
|
||||
@@ -65,6 +65,7 @@ class Create extends Action
|
||||
->inject('dbForPlatform')
|
||||
->inject('queueForEvents')
|
||||
->inject('deployments')
|
||||
->inject('buildTimeout')
|
||||
->inject('deviceForFunctions')
|
||||
->inject('vcsFactory')
|
||||
->callback($this->action(...));
|
||||
@@ -79,6 +80,7 @@ class Create extends Action
|
||||
Database $dbForPlatform,
|
||||
Event $queueForEvents,
|
||||
Deployments $deployments,
|
||||
int $buildTimeout,
|
||||
Device $deviceForFunctions,
|
||||
VcsFactory $vcsFactory,
|
||||
) {
|
||||
@@ -147,7 +149,7 @@ class Create extends Action
|
||||
]);
|
||||
|
||||
if ($hasSource) {
|
||||
$deployment = $deployments->createFromUpload($function, $deployment);
|
||||
$deployment = $deployments->createFromUpload($function, $deployment, $buildTimeout);
|
||||
} elseif ($installationId !== '') {
|
||||
$installation = $dbForPlatform->getDocument('installations', $installationId);
|
||||
if ($installation->isEmpty()) {
|
||||
@@ -160,6 +162,7 @@ class Create extends Action
|
||||
$deployment = $deployments->createFromVcs(
|
||||
$function,
|
||||
$deployment,
|
||||
$buildTimeout,
|
||||
$github,
|
||||
$owner,
|
||||
$repository,
|
||||
@@ -172,6 +175,7 @@ class Create extends Action
|
||||
$deployment = $deployments->createFromRef(
|
||||
$function,
|
||||
$deployment,
|
||||
$buildTimeout,
|
||||
$owner,
|
||||
$repository,
|
||||
GitHub::CLONE_TYPE_COMMIT,
|
||||
|
||||
@@ -81,6 +81,7 @@ class Create extends Base
|
||||
->inject('publisherForBuilds')
|
||||
->inject('vcsFactory')
|
||||
->inject('deployments')
|
||||
->inject('buildTimeout')
|
||||
->inject('authorization')
|
||||
->inject('bus')
|
||||
->inject('platform')
|
||||
@@ -104,6 +105,7 @@ class Create extends Base
|
||||
BuildPublisher $publisherForBuilds,
|
||||
VcsFactory $vcsFactory,
|
||||
Deployments $deployments,
|
||||
int $buildTimeout,
|
||||
Authorization $authorization,
|
||||
Bus $bus,
|
||||
array $platform
|
||||
@@ -144,7 +146,8 @@ class Create extends Base
|
||||
deployments: $deployments,
|
||||
platform: $platform,
|
||||
referenceType: $type,
|
||||
reference: $reference
|
||||
reference: $reference,
|
||||
buildTimeout: $buildTimeout
|
||||
);
|
||||
|
||||
$queueForEvents
|
||||
@@ -185,6 +188,7 @@ class Create extends Base
|
||||
'type' => 'vcs',
|
||||
'activate' => $activate,
|
||||
]),
|
||||
$buildTimeout,
|
||||
$owner,
|
||||
$repository,
|
||||
$type,
|
||||
|
||||
@@ -76,6 +76,7 @@ class Create extends Base
|
||||
->inject('publisherForBuilds')
|
||||
->inject('vcsFactory')
|
||||
->inject('deployments')
|
||||
->inject('buildTimeout')
|
||||
->inject('platform')
|
||||
->callback($this->action(...));
|
||||
}
|
||||
@@ -94,6 +95,7 @@ class Create extends Base
|
||||
BuildPublisher $publisherForBuilds,
|
||||
VcsFactory $vcsFactory,
|
||||
Deployments $deployments,
|
||||
int $buildTimeout,
|
||||
array $platform,
|
||||
) {
|
||||
$function = $dbForProject->getDocument('functions', $functionId);
|
||||
@@ -123,7 +125,8 @@ class Create extends Base
|
||||
platform: $platform,
|
||||
reference: $reference,
|
||||
referenceType: $type,
|
||||
deployments: $deployments
|
||||
deployments: $deployments,
|
||||
buildTimeout: $buildTimeout
|
||||
);
|
||||
|
||||
$queueForEvents
|
||||
|
||||
@@ -130,6 +130,7 @@ class Create extends Base
|
||||
->inject('queueForEvents')
|
||||
->inject('publisherForBuilds')
|
||||
->inject('deployments')
|
||||
->inject('buildTimeout')
|
||||
->inject('queueForRealtime')
|
||||
->inject('queueForWebhooks')
|
||||
->inject('publisherForFunctions')
|
||||
@@ -179,6 +180,7 @@ class Create extends Base
|
||||
Event $queueForEvents,
|
||||
BuildPublisher $publisherForBuilds,
|
||||
Deployments $deployments,
|
||||
int $buildTimeout,
|
||||
Realtime $queueForRealtime,
|
||||
Webhook $queueForWebhooks,
|
||||
FunctionPublisher $publisherForFunctions,
|
||||
@@ -377,7 +379,8 @@ class Create extends Base
|
||||
activate: true,
|
||||
platform: $platform,
|
||||
reference: $providerBranch,
|
||||
referenceType: 'branch'
|
||||
referenceType: 'branch',
|
||||
buildTimeout: $buildTimeout
|
||||
);
|
||||
|
||||
} elseif (!$template->isEmpty()) {
|
||||
@@ -402,6 +405,7 @@ class Create extends Base
|
||||
'type' => 'vcs',
|
||||
'activate' => true,
|
||||
]),
|
||||
$buildTimeout,
|
||||
$templateOwner,
|
||||
$templateRepository,
|
||||
Git::CLONE_TYPE_TAG,
|
||||
|
||||
@@ -115,6 +115,7 @@ class Update extends Base
|
||||
->inject('queueForEvents')
|
||||
->inject('publisherForBuilds')
|
||||
->inject('deployments')
|
||||
->inject('buildTimeout')
|
||||
->inject('dbForPlatform')
|
||||
->inject('vcsFactory')
|
||||
->inject('repositoryWebhooks')
|
||||
@@ -154,6 +155,7 @@ class Update extends Base
|
||||
Event $queueForEvents,
|
||||
BuildPublisher $publisherForBuilds,
|
||||
Deployments $deployments,
|
||||
int $buildTimeout,
|
||||
Database $dbForPlatform,
|
||||
VcsFactory $vcsFactory,
|
||||
RepositoryWebhooks $repositoryWebhooks,
|
||||
@@ -329,7 +331,7 @@ class Update extends Base
|
||||
|
||||
// Redeploy logic
|
||||
if (!$isConnected && !empty($providerRepositoryId)) {
|
||||
$this->redeployVcsFunction($request, $function, $project, $installation, $dbForProject, $publisherForBuilds, new Document(), $vcsFactory->fromInstallation($installation), true, $deployments, $platform);
|
||||
$this->redeployVcsFunction($request, $function, $project, $installation, $dbForProject, $publisherForBuilds, new Document(), $vcsFactory->fromInstallation($installation), true, $deployments, $buildTimeout, $platform);
|
||||
}
|
||||
|
||||
// Inform scheduler if function is still active
|
||||
|
||||
@@ -399,6 +399,7 @@ class Builds extends Action
|
||||
$deployments->createFromVcs(
|
||||
$resource,
|
||||
$deployment,
|
||||
$timeout,
|
||||
$providerAdapter,
|
||||
$cloneOwner,
|
||||
$cloneRepository,
|
||||
|
||||
@@ -87,6 +87,7 @@ class Create extends Action
|
||||
->inject('deviceForSites')
|
||||
->inject('deviceForLocal')
|
||||
->inject('deployments')
|
||||
->inject('buildTimeout')
|
||||
->inject('plan')
|
||||
->inject('authorization')
|
||||
->inject('bus')
|
||||
@@ -111,6 +112,7 @@ class Create extends Action
|
||||
Device $deviceForSites,
|
||||
Device $deviceForLocal,
|
||||
Deployments $deployments,
|
||||
int $buildTimeout,
|
||||
array $plan,
|
||||
Authorization $authorization,
|
||||
Bus $bus,
|
||||
@@ -320,7 +322,7 @@ class Create extends Action
|
||||
}
|
||||
|
||||
try {
|
||||
$locks($lockKey, 600, function () use ($activate, $authorization, $bus, $commands, $chunk, &$chunks, $dbForPlatform, $dbForProject, $deploymentId, $deployments, $deviceForLocal, $deviceForSites, $fileSize, $fileTmpName, &$metadata, $mergeUploadMetadata, $outputDirectory, $path, $platform, $project, $queueForEvents, $response, &$site, $type): void {
|
||||
$locks($lockKey, 600, function () use ($buildTimeout, $activate, $authorization, $bus, $commands, $chunk, &$chunks, $dbForPlatform, $dbForProject, $deploymentId, $deployments, $deviceForLocal, $deviceForSites, $fileSize, $fileTmpName, &$metadata, $mergeUploadMetadata, $outputDirectory, $path, $platform, $project, $queueForEvents, $response, &$site, $type): void {
|
||||
$deployment = $dbForProject->getDocument('deployments', $deploymentId);
|
||||
$uploaded = 0;
|
||||
|
||||
@@ -383,7 +385,7 @@ class Create extends Action
|
||||
'activate' => $activate,
|
||||
'sourceMetadata' => $metadata,
|
||||
'type' => $type,
|
||||
]));
|
||||
]), $buildTimeout);
|
||||
|
||||
if ($isNewDeployment) {
|
||||
$sitesDomain = $platform['sitesDomain'];
|
||||
|
||||
@@ -69,6 +69,7 @@ class Create extends Action
|
||||
->inject('dbForPlatform')
|
||||
->inject('queueForEvents')
|
||||
->inject('deployments')
|
||||
->inject('buildTimeout')
|
||||
->inject('deviceForSites')
|
||||
->inject('vcsFactory')
|
||||
->inject('authorization')
|
||||
@@ -87,6 +88,7 @@ class Create extends Action
|
||||
Database $dbForPlatform,
|
||||
Event $queueForEvents,
|
||||
Deployments $deployments,
|
||||
int $buildTimeout,
|
||||
Device $deviceForSites,
|
||||
VcsFactory $vcsFactory,
|
||||
Authorization $authorization,
|
||||
@@ -172,7 +174,7 @@ class Create extends Action
|
||||
]);
|
||||
|
||||
if ($hasSource) {
|
||||
$deployment = $deployments->createFromUpload($site, $deployment);
|
||||
$deployment = $deployments->createFromUpload($site, $deployment, $buildTimeout);
|
||||
} elseif ($installationId !== '') {
|
||||
$installation = $dbForPlatform->getDocument('installations', $installationId);
|
||||
if ($installation->isEmpty()) {
|
||||
@@ -185,6 +187,7 @@ class Create extends Action
|
||||
$deployment = $deployments->createFromVcs(
|
||||
$site,
|
||||
$deployment,
|
||||
$buildTimeout,
|
||||
$vcs,
|
||||
$owner,
|
||||
$repository,
|
||||
@@ -197,6 +200,7 @@ class Create extends Action
|
||||
$deployment = $deployments->createFromRef(
|
||||
$site,
|
||||
$deployment,
|
||||
$buildTimeout,
|
||||
$owner,
|
||||
$repository,
|
||||
GitHub::CLONE_TYPE_COMMIT,
|
||||
|
||||
@@ -86,6 +86,7 @@ class Create extends Base
|
||||
->inject('vcsFactory')
|
||||
->inject('authorization')
|
||||
->inject('deployments')
|
||||
->inject('buildTimeout')
|
||||
->inject('bus')
|
||||
->inject('platform')
|
||||
->callback($this->action(...));
|
||||
@@ -109,6 +110,7 @@ class Create extends Base
|
||||
VcsFactory $vcsFactory,
|
||||
Authorization $authorization,
|
||||
Deployments $deployments,
|
||||
int $buildTimeout,
|
||||
Bus $bus,
|
||||
array $platform
|
||||
) {
|
||||
@@ -146,7 +148,8 @@ class Create extends Base
|
||||
authorization: $authorization,
|
||||
deployments: $deployments,
|
||||
bus: $bus,
|
||||
platform: $platform
|
||||
platform: $platform,
|
||||
buildTimeout: $buildTimeout
|
||||
);
|
||||
|
||||
$queueForEvents
|
||||
@@ -232,6 +235,7 @@ class Create extends Base
|
||||
$deployment = $deployments->createFromRef(
|
||||
$site,
|
||||
$deployment,
|
||||
$buildTimeout,
|
||||
$owner,
|
||||
$repository,
|
||||
$type,
|
||||
|
||||
@@ -79,6 +79,7 @@ class Create extends Base
|
||||
->inject('vcsFactory')
|
||||
->inject('authorization')
|
||||
->inject('deployments')
|
||||
->inject('buildTimeout')
|
||||
->inject('bus')
|
||||
->inject('platform')
|
||||
->callback($this->action(...));
|
||||
@@ -99,6 +100,7 @@ class Create extends Base
|
||||
VcsFactory $vcsFactory,
|
||||
Authorization $authorization,
|
||||
Deployments $deployments,
|
||||
int $buildTimeout,
|
||||
Bus $bus,
|
||||
array $platform
|
||||
) {
|
||||
@@ -132,7 +134,8 @@ class Create extends Base
|
||||
bus: $bus,
|
||||
reference: $reference,
|
||||
referenceType: $type,
|
||||
platform: $platform
|
||||
platform: $platform,
|
||||
buildTimeout: $buildTimeout
|
||||
);
|
||||
|
||||
$queueForEvents
|
||||
|
||||
@@ -119,6 +119,7 @@ class Update extends Base
|
||||
->inject('executor')
|
||||
->inject('authorization')
|
||||
->inject('deployments')
|
||||
->inject('buildTimeout')
|
||||
->inject('bus')
|
||||
->inject('platform')
|
||||
->callback($this->action(...));
|
||||
@@ -161,6 +162,7 @@ class Update extends Base
|
||||
Executor $executor,
|
||||
Authorization $authorization,
|
||||
Deployments $deployments,
|
||||
int $buildTimeout,
|
||||
Bus $bus,
|
||||
array $platform
|
||||
) {
|
||||
@@ -347,7 +349,7 @@ class Update extends Base
|
||||
|
||||
// Redeploy logic
|
||||
if (!$isConnected && !empty($providerRepositoryId)) {
|
||||
$this->redeployVcsSite($request, $site, $project, $installation, $dbForProject, $dbForPlatform, $publisherForBuilds, new Document(), $vcsFactory->fromInstallation($installation), true, $authorization, $deployments, $bus, $platform);
|
||||
$this->redeployVcsSite($request, $site, $project, $installation, $dbForProject, $dbForPlatform, $publisherForBuilds, new Document(), $vcsFactory->fromInstallation($installation), true, $authorization, $deployments, $buildTimeout, $bus, $platform);
|
||||
}
|
||||
|
||||
$queueForEvents->setParam('siteId', $site->getId());
|
||||
|
||||
@@ -77,7 +77,8 @@ trait Deployment
|
||||
throw new Exception(Exception::PROJECT_NOT_FOUND, 'Repository references non-existent project');
|
||||
}
|
||||
|
||||
$this->beforeCreateGitDeployment($project, $repository, $dbForPlatform, $authorization);
|
||||
$timeout = $this->beforeCreateGitDeployment($project, $repository, $dbForPlatform, $authorization)
|
||||
?? (int) System::getEnv('_APP_COMPUTE_BUILD_TIMEOUT', 900);
|
||||
|
||||
try {
|
||||
$dsn = new DSN($project->getAttribute('database'));
|
||||
@@ -400,6 +401,7 @@ trait Deployment
|
||||
->createFromVcs(
|
||||
$resource,
|
||||
$deployment,
|
||||
$timeout,
|
||||
$vcs,
|
||||
$providerRepositoryOwner,
|
||||
$providerRepositoryName,
|
||||
@@ -594,8 +596,10 @@ trait Deployment
|
||||
}
|
||||
}
|
||||
|
||||
protected function beforeCreateGitDeployment(Document $project, Document $repository, Database $dbForPlatform, Authorization $authorization): void
|
||||
/** Validate the tenant before submission and optionally supply its build budget. */
|
||||
protected function beforeCreateGitDeployment(Document $project, Document $repository, Database $dbForPlatform, Authorization $authorization): ?int
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,10 +39,10 @@ final class UploadCallbacksTest extends TestCase
|
||||
$requests[] = json_decode((string) $request->getBody(), true, flags: JSON_THROW_ON_ERROR);
|
||||
return new Response(202, body: new Stream('{"id":"build","status":"accepted"}'));
|
||||
});
|
||||
$deployments = new Deployments(new Jobs($client), $database, new Document(['$id' => 'project', 'region' => 'default']), ['apiHostname' => 'localhost'], 900);
|
||||
$deployments = new Deployments(new Jobs($client), $database, new Document(['$id' => 'project', 'region' => 'default']), ['apiHostname' => 'localhost']);
|
||||
$result = $deployments->createFromUpload(new Document([
|
||||
'$id' => 'function', '$collection' => 'functions', 'runtime' => array_key_first(Config::getParam('runtimes-v2')),
|
||||
]), clone $deployment);
|
||||
]), clone $deployment, 900);
|
||||
|
||||
$this->assertSame('waiting', $result->getAttribute('status'));
|
||||
$this->assertCount(1, $requests);
|
||||
|
||||
Reference in new issue
Block a user