Skip to content

Commit 5a012dd

Browse files
committed
Skip virtiofs mount if mount point is already mounted
1 parent e821c2d commit 5a012dd

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

app/Pipelines/Steps/BootVm.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,16 @@ protected function mountSharedDirectories(SessionContext $context): void
5454
$project_dir = $context->project_dir;
5555

5656
$this->ssh->run("sudo mkdir -p {$mount_point}");
57-
$this->ssh->run("sudo chown -R admin:admin {$mount_point}");
5857

5958
while (time() - $start < $mount_timeout) {
6059
try {
61-
$result = $this->ssh->run("sudo mount -t virtiofs com.apple.virtio-fs.automount {$mount_point} 2>&1; true");
62-
$output = trim($result->output());
60+
if (! $this->isMounted($mount_point)) {
61+
$result = $this->ssh->run("sudo mount -t virtiofs com.apple.virtio-fs.automount {$mount_point} 2>&1; true");
62+
$output = trim($result->output());
6363

64-
if ($output && $output !== $last_error) {
65-
$last_error = $output;
64+
if ($output && $output !== $last_error) {
65+
$last_error = $output;
66+
}
6667
}
6768

6869
$this->ssh->run("mountpoint -q {$mount_point}");
@@ -100,6 +101,16 @@ protected function mountSharedDirectories(SessionContext $context): void
100101
);
101102
}
102103

104+
protected function isMounted(string $path): bool
105+
{
106+
try {
107+
$this->ssh->run("mountpoint -q {$path}");
108+
return true;
109+
} catch (Throwable) {
110+
return false;
111+
}
112+
}
113+
103114
protected function waitForSsh(SessionContext $context): void
104115
{
105116
$start = time();

0 commit comments

Comments
 (0)