@@ -5,26 +5,27 @@ import (
55)
66
77// An Option represents a functional option passed to the constructor.
8- type Option func (* options )
8+ type Option func (* reconfigureMIGOptions )
99
1010// reconfigureMIGOptions contains configuration options for reconfiguring MIG
1111// settings on a Kubernetes node. This struct is used to manage the various
1212// parameters required for applying MIG configurations through mig-parted, including node identification, configuration files, reboot behavior, and host
1313// system service management.
1414type reconfigureMIGOptions struct {
15+ clientset * kubernetes.Clientset `validate:"required"`
16+
1517 // NodeName is the kubernetes node to change the MIG configuration on.
1618 // Its validation follows the RFC 1123 standard for DNS subdomain names.
1719 // Source: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names
18- // NodeName string `validate:"required,hostname_rfc1123"`
20+ NodeName string `validate:"required,hostname_rfc1123"`
1921
2022 // MIGPartedConfigFile is the mig-parted configuration file path.
21- // Deprecated: Pass the config file as an argument.
2223 MIGPartedConfigFile string `validate:"required,filepath"`
2324
2425 // SelectedMIGConfig is the selected mig-parted configuration to apply to the
2526 // node.
26- // Deprecated: Pass the selected config as an argument .
27- SelectedMIGConfig string
27+ // TODO: Define the validation schema .
28+ SelectedMIGConfig string `validate:"required"`
2829
2930 // DriverLibrayPath is the path to libnvidia-ml.so.1 in the container.
3031 DriverLibraryPath string `validate:"required,filepath"`
@@ -51,84 +52,81 @@ type reconfigureMIGOptions struct {
5152 // which may need to be shutdown/restarted across a MIG mode reconfiguration.
5253 HostKubeletService string `validate:"systemd_service_name"`
5354
54- configStateLabel string
55- }
55+ // TODO: Define the validation schema.
56+ configStateLabel string `validate:"required"`
5657
57- type manager struct {
58- clientset * kubernetes.Clientset
59- nodeName string
58+ // TODO: The following is not an option, but is tracked during the reconfiguration.
59+ hostGPUClientServicesStopped []string
6060}
6161
62- type options struct {
63- manager
64-
65- driverRoot root
66-
67- reconfigureMIGOptions
62+ func WithAllowReboot (allowReboot bool ) Option {
63+ return func (o * reconfigureMIGOptions ) {
64+ o .WithReboot = allowReboot
65+ }
6866}
6967
7068func WithClientset (clientset * kubernetes.Clientset ) Option {
71- return func (o * options ) {
69+ return func (o * reconfigureMIGOptions ) {
7270 o .clientset = clientset
7371 }
7472}
7573
76- func WithNodeName (nodeName string ) Option {
77- return func (o * options ) {
78- o .nodeName = nodeName
79- }
80- }
81-
82- func WithDriverRoot [T string | root ](driverRoot T ) Option {
83- return func (o * options ) {
84- o .driverRoot = root (driverRoot )
74+ func WithConfigStateLabel (configStateLabel string ) Option {
75+ return func (o * reconfigureMIGOptions ) {
76+ o .configStateLabel = configStateLabel
8577 }
8678}
8779
8880func WithDriverLibraryPath (driverLibraryPath string ) Option {
89- return func (o * options ) {
81+ return func (o * reconfigureMIGOptions ) {
9082 o .DriverLibraryPath = driverLibraryPath
9183 }
9284}
9385
94- func WithShutdownHostGPUClients (shutdownHostGPUClients bool ) Option {
95- return func (o * options ) {
96- o .WithShutdownHostGPUClients = shutdownHostGPUClients
97- }
98- }
99-
10086func WithHostGPUClientServices (hostGPUClientServices ... string ) Option {
101- return func (o * options ) {
87+ return func (o * reconfigureMIGOptions ) {
10288 o .HostGPUClientServices = append ([]string {}, hostGPUClientServices ... )
10389 }
10490}
10591
10692func WithHostKubeletService (hostKubeletService string ) Option {
107- return func (o * options ) {
93+ return func (o * reconfigureMIGOptions ) {
10894 o .HostKubeletService = hostKubeletService
10995 }
11096}
11197
11298func WithHostMIGManagerStateFile (hostMIGManagerStateFile string ) Option {
113- return func (o * options ) {
99+ return func (o * reconfigureMIGOptions ) {
114100 o .HostMIGManagerStateFile = hostMIGManagerStateFile
115101 }
116102}
117103
118104func WithHostRootMount (hostRootMount string ) Option {
119- return func (o * options ) {
105+ return func (o * reconfigureMIGOptions ) {
120106 o .HostRootMount = hostRootMount
121107 }
122108}
123109
124- func WithAllowReboot ( allowReboot bool ) Option {
125- return func (o * options ) {
126- o .WithReboot = allowReboot
110+ func WithMIGPartedConfigFile ( migPartedConfigFile string ) Option {
111+ return func (o * reconfigureMIGOptions ) {
112+ o .MIGPartedConfigFile = migPartedConfigFile
127113 }
128114}
129115
130- func WithConfigStateLabel (configStateLabel string ) Option {
131- return func (o * options ) {
132- o .configStateLabel = configStateLabel
116+ func WithNodeName (nodeName string ) Option {
117+ return func (o * reconfigureMIGOptions ) {
118+ o .NodeName = nodeName
119+ }
120+ }
121+
122+ func WithSelectedMIGConfig (selectedMIGConfig string ) Option {
123+ return func (o * reconfigureMIGOptions ) {
124+ o .SelectedMIGConfig = selectedMIGConfig
125+ }
126+ }
127+
128+ func WithShutdownHostGPUClients (shutdownHostGPUClients bool ) Option {
129+ return func (o * reconfigureMIGOptions ) {
130+ o .WithShutdownHostGPUClients = shutdownHostGPUClients
133131 }
134132}
0 commit comments