-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 blackbox action code as attachment #3979
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3979 +/- ##
==========================================
- Coverage 85.82% 81.24% -4.59%
==========================================
Files 146 146
Lines 7084 7095 +11
Branches 440 443 +3
==========================================
- Hits 6080 5764 -316
- Misses 1004 1331 +327
Continue to review full report at Codecov.
|
This PR is now ready for review |
0d8affa
to
0e30208
Compare
Rebased to. resolve the conflict. @dubee Would you be able to review this PR? |
5f52cf0
to
3c6084c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greatly crafted refactorings and enhancement! 🎉
The tests look solid to me and seem to address any migration paths there might be. It also seems like this is roughly the same change as needed when making all actions attachement based and since the migration logic worked there, I'm quite confident it will work here as well.
A second pair of 👀 will make sense though, as I'm not very proficient in this area.
Great job @chetanmeh, very much appreciated 🎉
|}""".stripMargin.parseJson.asJsObject | ||
val action = WhiskAction.serdes.read(json) | ||
action.exec should matchPattern { case BlackBoxExec(_, Some(Inline("foo")), None, false, false) => } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for testing this!
| } | ||
|}""".stripMargin.parseJson.asJsObject | ||
js shouldBe js2 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice tests, I like 👍
PG2 3553 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
|
||
private def isBinary(code: JsValue, obj: JsObject): Boolean = { | ||
code match { | ||
case JsString(c) => isBinaryCode(c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i know you preserved the previous behavior... but should be check for the presence of the binary field first and only if it's missing (indicating an old schema), compute the binary bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure on that - Current read flow would happen for 2 cases
- Deserializing the json obtained from
ArtifactStore
where thebinary
flag would have been set at time of serialization - Deserializing the user providing json
Would it fine to trust the binary
field if provided by user? Probably yes ... but wanted to check on that
val exec = """{ | ||
| "kind": "blackbox", | ||
| "image": "docker-custom.com/openwhisk-runtime/magic/nodejs:0.0.1", | ||
| "code": "while (true)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need another test where this is b64 encoded?
val j1 = """{ | ||
| "kind": "blackbox", | ||
| "image": "docker-custom.com/openwhisk-runtime/magic/nodejs:0.0.1", | ||
| "code": "SGVsbG8gT3BlbldoaXNr", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok you have it here (the b64 test).
| "kind": "blackbox", | ||
| "image": "docker-custom.com/openwhisk-runtime/magic/nodejs:0.0.1", | ||
| "code": "SGVsbG8gT3BlbldoaXNr", | ||
| "binary": false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note binary: false should never be stored in the repo incorrectly (since the system always computes it) --- note this is relevant for my comment above about checking if the binary field exists first.
* Use attachments with BlackBoxExec * Simplify code to avoid code duplication * Test for blackbox serialization * Test for cache for blackbox action
Treats blackbox action code as attachment
Description
This is next installment in the attachment saga (previous in this series #3945). With this change code related to blackbox action would also be stored as attachment.
Related issue and scope
My changes affect the following components
Types of changes
Checklist: