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/02/01 00:01:39 UTC

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

tysonnorris opened a new pull request #4814: Kcf - optional cpu resource scaling based on action memory
URL: https://github.com/apache/openwhisk/pull/4814
 
 
   <!--- Provide a concise summary of your changes in the Title -->
   Allow kubernetes operators to specify configuration to cause pods to request cpu (resources in addition to memory resources) based on scaling the configured action memory.
   
   ## Description
   
   ## Related issue and scope
   <!--- Please include a link to a related issue if there is one. -->
   - [ ] I opened an issue to propose and discuss this change (#????)
   
   ## My changes affect the following components
   <!--- Select below all system components are affected by your change. -->
   <!--- Enter an `x` in all applicable boxes. -->
   - [ ] API
   - [ ] Controller
   - [ ] Message Bus (e.g., Kafka)
   - [ ] Loadbalancer
   - [x] Invoker
   - [ ] Intrinsic actions (e.g., sequences, conductors)
   - [ ] Data stores (e.g., CouchDB)
   - [ ] Tests
   - [ ] Deployment
   - [ ] CLI
   - [ ] General tooling
   - [ ] Documentation
   
   ## Types of changes
   <!--- What types of changes does your code introduce? Use `x` in all the boxes that apply: -->
   - [ ] Bug fix (generally a non-breaking change which closes an issue).
   - [x] Enhancement or new feature (adds new functionality).
   - [ ] Breaking change (a bug fix or enhancement which changes existing behavior).
   
   ## Checklist:
   <!--- Please review the points below which help you make sure you've covered all aspects of the change you're making. -->
   
   - [x] I signed an [Apache CLA](https://github.com/apache/openwhisk/blob/master/CONTRIBUTING.md).
   - [x] I reviewed the [style guides](https://github.com/apache/openwhisk/wiki/Contributing:-Git-guidelines#code-readiness) and followed the recommendations (Travis CI will check :).
   - [x] I added tests to cover my changes.
   - [ ] My changes require further changes to the documentation.
   - [ ] I updated the documentation where necessary.
   
   

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
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  - 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

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

Posted by GitBox <gi...@apache.org>.
tysonnorris merged pull request #4814: Kcf - optional cpu resource scaling based on action memory
URL: https://github.com/apache/openwhisk/pull/4814
 
 
   

----------------------------------------------------------------
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

[GitHub] [openwhisk] dgrove-oss commented on issue #4814: Kcf - optional cpu resource scaling based on action memory

Posted by GitBox <gi...@apache.org>.
dgrove-oss commented on issue #4814: Kcf - optional cpu resource scaling based on action memory
URL: https://github.com/apache/openwhisk/pull/4814#issuecomment-581645660
 
 
   creating docs/kubernetes.md to capture core settings/configuration choices that are kubernetes specific seems plausible to me.  Not needed for this PR, but that might also be a good place to document how to configure the default pod spec for user action containers with KCF.  Its been a common question on slack.

----------------------------------------------------------------
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

[GitHub] [openwhisk] tysonnorris commented on issue #4814: Kcf - optional cpu resource scaling based on action memory

Posted by GitBox <gi...@apache.org>.
tysonnorris commented on issue #4814: Kcf - optional cpu resource scaling based on action memory
URL: https://github.com/apache/openwhisk/pull/4814#issuecomment-581556440
 
 
   I can either create a docs/kubernetes.md, or add something to https://github.com/apache/openwhisk-deploy-kube/blob/master/docs/configurationChoices.md#invoker-container-factory. I guess for now I would add a docs/kubernetes.md -WDYT?

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
chetanmeh 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_r391403702
 
 

 ##########
 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:
   @tysonnorris Just checking if we should be casting to `double` here as its an integer based division

----------------------------------------------------------------
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

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

Posted by GitBox <gi...@apache.org>.
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