You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2020/03/12 16:45:42 UTC

[GitHub] [openwhisk] tysonnorris commented on a change in pull request #4814: Kcf - optional cpu resource scaling based on action memory

tysonnorris commented on a change in pull request #4814: Kcf - optional cpu resource scaling based on action memory
URL: https://github.com/apache/openwhisk/pull/4814#discussion_r391752179
 
 

 ##########
 File path: core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/WhiskPodBuilder.scala
 ##########
 @@ -113,6 +121,13 @@ class WhiskPodBuilder(client: NamespacedKubernetesClient,
     pod
   }
 
+  def calculateCpu(c: KubernetesCpuScalingConfig, memory: ByteSize): Int = {
+    val cpuPerMemorySegment = c.millicpus
+    val cpuMin = c.millicpus
+    val cpuMax = c.maxMillicpus
+    math.min(math.max((memory.toMB / c.memory.toMB) * cpuPerMemorySegment, cpuMin), cpuMax).toInt
 
 Review comment:
   Currently calculation is always in millicpu in all cases - we append "m" to the pod spec cpu limit. So truncating the decimal places works. If instead of configuring 100 for the cpu per mem segment in millicpu, we could configure it as 0.1 and truncate the decimal (not sure if kubernetes cares about how many decimals are used for cpu?). Millicpu seemed more readable, but I don't have a strong opinion. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services