Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
device-plugin: fix container env var setting for multiple devices
Browse files Browse the repository at this point in the history
Signed-off-by: Maryam Tahhan <[email protected]>
  • Loading branch information
maryamtahhan committed Nov 14, 2023
1 parent d717535 commit 8e4da0c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (

/* Devices */
devicesProhibited = []string{"eno", "eth", "lo", "docker", "flannel", "cni"} // interfaces we never add to a pool
devicesEnvVar = "AFXDP_DEVICES" // env var set in the end user application pod, lists AF_XDP devices attached
devicesEnvVarPrefix = "AFXDP_DEVICES_" // env var set in the end user application pod, lists AF_XDP devices attached
deviceValidNameRegex = `^[a-zA-Z0-9_-]+$` // regex to check if a string is a valid device name
deviceValidNameMin = 1 // minimum length of a device name
deviceValidNameMax = 50 // maximum length of a device name
Expand Down Expand Up @@ -286,7 +286,7 @@ func init() {

Devices = devices{
Prohibited: devicesProhibited,
EnvVarList: devicesEnvVar,
EnvVarList: devicesEnvVarPrefix,
ValidNameRegex: deviceValidNameRegex,
ValidNameMin: deviceValidNameMin,
ValidNameMax: deviceValidNameMax,
Expand Down
7 changes: 2 additions & 5 deletions internal/deviceplugin/poolManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,8 @@ func (pm *PoolManager) Allocate(ctx context.Context,
}
}

// MT this doesn't really work as the env var is being set per Allocate request
// Could leave the app to deduce the af_xdp device name from the path above
// or write the device name into a file in the same path as the xskmap
// or just drop altogher?
envs[constants.Devices.EnvVarList] = strings.Join(crqt.DevicesIDs[:], " ")
envVar := constants.Devices.EnvVarList + strings.ToUpper(pm.Name)
envs[envVar] = strings.Join(crqt.DevicesIDs[:], " ")
envsPrint, err := tools.PrettyString(envs)
if err != nil {
logging.Errorf("Error printing container environment variables: %v", err)
Expand Down

0 comments on commit 8e4da0c

Please sign in to comment.