Skip to content

Commit 7fc6642

Browse files
committed
Remove IMEX nodes config option
This change removes the IMEX nodes config option. Instead, the path to the config file /etc/nvidia-imex/nodes_config.cfg is assumed with the following roots being searched for this file: /, /config, ${DRIVER_ROOT_CTR_PATH}. Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent e8e4f61 commit 7fc6642

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

api/config/v1/config.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ func NewConfig(c *cli.Context, flags []cli.Flag) (*Config, error) {
6161
if c.IsSet("imex-required") {
6262
config.Imex.Required = c.Bool("imex-required")
6363
}
64-
updateFromCLIFlag(&config.Imex.NodesConfigFile, c, "imex-nodes-config-file")
6564

6665
// If nvidiaDevRoot (the path to the device nodes on the host) is not set,
6766
// we default to using the driver root on the host.

api/config/v1/imex.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ type Imex struct {
3939
// If it is not required its injection is skipped if the device nodes do not exist or if its
4040
// existence cannot be queried.
4141
Required bool `json:"required,omitempty" yaml:"required,omitempty"`
42-
// NodesConfigFile defines the location to the IMEX nodes config file.
43-
// Such a nodes config file contains the IP addresses of nodes that are part of the IMEX domain.
44-
// Note that this is the absolute path to the file in the device plugin container.
45-
NodesConfigFile *string `json:"nodesConfigFile,omitempty" yaml:"nodesConfigFile,omitempty"`
4642
}
4743

4844
// AssertChannelIDsIsValid checks whether the specified list of channel IDs is valid.

cmd/gpu-feature-discovery/main.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,6 @@ func main() {
8686
Value: "/etc/kubernetes/node-feature-discovery/features.d/gfd",
8787
EnvVars: []string{"GFD_OUTPUT_FILE"},
8888
},
89-
&cli.StringFlag{
90-
Name: "imex-nodes-config-file",
91-
Usage: "Path to the IMEX nodes config file. This file contains a list of IP addresses of the nodes in the IMEX domain.",
92-
Value: "/etc/nvidia-imex/nodes_config.cfg",
93-
EnvVars: []string{"GFD_IMEX_NODES_CONFIG_FILE"},
94-
},
9589
&cli.StringFlag{
9690
Name: "machine-type-file",
9791
Value: "/sys/class/dmi/id/product_name",

internal/lm/fabric.go renamed to internal/lm/imex.go

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,16 @@ import (
3434
"github.com/NVIDIA/k8s-device-plugin/internal/resource"
3535
)
3636

37-
func newImexLabeler(config *spec.Config, devices []resource.Device) (Labeler, error) {
38-
if config.Imex.NodesConfigFile == nil || *config.Imex.NodesConfigFile == "" {
39-
// No imex config file, return empty labels
40-
return empty{}, nil
41-
}
42-
43-
nodesConfigFiles := []string{*config.Imex.NodesConfigFile}
44-
if root := config.Flags.Plugin.ContainerDriverRoot; root != nil && *root != "" {
45-
nodesConfigFiles = append(nodesConfigFiles, filepath.Join(*root, *config.Imex.NodesConfigFile))
46-
}
37+
const (
38+
// ImexNodesConfigFilePath is the path to the IMEX nodes config file.
39+
// This file contains a list of IP addresses of the nodes in the IMEX domain.
40+
ImexNodesConfigFilePath = "/etc/nvidia-imex/nodes_config.cfg"
41+
)
4742

43+
func newImexLabeler(config *spec.Config, devices []resource.Device) (Labeler, error) {
4844
var errs error
49-
for _, configFilePath := range nodesConfigFiles {
45+
for _, root := range imexNodesConfigFilePathSearchRoots(config) {
46+
configFilePath := filepath.Join(root, ImexNodesConfigFilePath)
5047
imexLabeler, err := imexLabelerForConfigFile(configFilePath, devices)
5148
if err != nil {
5249
errs = errors.Join(errs, err)
@@ -64,6 +61,19 @@ func newImexLabeler(config *spec.Config, devices []resource.Device) (Labeler, er
6461
return empty{}, nil
6562
}
6663

64+
// imexNodesConfigFilePathSearchRoots returns a list of roots to search for the IMEX nodes config file.
65+
func imexNodesConfigFilePathSearchRoots(config *spec.Config) []string {
66+
// By default, search / and /config for config files.
67+
roots := []string{"/", "/config"}
68+
69+
if config == nil || config.Flags.Plugin == nil || config.Flags.Plugin.ContainerDriverRoot == nil {
70+
return roots
71+
}
72+
73+
// If a driver root is specified, it is also searched.
74+
return append(roots, *config.Flags.Plugin.ContainerDriverRoot)
75+
}
76+
6777
func imexLabelerForConfigFile(configFilePath string, devices []resource.Device) (Labeler, error) {
6878
imexConfigFile, err := os.Open(configFilePath)
6979
if os.IsNotExist(err) {
File renamed without changes.

0 commit comments

Comments
 (0)