This is an automated email from the ASF dual-hosted git repository.

mcdan pushed a commit to branch mcdan/disk-limit
in repository https://gitbox.apache.org/repos/asf/openwhisk.git

commit 998c4cb056ab9b760068c0b5719a04228d43ef2b
Author: mcweeney <[email protected]>
AuthorDate: Thu Jun 4 15:54:27 2020 -0400

    Only allow the configuraiton of the limit for ephemeral to prevent action 
eviction due to resource constraint
---
 core/invoker/src/main/resources/application.conf                   | 1 -
 .../openwhisk/core/containerpool/kubernetes/KubernetesClient.scala | 5 ++---
 .../openwhisk/core/containerpool/kubernetes/WhiskPodBuilder.scala  | 7 ++-----
 .../core/containerpool/kubernetes/test/WhiskPodBuilderTests.scala  | 4 ++--
 4 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/core/invoker/src/main/resources/application.conf 
b/core/invoker/src/main/resources/application.conf
index 3c2212d..f5afc0c 100644
--- a/core/invoker/src/main/resources/application.conf
+++ b/core/invoker/src/main/resources/application.conf
@@ -112,7 +112,6 @@ whisk {
     #See: 
https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#local-ephemeral-storage
     #ephemeral-storage {
     #  limit = 2 g
-    #  request = 500 m
     #}
 
     #enable PodDisruptionBudget creation for pods? (will include same labels 
as pods, and specify minAvailable=1 to prevent termination of action pods 
during maintenance)
diff --git 
a/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/KubernetesClient.scala
 
b/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/KubernetesClient.scala
index f7c7874..3dea020 100644
--- 
a/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/KubernetesClient.scala
+++ 
b/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/KubernetesClient.scala
@@ -70,10 +70,9 @@ case class KubernetesClientTimeoutConfig(run: 
FiniteDuration, logs: FiniteDurati
 case class KubernetesCpuScalingConfig(millicpus: Int, memory: ByteSize, 
maxMillicpus: Int)
 
 /**
- * Configuration for kubernetes cpu resource request/limit scaling based on 
action memory limit
+ * Configuration for kubernetes ephemeral storage limit for the action 
container
  */
-case class KubernetesEphemeralStorageConfig(request: ByteSize, limit: ByteSize)
-
+case class KubernetesEphemeralStorageConfig(limit: ByteSize)
 
 /**
  * Exception to indicate a pod took too long to become ready.
diff --git 
a/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/WhiskPodBuilder.scala
 
b/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/WhiskPodBuilder.scala
index 5313bf7..a012a07 100644
--- 
a/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/WhiskPodBuilder.scala
+++ 
b/core/invoker/src/main/scala/org/apache/openwhisk/core/containerpool/kubernetes/WhiskPodBuilder.scala
@@ -107,11 +107,8 @@ class WhiskPodBuilder(client: NamespacedKubernetesClient, 
config: KubernetesClie
       .map(cpuConfig => Map("cpu" -> new Quantity(calculateCpu(cpuConfig, 
memory) + "m")))
       .getOrElse(Map.empty)
 
-    val diskRequest = config.ephmeralStorage
-        .map(diskConfig => Map("ephemeral-storage"-> new 
Quantity(diskConfig.request.toMB + "Mi")))
-        .getOrElse(Map.empty)
     val diskLimit = config.ephmeralStorage
-      .map(diskConfig => Map("ephemeral-storage"-> new 
Quantity(diskConfig.limit.toMB + "Mi")))
+      .map(diskConfig => Map("ephemeral-storage" -> new 
Quantity(diskConfig.limit.toMB + "Mi")))
       .getOrElse(Map.empty)
 
     //In container its assumed that env, port, resource limits are set 
explicitly
@@ -120,7 +117,7 @@ class WhiskPodBuilder(client: NamespacedKubernetesClient, 
config: KubernetesClie
       .withNewResources()
       //explicitly set requests and limits to same values
       .withLimits((Map("memory" -> new Quantity(memory.toMB + "Mi")) ++ cpu ++ 
diskLimit).asJava)
-      .withRequests((Map("memory" -> new Quantity(memory.toMB + "Mi")) ++ cpu 
++ diskRequest).asJava)
+      .withRequests((Map("memory" -> new Quantity(memory.toMB + "Mi")) ++ cpu 
++ diskLimit).asJava)
       .endResources()
       .withName("user-action")
       .withImage(image)
diff --git 
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/kubernetes/test/WhiskPodBuilderTests.scala
 
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/kubernetes/test/WhiskPodBuilderTests.scala
index df9b03b..93bc4b3 100644
--- 
a/tests/src/test/scala/org/apache/openwhisk/core/containerpool/kubernetes/test/WhiskPodBuilderTests.scala
+++ 
b/tests/src/test/scala/org/apache/openwhisk/core/containerpool/kubernetes/test/WhiskPodBuilderTests.scala
@@ -133,13 +133,13 @@ class WhiskPodBuilderTests extends FlatSpec with Matchers 
with KubeClientSupport
       Some(KubernetesCpuScalingConfig(300, 3.MB, 1000)),
       false,
       None,
-      Some(KubernetesEphemeralStorageConfig(1.GB, 2.GB)))
+      Some(KubernetesEphemeralStorageConfig(1.GB)))
     val builder = new WhiskPodBuilder(kubeClient, config)
 
     val (pod, _) = builder.buildPodSpec(name, testImage, 2.MB, Map("foo" -> 
"bar"), Map("fooL" -> "barV"), config)
     withClue(Serialization.asYaml(pod)) {
       val c = getActionContainer(pod)
-      
c.getResources.getLimits.asScala.get("ephemeral-storage").map(_.getAmount) 
shouldBe Some("2048Mi")
+      
c.getResources.getLimits.asScala.get("ephemeral-storage").map(_.getAmount) 
shouldBe Some("1024Mi")
       
c.getResources.getRequests.asScala.get("ephemeral-storage").map(_.getAmount) 
shouldBe Some("1024Mi")
     }
   }

Reply via email to