@@ -46,6 +46,7 @@ import (
46
46
"k8s.io/client-go/tools/record"
47
47
utilsysctl "k8s.io/component-helpers/node/util/sysctl"
48
48
internalapi "k8s.io/cri-api/pkg/apis"
49
+ pluginwatcherapi "k8s.io/kubelet/pkg/apis/pluginregistration/v1"
49
50
podresourcesapi "k8s.io/kubelet/pkg/apis/podresources/v1"
50
51
kubefeatures "k8s.io/kubernetes/pkg/features"
51
52
"k8s.io/kubernetes/pkg/kubelet/cadvisor"
@@ -132,6 +133,8 @@ type containerManagerImpl struct {
132
133
topologyManager topologymanager.Manager
133
134
// Interface for Dynamic Resource Allocation management.
134
135
draManager dra.Manager
136
+ // kubeClient is the interface to the Kubernetes API server. May be nil if the kubelet is running in standalone mode.
137
+ kubeClient clientset.Interface
135
138
}
136
139
137
140
type features struct {
@@ -312,6 +315,7 @@ func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.I
312
315
return nil , err
313
316
}
314
317
}
318
+ cm .kubeClient = kubeClient
315
319
316
320
// Initialize CPU manager
317
321
cm .cpuManager , err = cpumanager .NewManager (
@@ -555,6 +559,7 @@ func (cm *containerManagerImpl) Status() Status {
555
559
556
560
func (cm * containerManagerImpl ) Start (ctx context.Context , node * v1.Node ,
557
561
activePods ActivePodsFunc ,
562
+ getNode GetNodeFunc ,
558
563
sourcesReady config.SourcesReady ,
559
564
podStatusProvider status.PodStatusProvider ,
560
565
runtimeService internalapi.RuntimeService ,
@@ -564,7 +569,7 @@ func (cm *containerManagerImpl) Start(ctx context.Context, node *v1.Node,
564
569
565
570
// Initialize DRA manager
566
571
if utilfeature .DefaultFeatureGate .Enabled (kubefeatures .DynamicResourceAllocation ) {
567
- err := cm .draManager .Start (ctx , dra .ActivePodsFunc (activePods ), sourcesReady )
572
+ err := cm .draManager .Start (ctx , dra .ActivePodsFunc (activePods ), dra . GetNodeFunc ( getNode ), sourcesReady )
568
573
if err != nil {
569
574
return fmt .Errorf ("start dra manager error: %w" , err )
570
575
}
@@ -649,8 +654,16 @@ func (cm *containerManagerImpl) Start(ctx context.Context, node *v1.Node,
649
654
return nil
650
655
}
651
656
652
- func (cm * containerManagerImpl ) GetPluginRegistrationHandler () cache.PluginHandler {
653
- return cm .deviceManager .GetWatcherHandler ()
657
+ func (cm * containerManagerImpl ) GetPluginRegistrationHandlers () map [string ]cache.PluginHandler {
658
+ res := map [string ]cache.PluginHandler {
659
+ pluginwatcherapi .DevicePlugin : cm .deviceManager .GetWatcherHandler (),
660
+ }
661
+
662
+ if utilfeature .DefaultFeatureGate .Enabled (kubefeatures .DynamicResourceAllocation ) {
663
+ res [pluginwatcherapi .DRAPlugin ] = cm .draManager .GetWatcherHandler ()
664
+ }
665
+
666
+ return res
654
667
}
655
668
656
669
// TODO: move the GetResources logic to PodContainerManager.
0 commit comments