-
Notifications
You must be signed in to change notification settings - Fork 387
Add support for specifying the config file path in an environment variable #763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
91aadb7
to
3a304b0
Compare
This change adds support for explicitly specifying the path to the config file through an environment variable. The NVIDIA_CTK_CONFIG_FILE_PATH variable is used for both the nvidia-container-runtime and nvidia-container-runtime-hook. Signed-off-by: Evan Lezar <[email protected]>
Signed-off-by: Evan Lezar <[email protected]>
3a304b0
to
77457b4
Compare
Pull Request Test Coverage Report for Build 15733658255Details
💛 - Coveralls |
Signed-off-by: Evan Lezar <[email protected]>
77457b4
to
849691d
Compare
There was a problem hiding this 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 enables overriding the location of the nvidia-container-runtime
config file via the NVIDIA_CTK_CONFIG_FILE_PATH
environment variable for both the runtime and hook, and refactors related installer APIs to propagate the explicit path.
- Introduce
FilePathOverrideEnvVar
andRelativeFilePath
constants and updateGetConfigFilePath
to respectNVIDIA_CTK_CONFIG_FILE_PATH
- Refactor installer (
ToolkitInstaller
) to accept and propagate a concrete config file path - Update tests and hook code to use the new override logic and remove direct
-config
flag usage
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
internal/config/config.go | Added FilePathOverrideEnvVar /RelativeFilePath and updated GetConfigFilePath logic |
internal/config/config_test.go | Adjusted tests to cover both root override and file-path override |
cmd/nvidia-ctk-installer/toolkit/toolkit.go | Pass explicit config path into installToolkitConfig |
cmd/nvidia-ctk-installer/toolkit/installer/options.go | Renamed toolkitInstaller receiver to ToolkitInstaller in options |
cmd/nvidia-ctk-installer/toolkit/installer/libraries.go | Updated receiver type for collectLibraries |
cmd/nvidia-ctk-installer/toolkit/installer/installer_test.go | Switched to ToolkitInstaller in test setup and updated env vars |
cmd/nvidia-ctk-installer/toolkit/installer/installer.go | Renamed type, made New return *ToolkitInstaller , added ConfigFilePath |
cmd/nvidia-ctk-installer/toolkit/installer/executables_test.go | Removed Args -related tests following wrapper refactor |
cmd/nvidia-ctk-installer/toolkit/installer/executables.go | Dropped CLI-arg support, now uses env-var override in wrappers |
cmd/nvidia-ctk-installer/toolkit/installer/directory.go | Renamed receiver on createDirectory |
cmd/nvidia-container-runtime-hook/hook_config.go | Simplified loadConfig , now honors flag/env/default path |
Comments suppressed due to low confidence (6)
internal/config/config.go:34
- Add a GoDoc comment for the exported constant FilePathOverrideEnvVar to explain its purpose and usage.
FilePathOverrideEnvVar = "NVIDIA_CTK_CONFIG_FILE_PATH"
internal/config/config.go:35
- Add a GoDoc comment for the exported constant RelativeFilePath to clarify that it represents the default relative path to the configuration file.
RelativeFilePath = "nvidia-container-runtime/config.toml"
internal/config/config_test.go:28
- [nitpick] The test name TestGetConfigWithCustomConfig does not clearly reflect that it verifies behavior under the XDG_CONFIG_HOME override. Consider renaming to TestGetConfigWithConfigRootOverride.
func TestGetConfigWithCustomConfig(t *testing.T) {
internal/config/config_test.go:34
- [nitpick] This comment appears misleading because the test actually writes a debug path into the file contents. Update or remove it to accurately describe what the test is verifying.
// By default debug is disabled
cmd/nvidia-ctk-installer/toolkit/installer/installer.go:49
- [nitpick] Changing the signature of New to return *ToolkitInstaller instead of Installer is a breaking API change. Ensure all consumers are updated or consider providing an overload to maintain backward compatibility.
func New(opts ...Option) (*ToolkitInstaller, error) {
cmd/nvidia-container-runtime-hook/hook_config.go:21
- The previous fallback to loading the config from the driver directory (/run/nvidia/driver/etc) was removed. If that behavior is still required for legacy installs, consider reintroducing the driverPath fallback logic.
func loadConfig() (*config.Config, error) {
if configFilePathOverride := os.Getenv(FilePathOverrideEnvVar); configFilePathOverride != "" { | ||
return configFilePathOverride | ||
} | ||
configRoot := "/etc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe a newline before configRoot :=...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non blocker
@elezar I think the PR title should be updated to better reflect the intent of the PR. |
@ArangoGutierrez is the change you require the PR title, or are you blocking on the nit? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This change allows the config file used by the
nvidia-container-runtime
andnvidia-container-runtime-hook
to be explicitly set using anNVIDIA_CTK_CONFIG_FILE_PATH
environment variable. This removes the need to inject a-config
option when installing thenvidia-contianer-runtime-hook
wrapper from the toolkit container and allows the two components to treat this consistently.This would allow the changes of #700 to be integrated more easily.