Skip to content

Commit 1102960

Browse files
committed
CD plugin: move CDI edit gen into computeDomainDaemonSettings
Signed-off-by: Dr. Jan-Philip Gehrcke <[email protected]>
1 parent f7e4a45 commit 1102960

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,29 +154,29 @@ func (m *ComputeDomainManager) GetComputeDomainChannelContainerEdits(devRoot str
154154
}
155155
}
156156

157-
// GetComputeDomainDaemonContainerEdits() returns the CDI spec edits always
158-
// required for launching the CD Daemon (whether or not it tries to launch an
159-
// IMEX daemon internally).
160-
func (m *ComputeDomainManager) GetComputeDomainDaemonContainerEdits(ctx context.Context, domainID string) (*cdiapi.ContainerEdits, error) {
161-
cd, err := m.GetComputeDomain(ctx, domainID)
157+
// GetCommonCDIContainerEdits() returns the CDI spec edits always required for
158+
// launching the CD Daemon (whether or not it tries to launch an IMEX daemon
159+
// internally).
160+
func (s *ComputeDomainDaemonSettings) GetCommonCDIContainerEdits(ctx context.Context) (*cdiapi.ContainerEdits, error) {
161+
cd, err := s.manager.GetComputeDomain(ctx, s.domainID)
162162
if err != nil {
163-
return nil, fmt.Errorf("error getting compute domain %s: %w", domainID, err)
163+
return nil, fmt.Errorf("error getting compute domain %s: %w", s.domainID, err)
164164
}
165165
if cd == nil {
166-
return nil, fmt.Errorf("compute domain not found: %s", domainID)
166+
return nil, fmt.Errorf("compute domain not found: %s", s.domainID)
167167
}
168168

169169
edits := &cdiapi.ContainerEdits{
170170
ContainerEdits: &cdispec.ContainerEdits{
171171
Mounts: []*cdispec.Mount{
172172
{
173173
ContainerPath: "/etc/nvidia-imex",
174-
HostPath: fmt.Sprintf("%s/%s", m.configFilesRoot, domainID),
174+
HostPath: s.rootDir,
175175
Options: []string{"rw", "nosuid", "nodev", "bind"},
176176
},
177177
},
178178
Env: []string{
179-
fmt.Sprintf("CLIQUE_ID=%s", m.cliqueID),
179+
fmt.Sprintf("CLIQUE_ID=%s", s.manager.cliqueID),
180180
fmt.Sprintf("COMPUTE_DOMAIN_UUID=%s", cd.UID),
181181
fmt.Sprintf("COMPUTE_DOMAIN_NAME=%s", cd.Name),
182182
fmt.Sprintf("COMPUTE_DOMAIN_NAMESPACE=%s", cd.Namespace),

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -492,14 +492,6 @@ func (s *DeviceState) applyComputeDomainDaemonConfig(ctx context.Context, config
492492
ComputeDomain: config.DomainID,
493493
}
494494

495-
// Always inject CD config details into the CD daemon (regardless of clique
496-
// ID being empty or not).
497-
edits, err := s.computeDomainManager.GetComputeDomainDaemonContainerEdits(ctx, config.DomainID)
498-
if err != nil {
499-
return nil, fmt.Errorf("error preparing ComputeDomain daemon settings: %w", err)
500-
}
501-
configState.containerEdits = configState.containerEdits.Append(edits)
502-
503495
// Create new ComputeDomain daemon settings from the ComputeDomainManager.
504496
computeDomainDaemonSettings := s.computeDomainManager.NewSettings(config.DomainID)
505497

@@ -512,6 +504,14 @@ func (s *DeviceState) applyComputeDomainDaemonConfig(ctx context.Context, config
512504
return nil, fmt.Errorf("error preparing ComputeDomain daemon settings for requests '%v' in claim '%v': %w", requests, claim.UID, err)
513505
}
514506

507+
// Always inject CD config details into the CD daemon (regardless of clique
508+
// ID being empty or not).
509+
edits, err := computeDomainDaemonSettings.GetCommonCDIContainerEdits(ctx)
510+
if err != nil {
511+
return nil, fmt.Errorf("error getting common container edits for ComputeDomain daemon '%s': %w", config.DomainID, err)
512+
}
513+
configState.containerEdits = configState.containerEdits.Append(edits)
514+
515515
// Only inject dev nodes related to
516516
// /proc/driver/nvidia/capabilities/fabric-imex-mgmt if IMEX is supported
517517
// (if we want to start the IMEX daemon process in the CD daemon pod).

0 commit comments

Comments
 (0)