Skip to content

Commit 2f23e97

Browse files
committed
WSL: Move remounting / to right after stopping previous run
This lets us wait for the remount concurrently to starting K3s, which should let us eliminate the hard-coded 60 second wait. As we now do this when nothing else is running, this should complete faster. Signed-off-by: Mark Yen <mark.yen@suse.com>
1 parent 7e69530 commit 2f23e97

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/k8s-engine/wsl.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,22 @@ export default class WSLBackend extends events.EventEmitter implements K8s.Kuber
321321

322322
// If we were previously running, stop it now.
323323
this.process?.kill('SIGTERM');
324+
await childProcess.spawnFile('wsl.exe', ['--terminate', INSTANCE_NAME],
325+
{
326+
stdio: ['ignore', await Logging.wsl.fdStream, await Logging.wsl.fdStream],
327+
windowsHide: true
328+
});
329+
330+
// Temporary workaround: ensure root is mounted as shared -- this will be done later
331+
// Right now the builder pod needs to be restarted after the remount
332+
// TODO: When this code is removed, make `client.getActivePod` protected again.
333+
await childProcess.spawnFile(
334+
'wsl.exe',
335+
['--user', 'root', '--distribution', INSTANCE_NAME, 'mount', '--make-shared', '/'],
336+
{
337+
stdio: ['ignore', await Logging.wsl.fdStream, await Logging.wsl.fdStream],
338+
windowsHide: true,
339+
});
324340

325341
// Run run-k3s with NORUN, to set up the environment.
326342
await childProcess.spawnFile('wsl.exe',
@@ -378,15 +394,6 @@ export default class WSLBackend extends events.EventEmitter implements K8s.Kuber
378394
// Right now the builder pod needs to be restarted after the remount
379395
// TODO: When this code is removed, make `client.getActivePod` protected again.
380396
try {
381-
await childProcess.spawnFile(
382-
'wsl.exe',
383-
['--user', 'root', '--distribution', INSTANCE_NAME, 'mount', '--make-shared', '/'],
384-
{
385-
stdio: ['ignore', await Logging.wsl.fdStream, await Logging.wsl.fdStream],
386-
windowsHide: true,
387-
});
388-
console.log('Waiting for ensuring root is shared');
389-
await util.promisify(setTimeout)(60_000);
390397
await childProcess.spawnFile(
391398
resources.executable('kim'),
392399
['builder', 'install', '--force', '--no-wait'],

0 commit comments

Comments
 (0)