diff --git a/resource/cobalt/node.go b/resource/cobalt/node.go index fcdef84aa..fc6532939 100644 --- a/resource/cobalt/node.go +++ b/resource/cobalt/node.go @@ -33,6 +33,7 @@ func (m Manager) AddNode(ctx context.Context, nodename string, opts resourcetype resps, err := call(ctx, m.plugins, func(plugin plugins.Plugin) (*plugintypes.AddNodeResponse, error) { r := opts[plugin.Name()] if r == nil { + logger.WithField("plugin", plugin.Name()).Warn(ctx, "empty plugin config") return &plugintypes.AddNodeResponse{}, nil } logger.WithField("plugin", plugin.Name()).WithField("node", nodename).Infof(ctx, "%v", litter.Sdump(r)) diff --git a/resource/plugins/cpumem/client/cpu.go b/resource/plugins/cpumem/client/cpu.go new file mode 100644 index 000000000..0e2c96112 --- /dev/null +++ b/resource/plugins/cpumem/client/cpu.go @@ -0,0 +1,35 @@ +package client + +import ( + "fmt" + "strings" + + "github.com/projecteru2/core/resource/plugins/cpumem/types" + "github.com/projecteru2/core/utils" +) + +// NewNUMAFromStr . +func NewNUMAFromStr(numa []string) (types.NUMA, error) { + r := types.NUMA{} + for index, numaCPUList := range numa { + nodeID := fmt.Sprintf("%d", index) + for _, cpuID := range strings.Split(numaCPUList, ",") { + r[cpuID] = nodeID + } + } + return r, nil +} + +// NewNUMAMemoryFromStr . +func NewNUMAMemoryFromStr(numaMemory []string) (types.NUMAMemory, error) { + r := types.NUMAMemory{} + for index, nodeMemory := range numaMemory { + nodeID := fmt.Sprintf("%d", index) + mem, err := utils.ParseRAMInHuman(nodeMemory) + if err != nil { + return r, err + } + r[nodeID] = mem + } + return r, nil +} diff --git a/resource/plugins/cpumem/types/node.go b/resource/plugins/cpumem/types/node.go index bacec47d3..9456baf2e 100644 --- a/resource/plugins/cpumem/types/node.go +++ b/resource/plugins/cpumem/types/node.go @@ -215,6 +215,7 @@ func (n *NodeResourceRequest) Parse(config coretypes.Config, rawParams resourcet } for nodeID, nodeMemory := range rawParams.RawParams("numa-memory") { + // stupid golang covert int64 to float64 when using json.unmarshal n.NUMAMemory[nodeID] = int64(nodeMemory.(float64)) } return nil diff --git a/rpc/transform.go b/rpc/transform.go index d0b2b8d44..85424f379 100644 --- a/rpc/transform.go +++ b/rpc/transform.go @@ -12,7 +12,6 @@ import ( pb "github.com/projecteru2/core/rpc/gen" "github.com/projecteru2/core/types" "github.com/projecteru2/core/utils" - "github.com/sanity-io/litter" "golang.org/x/net/context" ) @@ -540,17 +539,12 @@ func toCoreRemoveImageOptions(opts *pb.RemoveImageOptions) *types.ImageOptions { func toCoreResources(resources map[string][]byte) resourcetypes.Resources { r := resourcetypes.Resources{} for k, v := range resources { - fmt.Println("==============") - fmt.Println(k, string(v)) - fmt.Println("==============") rp := resourcetypes.RawParams{} if err := json.Unmarshal(v, &rp); err != nil { log.WithFunc("toCoreResources").Errorf(nil, err, "%v", string(v)) // nolint continue } r[k] = rp - litter.Dump(rp) - fmt.Println("==============") } return r }