func parseResourceMemory(flags *pflag.FlagSet, resources *api.Resources, name string) error { memory, err := flags.GetString(name) if err != nil { return err } bytes, err := units.RAMInBytes(memory) if err != nil { return err } resources.MemoryBytes = bytes return nil }
func (s *Scheduler) createOrUpdateNode(n *api.Node) { nodeInfo, _ := s.nodeHeap.nodeInfo(n.ID) var resources api.Resources if n.Description != nil && n.Description.Resources != nil { resources = *n.Description.Resources // reconcile resources by looping over all tasks in this node for _, task := range nodeInfo.Tasks { reservations := taskReservations(task.Spec) resources.MemoryBytes -= reservations.MemoryBytes resources.NanoCPUs -= reservations.NanoCPUs } } nodeInfo.Node = n nodeInfo.AvailableResources = resources s.nodeHeap.addOrUpdateNode(nodeInfo) }