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

45 set up an example for d41 #46

Merged
merged 9 commits into from
Sep 11, 2023
Merged

Conversation

ccicconetti
Copy link
Member

In addition to the example simple_workflow_http note:

  • I added an edgeless_cli function invoke mode, which is actually unrelated to this PR 🤦
  • now the annotation "init-payload" is passed to the handle_init() as payload (before the hardcoded "test" string was passed)

@ccicconetti ccicconetti linked an issue Sep 8, 2023 that may be closed by this pull request
Build {
spec_file: String,
},
Invoke {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We might not want to advertise this feature too much as that could be problematic once we have encryption (and the client might need another cert for that if we do mutual auth), or if we have a more complex dataplane. Still this is useful for debugging.

Copy link
Member Author

Choose a reason for hiding this comment

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

We do have a requirement for directly addressable functions, precisely for development/troubleshooting reasons.

Anyway, this requirement can be fulfilled only partially at the moment, because you can only cast (not call) a function since that would require the dataplane to be reconfigured on the fly.

I added this (tiny) feature as a placeholder of the requirement: in the future we can expand things or suppress direct invocation (and the requirement).

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can certainly make it work even in the more complex cases (I was not aware this was a requirement).

function_id: uuid::Uuid::parse_str(&function_id)?,
},
source: edgeless_api::function_instance::InstanceId {
node_id: uuid::uuid!("00000000-0000-0000-0000-ffff00000000"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

didn't you use that for "all-nodes" elsewhere? While this does not cause a direct issue here, probably you should generate some unique instance_id so any responses are routed towards that (and dropped by the dataplane).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, actually that was for the "no workflow". I was in a rush so I did not define a special value also for the "no node" and "no function", though that would be a good idea (will do).

stream_id: 0,
data: match event_type.as_str() {
"cast" => edgeless_api::invocation::EventData::Cast(payload),
_ => edgeless_api::invocation::EventData::Err,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would probably use an empty-message cast as the default case. While we haven't used err yet, this sounds like it could trigger some unexpected code. An alternative would be to not send a message at all if it is sth else than cast.

_ => edgeless_api::invocation::EventData::Err,
},
};
if let edgeless_api::invocation::EventData::Err = event.data {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, this is better, no actual error-message is sent.
You could move that return to the match in line 239 to make things more readable.

body: None,
headers: std::collections::HashMap::<String, String>::new(),
}
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sth. you need to change, but that seems quite verbose as only the message changes.
Might be able to partially solve this by making some contents of EdgelessHTTPResponse optional, creating a builder or just refactoring this specific instance.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, will fix.

&"external_sink",
&edgeless_http::request_to_string(&edgeless_http::EdgelessHTTPRequest {
protocol: edgeless_http::EdgelessHTTPProtocol::HTTP,
host: CONFIGURATION.get().unwrap().lock().unwrap().target_host.clone(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also not something specific to this pr but we really need to find a way to make state examples look less weird.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree... Anyway in this example CONFIGURATION is not even a state. I will simplify a bit by dropping the Mutex.

"version": "0.1",
"include_code_file": "./http_read_number/http_read_number.wasm",
"output_callbacks": [
"cb_success"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor nitpick but it is probably more readable if those have proper names.

Copy link
Member Author

Choose a reason for hiding this comment

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

For cb_success you mean? For me that's a proper name ;-) since it is the callback (cb) that is invoked in case of success.

By the way: I like this callback mechanism very much. Indeed, I am not sure I see a reason to keep the "call" invocation method at all. Let's discuss this later.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It was just that in this workflow there are multiple cb_success. Something like result might be better for the mathematical operators or parsed_value for the ingress-bridge. But as said above, this was a minor nitpick.

Cast without alias can be useful if we send instance_ids over the network (which we do with the sender, essentially this is continuation-passing). Ofc that has some lifetime assumptions but this works well in Erlang.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, your names are better

@ccicconetti ccicconetti merged commit 3d0deef into main Sep 11, 2023
2 checks passed
@ccicconetti ccicconetti deleted the 45-set-up-an-example-for-d41 branch September 11, 2023 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set up an example for D4.1
2 participants