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

markusthoemmes pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new 86d238a  Temporarily disables attachment inlining logic by setting 
max-inline-size to zero until #3770 is fixed. (#3771)
86d238a is described below

commit 86d238ae51f7dd839d834d85230bdd4592673192
Author: Chetan Mehrotra <chet...@apache.org>
AuthorDate: Sat Jun 16 15:37:52 2018 +0530

    Temporarily disables attachment inlining logic by setting max-inline-size 
to zero until #3770 is fixed. (#3771)
    
    Fixes #3769. See #3770 for details
---
 common/scala/src/main/resources/application.conf   |  2 +-
 .../whisk/core/database/CouchDbRestStore.scala     | 42 +++++++++++++---------
 .../core/controller/test/ActionsApiTests.scala     |  1 +
 .../scala/whisk/core/database/test/DbUtils.scala   |  7 +++-
 .../ArtifactStoreAttachmentBehaviors.scala         |  2 ++
 5 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/common/scala/src/main/resources/application.conf 
b/common/scala/src/main/resources/application.conf
index dbc70c5..233423b 100644
--- a/common/scala/src/main/resources/application.conf
+++ b/common/scala/src/main/resources/application.conf
@@ -117,7 +117,7 @@ whisk {
 
         # Size limit for inlined attachments. Attachments having size less 
than this would
         # be inlined with there content encoded in attachmentName
-        max-inline-size = 16 k
+        max-inline-size = 0 k
 
         # Chunk sized for converting source of bytes to ByteString as part of 
attachment
         # upload flow
diff --git 
a/common/scala/src/main/scala/whisk/core/database/CouchDbRestStore.scala 
b/common/scala/src/main/scala/whisk/core/database/CouchDbRestStore.scala
index 44579d3..853adea 100644
--- a/common/scala/src/main/scala/whisk/core/database/CouchDbRestStore.scala
+++ b/common/scala/src/main/scala/whisk/core/database/CouchDbRestStore.scala
@@ -372,24 +372,34 @@ class CouchDbRestStore[DocumentAbstraction <: 
DocumentSerializer](dbProtocol: St
     update: (A, Attached) => A,
     contentType: ContentType,
     docStream: Source[ByteString, _])(implicit transid: TransactionId) = {
-    for {
-      (bytes, tailSource) <- inlineAndTail(docStream)
-      uri <- Future.successful(uriOf(bytes, UUID().asString))
-      attached <- {
-        val a = if (isInlined(uri)) {
-          Attached(uri.toString, contentType, Some(bytes.size), 
Some(digest(bytes)))
+
+    if (maxInlineSize.toBytes == 0) {
+      val uri = Uri.from(scheme = attachmentScheme, path = UUID().asString)
+      for {
+        attached <- Future.successful(Attached(uri.toString, contentType))
+        i1 <- put(update(doc, attached))
+        i2 <- attach(i1, uri.path.toString, attached.attachmentType, docStream)
+      } yield (i2, attached)
+    } else {
+      for {
+        (bytes, tailSource) <- inlineAndTail(docStream)
+        uri <- Future.successful(uriOf(bytes, UUID().asString))
+        attached <- {
+          val a = if (isInlined(uri)) {
+            Attached(uri.toString, contentType, Some(bytes.size), 
Some(digest(bytes)))
+          } else {
+            Attached(uri.toString, contentType)
+          }
+          Future.successful(a)
+        }
+        i1 <- put(update(doc, attached))
+        i2 <- if (isInlined(uri)) {
+          Future.successful(i1)
         } else {
-          Attached(uri.toString, contentType)
+          attach(i1, uri.path.toString, attached.attachmentType, 
combinedSource(bytes, tailSource))
         }
-        Future.successful(a)
-      }
-      i1 <- put(update(doc, attached))
-      i2 <- if (isInlined(uri)) {
-        Future.successful(i1)
-      } else {
-        attach(i1, uri.path.toString, attached.attachmentType, 
combinedSource(bytes, tailSource))
-      }
-    } yield (i2, attached)
+      } yield (i2, attached)
+    }
   }
 
   private def attachToExternalStore[A <: DocumentAbstraction](
diff --git 
a/tests/src/test/scala/whisk/core/controller/test/ActionsApiTests.scala 
b/tests/src/test/scala/whisk/core/controller/test/ActionsApiTests.scala
index 18fc125..ce6529e 100644
--- a/tests/src/test/scala/whisk/core/controller/test/ActionsApiTests.scala
+++ b/tests/src/test/scala/whisk/core/controller/test/ActionsApiTests.scala
@@ -859,6 +859,7 @@ class ActionsApiTests extends ControllerTestCommon with 
WhiskActionsApi {
   }
 
   it should "put and then get an action with inlined attachment" in {
+    assumeAttachmentInliningEnabled(entityStore)
     val action =
       WhiskAction(
         namespace,
diff --git a/tests/src/test/scala/whisk/core/database/test/DbUtils.scala 
b/tests/src/test/scala/whisk/core/database/test/DbUtils.scala
index 2b39fd3..47c884a 100644
--- a/tests/src/test/scala/whisk/core/database/test/DbUtils.scala
+++ b/tests/src/test/scala/whisk/core/database/test/DbUtils.scala
@@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger
 import akka.http.scaladsl.model.ContentType
 import akka.stream.scaladsl.Source
 import akka.util.ByteString
+import org.scalatest.Assertions
 import spray.json.DefaultJsonProtocol._
 import spray.json._
 import whisk.common.TransactionId
@@ -45,7 +46,7 @@ import scala.util.{Failure, Random, Success, Try}
  * operations with those that flow through the cache. To mitigate this, use 
unique asset
  * names in tests, and defer all cleanup to the end of a test suite.
  */
-trait DbUtils {
+trait DbUtils extends Assertions {
   implicit val dbOpTimeout = 15 seconds
   val instance = InstanceId(0)
   val docsToDelete = ListBuffer[(ArtifactStore[_], DocInfo)]()
@@ -316,6 +317,10 @@ trait DbUtils {
     }
   }
 
+  def assumeAttachmentInliningEnabled(db: ArtifactStore[_]): Unit = {
+    assume(inlinedAttachmentSize(db) > 0, "Attachment inlining is disabled")
+  }
+
   protected def encodedRandomBytes(size: Int): String = 
Base64.getEncoder.encodeToString(randomBytes(size))
 
   def isMemoryStore(store: ArtifactStore[_]): Boolean = 
store.isInstanceOf[MemoryArtifactStore[_]]
diff --git 
a/tests/src/test/scala/whisk/core/database/test/behavior/ArtifactStoreAttachmentBehaviors.scala
 
b/tests/src/test/scala/whisk/core/database/test/behavior/ArtifactStoreAttachmentBehaviors.scala
index de7a7a8..a32eb28 100644
--- 
a/tests/src/test/scala/whisk/core/database/test/behavior/ArtifactStoreAttachmentBehaviors.scala
+++ 
b/tests/src/test/scala/whisk/core/database/test/behavior/ArtifactStoreAttachmentBehaviors.scala
@@ -90,6 +90,7 @@ trait ArtifactStoreAttachmentBehaviors extends 
ArtifactStoreBehaviorBase with Ex
    * if attachment is inlined
    */
   it should "work on reading with old inlined attachment" in {
+    assumeAttachmentInliningEnabled(entityStore)
     implicit val tid: TransactionId = transid()
     val code1 = encodedRandomBytes(inlinedAttachmentSize(entityStore))
     val exec = javaDefault(code1, Some("hello"))
@@ -140,6 +141,7 @@ trait ArtifactStoreAttachmentBehaviors extends 
ArtifactStoreBehaviorBase with Ex
   }
 
   it should "inline small attachments" in {
+    assumeAttachmentInliningEnabled(entityStore)
     implicit val tid: TransactionId = transid()
     val attachmentSize = inlinedAttachmentSize(entityStore) - 1
     val base64 = encodedRandomBytes(attachmentSize)

-- 
To stop receiving notification emails like this one, please contact
markusthoem...@apache.org.

Reply via email to