-
Notifications
You must be signed in to change notification settings - Fork 50
Add reconfigure api #218
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
base: main
Are you sure you want to change the base?
Add reconfigure api #218
Conversation
648ffdd to
e71d1cc
Compare
e71d1cc to
2dcb50b
Compare
7ba94e5 to
e9f7a10
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 migrates the mig-reconfigure implementation from the vgpu-device-manager repository to a shared package in mig-parted, enabling both mig-manager and vgpu-device-manager to utilize the same functionality.
- Creates a new
pkg/mig/reconfigurepackage with configuration, validation, and execution logic - Implements validation for systemd service names using custom validators
- Provides comprehensive test coverage using mocked interfaces
Reviewed Changes
Copilot reviewed 9 out of 194 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/mig/reconfigure/reconfigure.go | Core implementation of MIG reconfiguration logic with systemd service management |
| pkg/mig/reconfigure/options.go | Configuration options and functional option pattern for API construction |
| pkg/mig/reconfigure/validate.go | Validation logic including custom systemd service name validator |
| pkg/mig/reconfigure/api.go | Public API interfaces and constants |
| pkg/mig/reconfigure/reconfigure_test.go | Comprehensive test suite with mocked dependencies |
| pkg/mig/reconfigure/*_mock.go | Generated mock implementations for testing |
| go.mod | Added validator dependency |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
pkg/mig/reconfigure/validate.go
Outdated
|
|
||
| err := validate.RegisterValidation("systemd_service_name", validateSystemdServiceName) | ||
| if err != nil { | ||
| return fmt.Errorf("unable to registre systemd service name validator: %w", err) |
Copilot
AI
Aug 14, 2025
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.
The word 'registre' is misspelled. It should be 'register'.
| return fmt.Errorf("unable to registre systemd service name validator: %w", err) | |
| return fmt.Errorf("unable to register systemd service name validator: %w", err) |
| expectedError: nil, | ||
| }, | ||
| { | ||
| description: "reconfigure exists if config is applied", |
Copilot
AI
Aug 14, 2025
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.
The word 'exists' should be 'exits' to match the similar test case on line 131.
| description: "reconfigure exists if config is applied", | |
| description: "reconfigure exits if config is applied", |
pkg/mig/reconfigure/options.go
Outdated
| // TODO: Define the validation schema. | ||
| SelectedMIGConfig string `validate:"required"` | ||
|
|
||
| // DriverLibrayPath is the path to libnvidia-ml.so.1 in the container. |
Copilot
AI
Aug 14, 2025
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.
The word 'DriverLibrayPath' is misspelled. It should be 'DriverLibraryPath'.
| // DriverLibrayPath is the path to libnvidia-ml.so.1 in the container. | |
| // DriverLibraryPath is the path to libnvidia-ml.so.1 in the container. |
| } | ||
|
|
||
| cmd = exec.Command("chroot", opts.HostRootMount, "systemctl", "-q", "is-enabled", service) // #nosec G204 -- HostRootMount validated via dirpath, service validated via systemd_service_name. | ||
| if err := cmd.Run(); err != nil { |
Copilot
AI
Aug 14, 2025
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.
This is a duplicate check of the same command executed on line 331. Consider extracting this repeated logic into a helper function to reduce code duplication.
| if err := cmd.Run(); err != nil { | |
| if err := runSystemctlIsEnabled(opts.HostRootMount, service); err != nil { |
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.
2 Nits
| @@ -0,0 +1,40 @@ | |||
| package reconfigure | |||
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: License header
| @@ -0,0 +1,132 @@ | |||
| package reconfigure | |||
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: License header
This change adds a mig/reconfigure package that implements the functionality added to the vgpu-device-manager. Signed-off-by: Evan Lezar <[email protected]>
Signed-off-by: Evan Lezar <[email protected]>
Signed-off-by: Evan Lezar <[email protected]>
Signed-off-by: Evan Lezar <[email protected]>
Signed-off-by: Evan Lezar <[email protected]>
Signed-off-by: Evan Lezar <[email protected]>
Signed-off-by: Evan Lezar <[email protected]>
e9f7a10 to
9cf3052
Compare
| return false | ||
| } | ||
|
|
||
| cmd = exec.Command("chroot", opts.HostRootMount, "systemctl", "-q", "is-enabled", service) // #nosec G204 -- HostRootMount validated via dirpath, service validated via systemd_service_name. |
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.
thoughts on using this library to invoke systemctl functions?
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.
Please disregard the above library, they too are just shelling out and invoking the systemctl command
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.
Looks like we will need to use coreos/go-systemd to replace the shell invocations here - https://github.com/coreos/go-systemd
I found this blog quite helpul - https://blog.gripdev.xyz/2024/09/27/golang-restart-systemd-unit/
This change migrates the mig-reconfigure implementation from NVIDIA/vgpu-device-manager#93 to a package in mig-parted so that it can be shared between the mig-manager and the vgpu-device-manager.
We will extend the API to support the mig-manager use case as a follow-up.
See #216