From f86dcefb04e07bbced07761f0bf1ac0b27fa0ca1 Mon Sep 17 00:00:00 2001 From: Aditya Ramani Date: Sat, 7 Jun 2025 12:45:45 -0700 Subject: [PATCH] Add make target to fetch the default kernel (#33) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the `--install-dependencies` flag with the `(enable/disable)-kernel-install` flag. If the flag is not passed - the default behavior is prompting the user for a response. Also adds a make target `install-kernel` ``` ➜ bin/container system start Verifying apiserver is running... Installing base container filesystem... No default kernel configured. Install the recommended default kernel from [https://github.com/kata-containers/kata-containers/releases/download/3.17.0/kata-static-3.17.0-arm64.tar.xz]? [Y/n]: n Please use the `container system kernel set --recommended` command to configure the default kernel ➜ bin/container system start --disable-kernel-install Verifying apiserver is running... ➜ bin/container system start --enable-kernel-install Verifying apiserver is running... Installing kernel... ➜ bin/container system start --help USAGE: container system start ... [--enable-kernel-install] [--disable-kernel-install] ... --enable-kernel-install/--disable-kernel-install Specify if the default kernel should be installed or not. ``` --------- Signed-off-by: Aditya Ramani --- .github/workflows/common.yml | 2 +- Makefile | 9 +++++++-- Sources/CLI/System/SystemStart.swift | 19 ++++++++++++++----- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml index b3b7e345..0d5e2742 100644 --- a/.github/workflows/common.yml +++ b/.github/workflows/common.yml @@ -63,7 +63,7 @@ jobs: - name: Test the container project run: | launchctl setenv HTTP_PROXY $HTTP_PROXY - make test integration + make test cleancontent install-kernel integration env: CONTAINER_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }} CONTAINER_REGISTRY_USER: ${{ github.actor }} diff --git a/Makefile b/Makefile index 782779d3..769580d5 100644 --- a/Makefile +++ b/Makefile @@ -128,13 +128,18 @@ dsym: test: @$(SWIFT) test -c $(BUILD_CONFIGURATION) $(CURRENT_SDK_ARGS) --skip TestCLI +.PHONY: install-kernel +install-kernel: + @bin/container system stop || true + @bin/container system start --enable-kernel-install + .PHONY: integration -integration: cleancontent init-block +integration: init-block @echo Ensuring apiserver stopped before the CLI integration tests... @bin/container system stop @scripts/ensure-container-stopped.sh @echo Running the integration tests... - @bin/container system start --install-dependencies + @bin/container system start @echo "Removing any existing containers" @bin/container rm --all @echo "Starting CLI integration tests" diff --git a/Sources/CLI/System/SystemStart.swift b/Sources/CLI/System/SystemStart.swift index 168300a6..acce9139 100644 --- a/Sources/CLI/System/SystemStart.swift +++ b/Sources/CLI/System/SystemStart.swift @@ -34,8 +34,10 @@ extension Application { @Flag(name: .long, help: "Enable debug logging for the runtime daemon.") var debug = false - @Flag(name: .long, help: "Do not prompt for confirmation before installing runtime dependencies") - var installDependencies: Bool = false + @Flag( + name: .long, inversion: .prefixedEnableDisable, + help: "Specify whether the default kernel should be installed or not. The default behavior is to prompt the user for a response.") + var kernelInstall: Bool? func run() async throws { // Without the true path to the binary in the plist, `container-apiserver` won't launch properly. @@ -110,9 +112,10 @@ extension Application { let defaultKernelURL = kernelDependency.source let defaultKernelBinaryPath = ClientDefaults.get(key: .defaultKernelBinaryPath) - print("No default kernel configured.") - print("Install the recommended default kernel from [\(kernelDependency.source)]? [Y/n]: ", terminator: "") - if !installDependencies { + var shouldInstallKernel = false + if kernelInstall == nil { + print("No default kernel configured.") + print("Install the recommended default kernel from [\(kernelDependency.source)]? [Y/n]: ", terminator: "") guard let read = readLine(strippingNewline: true) else { throw ContainerizationError(.internalError, message: "Failed to read user input") } @@ -120,6 +123,12 @@ extension Application { print("Please use the `container system kernel set --recommended` command to configure the default kernel") return } + shouldInstallKernel = true + } else { + shouldInstallKernel = kernelInstall ?? false + } + guard shouldInstallKernel else { + return } print("Installing kernel...") try await KernelSet.downloadAndInstallWithProgressBar(tarRemoteURL: defaultKernelURL, kernelFilePath: defaultKernelBinaryPath)