diff --git a/nodeinstaller/internal/config/containerd.go b/nodeinstaller/internal/config/containerd.go index 72aebd2836..f43e865948 100644 --- a/nodeinstaller/internal/config/containerd.go +++ b/nodeinstaller/internal/config/containerd.go @@ -22,7 +22,7 @@ type ContainerdConfig struct { // TTRPC configuration settings TTRPC any `toml:"ttrpc,omitempty"` // Debug and profiling settings - Debug any `toml:"debug,omitempty"` + Debug Debug `toml:"debug,omitempty"` // Metrics and monitoring settings Metrics any `toml:"metrics,omitempty"` // DisabledPlugins are IDs of plugins to disable. Disabled plugins won't be @@ -96,3 +96,13 @@ type Runtime struct { // podsandbox - means use Controller implementation from sbserver podsandbox package. Sandboxer string `toml:"sandboxer,omitempty" json:"sandboxer,omitempty"` } + +// Debug provides debug configuration. +type Debug struct { + Address string `toml:"address,omitempty"` + UID int `toml:"uid,omitempty"` + GID int `toml:"gid,omitempty"` + Level string `toml:"level,omitempty"` + // Format represents the logging format. Supported values are 'text' and 'json'. + Format string `toml:"format,omitempty"` +} diff --git a/nodeinstaller/node-installer.go b/nodeinstaller/node-installer.go index 0bdf83f78f..607ea92e22 100644 --- a/nodeinstaller/node-installer.go +++ b/nodeinstaller/node-installer.go @@ -129,7 +129,7 @@ func run(ctx context.Context, fetcher assetFetcher, platform platforms.Platform, return fmt.Errorf("getting runtime handler name: %w", err) } - if err := patchContainerdConfig(runtimeHandler, runtimeBase, containerdConfigPath, platform); err != nil { + if err := patchContainerdConfig(runtimeHandler, runtimeBase, containerdConfigPath, platform, config.DebugRuntime); err != nil { return fmt.Errorf("patching containerd configuration: %w", err) } @@ -183,7 +183,7 @@ func containerdRuntimeConfig(basePath, configPath string, platform platforms.Pla return os.WriteFile(configPath, rawConfig, os.ModePerm) } -func patchContainerdConfig(runtimeHandler, basePath, configPath string, platform platforms.Platform) error { +func patchContainerdConfig(runtimeHandler, basePath, configPath string, platform platforms.Platform, debugRuntime bool) error { existingRaw, existing, err := parseExistingContainerdConfig(configPath) if err != nil { fmt.Printf("Failed to parse existing containerd config: %v\n", err) @@ -191,6 +191,11 @@ func patchContainerdConfig(runtimeHandler, basePath, configPath string, platform existing = constants.ContainerdBaseConfig() } + if debugRuntime { + // Enable containerd debug logging. + existing.Debug.Level = "debug" + } + // Ensure section for the snapshotter proxy plugin exists. if existing.ProxyPlugins == nil { existing.ProxyPlugins = make(map[string]config.ProxyPlugin) diff --git a/nodeinstaller/node-installer_test.go b/nodeinstaller/node-installer_test.go index adce50554d..79f80ec34a 100644 --- a/nodeinstaller/node-installer_test.go +++ b/nodeinstaller/node-installer_test.go @@ -62,7 +62,7 @@ func TestPatchContainerdConfig(t *testing.T) { runtimeHandler := "my-runtime" err = patchContainerdConfig(runtimeHandler, - filepath.Join("/opt/edgeless", runtimeHandler), configPath, tc.platform) + filepath.Join("/opt/edgeless", runtimeHandler), configPath, tc.platform, true) if tc.wantErr { require.Error(err) return diff --git a/nodeinstaller/testdata/expected-aks-clh-snp.toml b/nodeinstaller/testdata/expected-aks-clh-snp.toml index 77f3320e4d..d0fd3f2ba7 100644 --- a/nodeinstaller/testdata/expected-aks-clh-snp.toml +++ b/nodeinstaller/testdata/expected-aks-clh-snp.toml @@ -1,5 +1,8 @@ version = 2 +[debug] +level = 'debug' + [metrics] address = '0.0.0.0:10257' diff --git a/nodeinstaller/testdata/expected-bare-metal-qemu-snp.toml b/nodeinstaller/testdata/expected-bare-metal-qemu-snp.toml index 22edbd5ea7..454de9a790 100644 --- a/nodeinstaller/testdata/expected-bare-metal-qemu-snp.toml +++ b/nodeinstaller/testdata/expected-bare-metal-qemu-snp.toml @@ -1,5 +1,8 @@ version = 2 +[debug] +level = 'debug' + [metrics] address = '0.0.0.0:10257' diff --git a/nodeinstaller/testdata/expected-bare-metal-qemu-tdx.toml b/nodeinstaller/testdata/expected-bare-metal-qemu-tdx.toml index e40e3f78c4..b8cb650748 100644 --- a/nodeinstaller/testdata/expected-bare-metal-qemu-tdx.toml +++ b/nodeinstaller/testdata/expected-bare-metal-qemu-tdx.toml @@ -1,5 +1,8 @@ version = 2 +[debug] +level = 'debug' + [metrics] address = '0.0.0.0:10257'