agent/api/task/task_linux.go
func (task *Task) buildImplicitLinuxCPUSpec() specs.LinuxCPU {
	// If task level CPU limits are missing,
	// aggregate container CPU shares when present
	var taskCPUShares uint64
	for _, container := range task.Containers {
		if container.CPU > 0 {
			taskCPUShares += uint64(container.CPU)
		}
	}

	// If there are are no CPU limits at task or container level,
	// default task CPU shares
	if taskCPUShares == 0 {
		// Set default CPU shares
		taskCPUShares = minimumCPUShare
	}

	return specs.LinuxCPU{
		Shares: &taskCPUShares,
	}
}
func (task *Task) buildImplicitLinuxCPUSpec() specs.LinuxCPU {
	// If task level CPU limits are missing,
	// aggregate container CPU shares when present
	var taskCPUShares uint64
	for _, container := range task.Containers {
		if container.CPU > 0 {
			taskCPUShares += uint64(container.CPU)
		}
	}

	// If there are are no CPU limits at task or container level,
	// default task CPU shares
	if taskCPUShares == 0 {
		// Set default CPU shares
		taskCPUShares = minimumCPUShare
	}

	return specs.LinuxCPU{
		Shares: &taskCPUShares,
	}
}
func ( task * Task ) buildImplicitLinuxCPUSpec ( ) specs . LinuxCPU { // If task level CPU limits are missing, // aggregate container CPU shares when present var taskCPUShares uint64 for _ , container := range task . Containers { if container . CPU > 0 { taskCPUShares += uint64 ( container . CPU ) } } // If there are are no CPU limits at task or container level, // default task CPU shares if taskCPUShares == 0 { // Set default CPU shares taskCPUShares = minimumCPUShare } return specs . LinuxCPU { Shares : & taskCPUShares , } }
// buildImplicitLinuxCPUSpec builds the implicit task CPU spec when
// task CPU and memory limit feature is enabled
buildImplicitLinuxCPUSpec builds the implicit task CPU spec when task CPU and memory limit feature is enabled