From 4980de30fc7c05897a6471459eb572f00b1d3dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Fri, 8 Nov 2024 16:44:41 +0100 Subject: [PATCH 1/4] test/install: Use separate runDir for each test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski --- __tests__/docker/install.test.itg.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/__tests__/docker/install.test.itg.ts b/__tests__/docker/install.test.itg.ts index 1bf9816..b960e77 100644 --- a/__tests__/docker/install.test.itg.ts +++ b/__tests__/docker/install.test.itg.ts @@ -23,7 +23,7 @@ import {Install, InstallSourceArchive, InstallSourceImage} from '../../src/docke import {Docker} from '../../src/docker/docker'; import {Exec} from '../../src/exec'; -const tmpDir = fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-itg-')); +const tmpDir = () => fs.mkdtempSync(path.join(process.env.TEMP || os.tmpdir(), 'docker-install-itg-')); describe('install', () => { const originalEnv = process.env; @@ -51,7 +51,7 @@ aarch64:https://cloud.debian.org/images/cloud/bookworm/20231013-1532/debian-12-g await ensureNoSystemContainerd(); const install = new Install({ source: source, - runDir: tmpDir, + runDir: tmpDir(), contextName: 'foo', daemonConfig: `{"debug":true,"features":{"containerd-snapshotter":true}}` }); @@ -74,7 +74,7 @@ describe('rootless', () => { await ensureNoSystemContainerd(); const install = new Install({ source: source, - runDir: tmpDir, + runDir: tmpDir(), contextName: 'foo', daemonConfig: `{"debug":true}`, rootless: true From 0b611e6c46b3a16d8b14df9ffde6c55f6ea88ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Fri, 8 Nov 2024 17:00:09 +0100 Subject: [PATCH 2/4] docker/install: Clean up toolDir in teardown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `toolDir` is added to `PATH` on install, so make sure the binaries aren't accessible after a teardown. Signed-off-by: Paweł Gronowski --- src/docker/install.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/docker/install.ts b/src/docker/install.ts index e3c1629..0c0203d 100644 --- a/src/docker/install.ts +++ b/src/docker/install.ts @@ -492,6 +492,13 @@ EOF`, throw new Error(`Unsupported platform: ${os.platform()}`); } } + + await core.group(`Cleaning up toolDir`, async () => { + if (!this._toolDir) { + return; + } + fs.rmSync(this._toolDir, {recursive: true, force: true}); + }); } private async tearDownDarwin(): Promise { From 15a9f9204428553ba1d32b0638a4989c7f7de201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Fri, 8 Nov 2024 16:45:42 +0100 Subject: [PATCH 3/4] docker/install: Copy all `rootless-extras` files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski --- src/docker/install.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/docker/install.ts b/src/docker/install.ts index 0c0203d..10d3b7b 100644 --- a/src/docker/install.ts +++ b/src/docker/install.ts @@ -170,7 +170,11 @@ export class Install { if (this.rootless) { core.info(`Downloading Docker rootless extras ${version} from ${this.source.channel} at download.docker.com`); const extrasFolder = await this.downloadStaticArchive('docker-rootless-extras', this.source); - fs.copyFileSync(path.join(extrasFolder, 'dockerd-rootless.sh'), path.join(extractFolder, 'dockerd-rootless.sh')); + fs.readdirSync(extrasFolder).forEach(file => { + const src = path.join(extrasFolder, file); + const dest = path.join(extractFolder, file); + fs.copyFileSync(src, dest); + }); } break; } From 54e0f74a8452e2e212146251dc227f514079123b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Fri, 8 Nov 2024 18:07:31 +0100 Subject: [PATCH 4/4] docker/install: Stop docker service on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski --- src/docker/install.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/docker/install.ts b/src/docker/install.ts index 10d3b7b..22828cf 100644 --- a/src/docker/install.ts +++ b/src/docker/install.ts @@ -552,6 +552,9 @@ EOF`, await core.group('Removing Docker context', async () => { await Docker.exec(['context', 'rm', '-f', this.contextName]); }); + await core.group('Stopping Docker daemon service', async () => { + await Exec.exec('powershell', ['-Command', `Stop-Service -Name docker -Force`]); + }); } private downloadURL(component: 'docker' | 'docker-rootless-extras', version: string, channel: string): string {