Skip to content

Commit 2093d59

Browse files
committed
fix: docker conflict error
$orchestration->run() sometimes also returns additional information such as output from pulling docker images. As such, it's not reliable to use the output for the container ID. Instead, we can just use the container name for operations on the container. Since we won't use the container ID, we can remove the 'id' column from the activeRuntimes table.
1 parent bd0cd3a commit 2093d59

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

app/http.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
$register->set('activeRuntimes', function () {
9393
$table = new Table(4096);
9494

95-
$table->column('id', Table::TYPE_STRING, 1024);
9695
$table->column('created', Table::TYPE_FLOAT);
9796
$table->column('updated', Table::TYPE_FLOAT);
9897
$table->column('name', Table::TYPE_STRING, 1024);
@@ -407,14 +406,12 @@ function removeAllRuntimes(Table $activeRuntimes, Orchestration $orchestration):
407406
}
408407

409408
$container = [];
410-
$containerId = '';
411409
$output = '';
412410
$startTime = \microtime(true);
413411

414412
$secret = \bin2hex(\random_bytes(16));
415413

416414
$activeRuntimes->set($activeRuntimeId, [
417-
'id' => $containerId,
418415
'name' => $activeRuntimeId,
419416
'hostname' => $runtimeHostname,
420417
'created' => $startTime,
@@ -567,7 +564,6 @@ function removeAllRuntimes(Table $activeRuntimes, Orchestration $orchestration):
567564
]);
568565

569566
$activeRuntimes->set($activeRuntimeId, [
570-
'id' => $containerId,
571567
'name' => $activeRuntimeId,
572568
'hostname' => $runtimeHostname,
573569
'created' => $startTime,
@@ -603,7 +599,7 @@ function removeAllRuntimes(Table $activeRuntimes, Orchestration $orchestration):
603599

604600
// Silently try to kill container
605601
try {
606-
$orchestration->remove($containerId, true);
602+
$orchestration->remove($activeRuntimeId, true);
607603
} catch (Throwable $th) {
608604
}
609605

@@ -620,7 +616,7 @@ function removeAllRuntimes(Table $activeRuntimes, Orchestration $orchestration):
620616

621617
// Silently try to kill container
622618
try {
623-
$orchestration->remove($containerId, true);
619+
$orchestration->remove($activeRuntimeId, true);
624620
} catch (Throwable $th) {
625621
}
626622

@@ -1217,7 +1213,7 @@ function (string $runtimeId, ?string $payload, string $path, string $method, arr
12171213
if ($runtime['updated'] < $inactiveThreshold) {
12181214
go(function () use ($activeRuntimeId, $runtime, $orchestration, $activeRuntimes) {
12191215
try {
1220-
$orchestration->remove($runtime['id'], true);
1216+
$orchestration->remove($runtime['name'], true);
12211217
Console::success("Successfully removed {$runtime['name']}");
12221218
} catch (\Throwable $th) {
12231219
Console::error('Inactive Runtime deletion failed: ' . $th->getMessage());

0 commit comments

Comments
 (0)