mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-09-12 12:34:53 +00:00
add kubelet client for Pod resource info
This change introduces kubelet client to get allocated device information of a Pod from newly added Kubelet grpc service. For more information please see: [kubernetes/kubernetes#70508](https://github.com/kubernetes/kubernetes/pull/70508) Change-Id: I11e58ccdd52662601f445fa24c7d55c225441efc Signed-off-by: Abdul Halim <abdul.halim@intel.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
"github.com/intel/multus-cni/logging"
|
||||
"github.com/intel/multus-cni/types"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -45,22 +46,18 @@ type Data struct {
|
||||
Checksum uint64
|
||||
}
|
||||
|
||||
type Checkpoint interface {
|
||||
// GetComputeDeviceMap returns an instance of a map of ResourceInfo for a PodID
|
||||
GetComputeDeviceMap(string) (map[string]*types.ResourceInfo, error)
|
||||
}
|
||||
type checkpoint struct {
|
||||
fileName string
|
||||
podEntires []PodDevicesEntry
|
||||
}
|
||||
|
||||
// GetCheckpoint returns an instance of Checkpoint
|
||||
func GetCheckpoint() (Checkpoint, error) {
|
||||
func GetCheckpoint() (types.ResourceClient, error) {
|
||||
logging.Debugf("GetCheckpoint(): invoked")
|
||||
return getCheckpoint(checkPointfile)
|
||||
}
|
||||
|
||||
func getCheckpoint(filePath string) (Checkpoint, error) {
|
||||
func getCheckpoint(filePath string) (types.ResourceClient, error) {
|
||||
cp := &checkpoint{fileName: filePath}
|
||||
err := cp.getPodEntries()
|
||||
if err != nil {
|
||||
@@ -89,12 +86,12 @@ func (cp *checkpoint) getPodEntries() error {
|
||||
}
|
||||
|
||||
// GetComputeDeviceMap returns an instance of a map of ResourceInfo
|
||||
func (cp *checkpoint) GetComputeDeviceMap(podID string) (map[string]*types.ResourceInfo, error) {
|
||||
|
||||
func (cp *checkpoint) GetPodResourceMap(pod *v1.Pod) (map[string]*types.ResourceInfo, error) {
|
||||
podID := string(pod.UID)
|
||||
resourceMap := make(map[string]*types.ResourceInfo)
|
||||
|
||||
if podID == "" {
|
||||
return nil, logging.Errorf("GetComputeDeviceMap(): invalid Pod cannot be empty")
|
||||
return nil, logging.Errorf("GetPodResourceMap(): invalid Pod cannot be empty")
|
||||
}
|
||||
|
||||
for _, pod := range cp.podEntires {
|
||||
|
Reference in New Issue
Block a user