diff --git a/k8s/jobs/desire_test.go b/k8s/jobs/desire_test.go index f0566724d..f99e42809 100644 --- a/k8s/jobs/desire_test.go +++ b/k8s/jobs/desire_test.go @@ -66,7 +66,7 @@ var _ = Describe("Desire", func() { OrgGUID: "org-id", GUID: taskGUID, MemoryMB: 1, - CPUWeight: 2, + CPUMillis: 2, DiskMB: 3, }, } diff --git a/k8s/jobs/task_to_job.go b/k8s/jobs/task_to_job.go index 0d4f84939..81bd529c0 100644 --- a/k8s/jobs/task_to_job.go +++ b/k8s/jobs/task_to_job.go @@ -59,6 +59,7 @@ func (m *Converter) Convert(task *eiriniv1.Task, privateRegistrySecret *corev1.S Requests: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceMemory: *resource.NewScaledQuantity(task.Spec.MemoryMB, resource.Mega), corev1.ResourceEphemeralStorage: *resource.NewScaledQuantity(task.Spec.DiskMB, resource.Mega), + corev1.ResourceCPU: *resource.NewScaledQuantity(task.Spec.CPUMillis, resource.Milli), }, }, SecurityContext: k8s.ContainerSecurityContext(), diff --git a/k8s/jobs/task_to_job_test.go b/k8s/jobs/task_to_job_test.go index 2bdf4501f..d0aa9a848 100644 --- a/k8s/jobs/task_to_job_test.go +++ b/k8s/jobs/task_to_job_test.go @@ -73,7 +73,7 @@ var _ = Describe("TaskToJob", func() { "my-env-var": "env", }, MemoryMB: 1, - CPUWeight: 2, + CPUMillis: 2, DiskMB: 3, }, } @@ -144,10 +144,11 @@ var _ = Describe("TaskToJob", func() { By("setting limits and request", func() { resources := job.Spec.Template.Spec.Containers[0].Resources - Expect(resources.Limits.Memory().ScaledValue(resource.Mega)).To(BeNumerically("==", 1)) - Expect(resources.Requests.Memory().ScaledValue(resource.Mega)).To(BeNumerically("==", 1)) - Expect(resources.Limits.StorageEphemeral().ScaledValue(resource.Mega)).To(BeNumerically("==", 3)) - Expect(resources.Requests.StorageEphemeral().ScaledValue(resource.Mega)).To(BeNumerically("==", 3)) + Expect(resources.Limits.Memory().ScaledValue(resource.Mega)).To(BeEquivalentTo(1)) + Expect(resources.Requests.Memory().ScaledValue(resource.Mega)).To(BeEquivalentTo(1)) + Expect(resources.Limits.StorageEphemeral().ScaledValue(resource.Mega)).To(BeEquivalentTo(3)) + Expect(resources.Requests.StorageEphemeral().ScaledValue(resource.Mega)).To(BeEquivalentTo(3)) + Expect(resources.Requests.Cpu().ScaledValue(resource.Milli)).To(BeEquivalentTo(2)) }) By("configuring pod security context", func() { diff --git a/k8s/reconciler/task_test.go b/k8s/reconciler/task_test.go index f4367e3d2..4aa2aa70d 100644 --- a/k8s/reconciler/task_test.go +++ b/k8s/reconciler/task_test.go @@ -100,7 +100,7 @@ var _ = Describe("Task", func() { SpaceGUID: "spacid", MemoryMB: 768, DiskMB: 512, - CPUWeight: 13, + CPUMillis: 13, }, } statusGetter.GetStatusConditionsReturns([]metav1.Condition{ diff --git a/pkg/apis/eirini/v1/task.go b/pkg/apis/eirini/v1/task.go index c75f665b1..19cdb93b7 100644 --- a/pkg/apis/eirini/v1/task.go +++ b/pkg/apis/eirini/v1/task.go @@ -41,8 +41,7 @@ type TaskSpec struct { SpaceGUID string `json:"spaceGUID"` MemoryMB int64 `json:"memoryMB"` DiskMB int64 `json:"diskMB"` - // +kubebuilder:validation:Format:=uint8 - CPUWeight uint8 `json:"cpuWeight"` + CPUMillis int64 `json:"cpuMillis"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object