Skip to content

Commit f7e4a45

Browse files
committed
CD daemon: always mount in IMEX daemon config files
Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]> CD plugin: always prepare IMEX config on the host and mount it in Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]>
1 parent c040429 commit f7e4a45

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

cmd/compute-domain-kubelet-plugin/computedomain.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ func (m *ComputeDomainManager) GetComputeDomainDaemonContainerEdits(ctx context.
168168

169169
edits := &cdiapi.ContainerEdits{
170170
ContainerEdits: &cdispec.ContainerEdits{
171+
Mounts: []*cdispec.Mount{
172+
{
173+
ContainerPath: "/etc/nvidia-imex",
174+
HostPath: fmt.Sprintf("%s/%s", m.configFilesRoot, domainID),
175+
Options: []string{"rw", "nosuid", "nodev", "bind"},
176+
},
177+
},
171178
Env: []string{
172179
fmt.Sprintf("CLIQUE_ID=%s", m.cliqueID),
173180
fmt.Sprintf("COMPUTE_DOMAIN_UUID=%s", cd.UID),
@@ -184,17 +191,10 @@ func (s *ComputeDomainDaemonSettings) GetDomainID() string {
184191
}
185192

186193
// GetCDIContainerEditsForImex() returns the CDI spec edits only required for
187-
// launching the CD Daemon when it actually wraps an IMEX daemon.
194+
// launching the CD daemon when it actually wraps an IMEX daemon.
188195
func (s *ComputeDomainDaemonSettings) GetCDIContainerEditsForImex(ctx context.Context, devRoot string, info *nvcapDeviceInfo) *cdiapi.ContainerEdits {
189196
edits := &cdiapi.ContainerEdits{
190197
ContainerEdits: &cdispec.ContainerEdits{
191-
Mounts: []*cdispec.Mount{
192-
{
193-
ContainerPath: "/etc/nvidia-imex",
194-
HostPath: s.rootDir,
195-
Options: []string{"rw", "nosuid", "nodev", "bind"},
196-
},
197-
},
198198
DeviceNodes: []*cdispec.DeviceNode{
199199
{
200200
Path: info.path,

cmd/compute-domain-kubelet-plugin/device_state.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -500,23 +500,27 @@ func (s *DeviceState) applyComputeDomainDaemonConfig(ctx context.Context, config
500500
}
501501
configState.containerEdits = configState.containerEdits.Append(edits)
502502

503-
// Only prepare files to inject to the daemon if IMEX is supported.
503+
// Create new ComputeDomain daemon settings from the ComputeDomainManager.
504+
computeDomainDaemonSettings := s.computeDomainManager.NewSettings(config.DomainID)
505+
506+
// Prepare injecting IMEX daemon config files even if IMEX is not supported.
507+
// This for example creates
508+
// '/var/lib/kubelet/plugins/compute-domain.nvidia.com/domains/<uid>' on the
509+
// host which is used as mount source mapped to /etc/nvidia-imex in the CD
510+
// daemon container.
511+
if err := computeDomainDaemonSettings.Prepare(ctx); err != nil {
512+
return nil, fmt.Errorf("error preparing ComputeDomain daemon settings for requests '%v' in claim '%v': %w", requests, claim.UID, err)
513+
}
514+
515+
// Only inject dev nodes related to
516+
// /proc/driver/nvidia/capabilities/fabric-imex-mgmt if IMEX is supported
517+
// (if we want to start the IMEX daemon process in the CD daemon pod).
504518
if s.computeDomainManager.cliqueID != "" {
505519
// Parse the device node info for the fabric-imex-mgmt nvcap.
506520
nvcapDeviceInfo, err := s.nvdevlib.parseNVCapDeviceInfo(nvidiaCapFabricImexMgmtPath)
507521
if err != nil {
508522
return nil, fmt.Errorf("error parsing nvcap device info for fabric-imex-mgmt: %w", err)
509523
}
510-
511-
// Create new ComputeDomain daemon settings from the ComputeDomainManager.
512-
computeDomainDaemonSettings := s.computeDomainManager.NewSettings(config.DomainID)
513-
514-
// Prepare the new ComputeDomain daemon.
515-
if err := computeDomainDaemonSettings.Prepare(ctx); err != nil {
516-
return nil, fmt.Errorf("error preparing ComputeDomain daemon settings for requests '%v' in claim '%v': %w", requests, claim.UID, err)
517-
}
518-
519-
// Store information about the ComputeDomain daemon in the configState.
520524
edits := computeDomainDaemonSettings.GetCDIContainerEditsForImex(ctx, s.cdi.devRoot, nvcapDeviceInfo)
521525
configState.containerEdits = configState.containerEdits.Append(edits)
522526
}

0 commit comments

Comments
 (0)