Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat action code as attachments for created/updated actions #2847

Closed
wants to merge 6 commits into from

Conversation

dubee
Copy link
Member

@dubee dubee commented Oct 10, 2017

Save action code as attachments in the database for new or updated actions.

Depends on #2832 to get whisk.core.controller.test.ActionsApiTests > Actions API should put and then get action from cache test to pass.

I combined these changes with #2730 and performed profiling on the controller.

Here is a graph of the heap monitoring when invoking a 34MB zipped action:

screen shot 2017-10-10 at 11 59 37 am

Previously invoking a 34MB non-cached action would result in a spike in heap usage when only using changes in #2730:

30878095-c7623960-a2c9-11e7-9cc0-f17af3120f67

@dubee
Copy link
Member Author

dubee commented Oct 10, 2017

@csantanapr, FYI.

@dubee dubee force-pushed the code-attach branch 4 times, most recently from 9d2e029 to 67f8765 Compare October 11, 2017 21:53
case _ =>
obj.fields.get("binary") match {
case Some(JsBoolean(b)) => b
case _ => false
Copy link
Member Author

@dubee dubee Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably error here since code and binary property is not defined.

@@ -138,7 +138,7 @@ class ActionsApiTests extends ControllerTestCommon with WhiskActionsApi {
Get(s"$collectionPath/${action.name}") ~> Route.seal(routes(creds)) ~> check {
status should be(OK)
val response = responseAs[WhiskAction]
response should be(action)
response.toJson should be(action.toJson)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct comparison of the WhiskAction here fails. However, comparing the actions as JSON seems to work.

@dubee dubee force-pushed the code-attach branch 2 times, most recently from 96b143b to f7f3b6a Compare October 12, 2017 06:09
@dubee dubee changed the title Treat action code as attachments for created/update actions Treat action code as attachments for created/updated actions Oct 12, 2017
} map {
attFmt[String].read(_)
} getOrElse {
throw new DeserializationException(
s"'code' must be a valid base64 string in 'exec' for '$kind' actions")
throw new DeserializationException(s"'code' must be a string defined in 'exec' for '$kind' actions")
Copy link
Member Author

@dubee dubee Oct 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we will ever get here. Since I think the function in map will work even for an empty string.

@dubee dubee requested a review from rabbah October 16, 2017 18:46
@dubee dubee added review Review for this PR has been requested and yet needs to be done. and removed wip labels Oct 16, 2017
@dubee
Copy link
Member Author

dubee commented Oct 16, 2017

Can expand tests from #2855 after that one is merged.

@dubee
Copy link
Member Author

dubee commented Oct 16, 2017

whisk.core.database.test.CacheConcurrencyTests > the cache should support concurrent CRUD without bogus residual cache entries, iter 1 FAILED

Failure is a result of parallel action gets with updates. I think this test fails because there is now an extra database write for the attachment that causes the action get to fail as it does not have the correct document revision.

Copy link
Member

@rabbah rabbah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks generally good - I'm surprised no test changes were required. I suspect because tests check for action equality which will be opaque to the attachment change.

We will need a test which shows the controller can tolerate an action in the previous schema and migrates it to the new schema.

// java actions once stored the attachment in "jar" instead of "code"
obj.fields.get("code").orElse(obj.fields.get("jar"))
// java actions once stored the attachment in "jar" instead of "code"
val code = obj.fields.get("code").orElse(obj.fields.get("jar"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps as part of the schema migration pr, you can normalize all jar occurrences to code and we can remove this legacy bit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As part of #2938 I have normalized jar to code. Will have to remove the jar reference here.

@dubee
Copy link
Member Author

dubee commented Nov 27, 2017

@rabbah, I believe I had originally planned to have #2855 merged first and update the tests in that PR for this one. I can add the tests here as well.

@dubee dubee force-pushed the code-attach branch 5 times, most recently from 0639141 to c6563a0 Compare December 1, 2017 02:33
@dubee
Copy link
Member Author

dubee commented Jan 6, 2018

Pushed changes to use ansible/files/runtimes.json since the runtimes were removed from ansible/group_varz/all.

copy(code = Inline(encoded))
val code = new String(bytes, StandardCharsets.UTF_8)

if (kind == "java" && !Exec.isBinaryCode(code)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allows backward compatibility with old Java actions that have attachments that are not base64.

@markusthoemmes markusthoemmes added the awaits-feedback A reviewer has asked a question and/or asked for a change. label Feb 28, 2018
@markusthoemmes
Copy link
Contributor

@dubeejw What's the status here? The latest Travis failed.

@codecov-io
Copy link

Codecov Report

Merging #2847 into master will decrease coverage by 0.07%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2847      +/-   ##
==========================================
- Coverage    74.5%   74.42%   -0.08%     
==========================================
  Files         126      126              
  Lines        5950     5955       +5     
  Branches      378      377       -1     
==========================================
- Hits         4433     4432       -1     
- Misses       1517     1523       +6
Impacted Files Coverage Δ
...src/main/scala/whisk/core/entity/WhiskAction.scala 77.62% <100%> (ø) ⬆️
.../scala/src/main/scala/whisk/core/entity/Exec.scala 79.37% <81.81%> (-4.5%) ⬇️
...src/main/scala/whisk/core/entity/Attachments.scala 88.88% <0%> (+11.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d13ff86...eddb1c7. Read the comment docs.

@dubee
Copy link
Member Author

dubee commented May 8, 2018

@markusthoemmes, Travis is now passing. Awaiting more feed back.

@dubee
Copy link
Member Author

dubee commented May 10, 2018

Closed in favor of #3286

@dubee dubee closed this May 10, 2018
@chetanmeh chetanmeh mentioned this pull request Aug 7, 2018
26 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaits-feedback A reviewer has asked a question and/or asked for a change. controller review Review for this PR has been requested and yet needs to be done.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants