Skip to content

Conversation

elezar
Copy link
Member

@elezar elezar commented Aug 28, 2025

This change refactors the AddRuntime function into GetDefaultRuntimeOptions and AddRuntimeWithOptions. This allows for a clearer distinction between SOURCE and DESTINATION configs which should facilitate switching to drop-in files.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 17298873827

Details

  • 48 of 59 (81.36%) changed or added relevant lines in 3 files are covered.
  • 8 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.008%) to 35.733%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/config/engine/containerd/config_v1.go 11 22 50.0%
Files with Coverage Reduction New Missed Lines %
pkg/config/engine/containerd/config_v1.go 8 18.18%
Totals Coverage Status
Change from base Build 17293965431: -0.008%
Covered Lines: 4656
Relevant Lines: 13030

💛 - Coveralls

This change refactors the AddRuntime function into GetDefaultRuntimeOptions
and AddRuntimeWithOptions. This allows for a clearer distinction between SOURCE
and DESTINATION configs which should facilitate switching to drop-in files.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
@elezar elezar force-pushed the clean-runtime-config-api branch from aec10b2 to 5d37aba Compare August 28, 2025 15:09
"runtime_type": c.RuntimeType,
"runtime_root": "",
"runtime_engine": "",
"privileged_without_host_devices": false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if, on this fallback, we should add the SystemdCgroup = true|false based on a function that looks if the system is running systemd.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent of this change is not to add additional behaviour. It is a refactor.

}

config = *c.Tree
// Note: This is deprecated in containerd 1.4.0 and will be removed in 1.5.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we edit the note, now that 1.5.0 is released? and add a warning log.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent of this change is not to add additional behaviour. It is a refactor.

@elezar elezar marked this pull request as ready for review September 8, 2025 08:11
@elezar elezar marked this pull request as draft September 8, 2025 08:38
@elezar elezar marked this pull request as ready for review September 8, 2025 09:07
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the AddRuntime function across multiple container engine configuration files to improve code organization and clarity. The refactoring separates the extraction of default runtime options from the actual runtime addition logic.

  • Refactors AddRuntime into GetDefaultRuntimeOptions and AddRuntimeWithOptions methods
  • Updates test files to use the new New() constructor pattern instead of direct struct instantiation
  • Improves error handling and logging consistency across CRI-O and containerd configurations

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
pkg/config/engine/crio/crio_test.go Updates tests to use New() constructor with functional options
pkg/config/engine/crio/crio.go Refactors AddRuntime into separate methods for options extraction and runtime addition
pkg/config/engine/containerd/config_v1.go Adapts containerd v1 config to use new refactored method structure
pkg/config/engine/containerd/config.go Implements the new method structure for containerd config with default options fallback

Comment on lines +84 to +85
defaultRuntimeOptions := c.GetDefaultRuntimeOptions()
return c.AddRuntimeWithOptions(name, path, setAsDefault, defaultRuntimeOptions)
Copy link
Preview

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The variable name defaultRuntimeOptions could be shortened to options for better readability, as the context already makes it clear these are default options.

Suggested change
defaultRuntimeOptions := c.GetDefaultRuntimeOptions()
return c.AddRuntimeWithOptions(name, path, setAsDefault, defaultRuntimeOptions)
options := c.GetDefaultRuntimeOptions()
return c.AddRuntimeWithOptions(name, path, setAsDefault, options)

Copilot uses AI. Check for mistakes.

break
options := c.GetSubtreeByPath([]string{"crio", "runtime", "runtimes", r})
if options != nil {
c.Logger.Debugf("Using options from runtime %v: %v", r, options)
Copy link
Preview

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The log message capitalization should be consistent with other log messages in the codebase. Consider using lowercase 'using' to match the pattern in the original code.

Suggested change
c.Logger.Debugf("Using options from runtime %v: %v", r, options)
c.Logger.Debugf("using options from runtime %v: %v", r, options)

Copilot uses AI. Check for mistakes.

}
c.Logger.Warningf("Could not infer options from runtimes %v", runtimeNamesForConfig)
Copy link
Preview

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The log message capitalization should be consistent. Consider using lowercase 'could' to match the pattern in the original code which used 'could not infer options'.

Suggested change
c.Logger.Warningf("Could not infer options from runtimes %v", runtimeNamesForConfig)
c.Logger.Warningf("could not infer options from runtimes %v", runtimeNamesForConfig)

Copilot uses AI. Check for mistakes.

Copy link
Collaborator

@ArangoGutierrez ArangoGutierrez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
I made a note to turn my 2 comments into TODO items

@elezar elezar merged commit 537f53b into NVIDIA:main Sep 8, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants