-
Notifications
You must be signed in to change notification settings - Fork 90
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
Handle args for modules with out extra first argument in prep for oci articfacts #146
Conversation
Signed-off-by: James Sturtevant <jstur@microsoft.com>
I think the failure is because I need to update wasmedge as well |
Signed-off-by: James Sturtevant <jstur@microsoft.com>
|
Ok I sorted it out, It seems to be a bug in wasmedge. If you pass None for arguements then it pass a blank string arg onto the call. I added some logging to the demo app and got:
This is because it is passing an array: https://github.com/WasmEdge/wasmedge-rust-sdk/blob/441dfe167c33119c4a12b0ba4034743bfde9a30d/crates/wasmedge-sys/src/instance/module.rs#L558-L563 |
Signed-off-by: James Sturtevant <jstur@microsoft.com>
So wasmedge is passing properly in 20.04:
Looks like it is failing in 22.04 for a different reason which I am having trouble getting logs for (I run 20.04 locally) |
Signed-off-by: James Sturtevant <jstur@microsoft.com>
well 22.04 passed on that run:
|
/assign @Mossaka |
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 think this PR needs to be linked to documentation somehow, because it's all about reading an annotation and having special args handling based on that. I think the documentation can just be a good comment in the code explaining the difference between the different ways of running the module, and why the arguments have to be processed differently.
Also, the wasmtime instance.rs
will see big changes due to #142. There should be some coordination about which PR goes in first.
args | ||
} | ||
_ => { | ||
if args.len() > 1 { |
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.
Hmm, is this a workaround for the Wasmedge issue? Should we wait for them to resolve it?
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.
No, this logic didn't change. This is the standard processing when the wasm module is shipped in the container layers. The first argument will always be the module. The rest of the args are the args to the module.
@@ -5,3 +5,4 @@ test/out/img.tar | |||
!crates/wasmtime/src/bin/ | |||
test/k8s/_out | |||
release/ | |||
.vscode/settings.json |
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.
Should we just ignore the full .vscode
directory while at it? Or is it possible to have some project-level settings there?
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.
open to either... settings.json changes often for me as I switch the rust analyzer settings around as I go.
I do have a couple debug configurations that might be worth sharing if folks are interested in them
@@ -109,4 +109,7 @@ jobs: | |||
make test/k3s | |||
- name: cleanup | |||
if: always() | |||
run: make test/k3s/clean | |||
run: | | |||
sudo bin/k3s kubectl logs deployments/wasi-demo |
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.
Is it possible that this will cause a long timeout if the cluster is in a broken state? I'm not opposing this but would like the cleanup to be quick and safe.
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.
good call, I can wrap it in a timeout? I was having trouble getting the logs on failure and this was the only way I could get it to work.
module_args = Some(args.iter().map(|s| s as &str).collect()) | ||
} | ||
|
||
debug!("module args: {:?}", module_args); |
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.
At some point we need to go through the codebase and look at the logging, because I'm worried that someone might pass secrets as environment variables or module arguments and we'll accidentally log them. It's not a problem yet, just something to keep in mind.
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.
yes, we might want to take a more structure approach to logging as well.
I can drop some of these debug statements. It was helpful when figuring this out but your concern is valid.
100% agree need docs. I was going to add them in #147. I was on the fence for including the annotations at all on this one. I wanted to give enough context on how this would change in an upcoming PR but I think it might not be appropriate here. This is really about fixing the argument handling as it is today.
👍 These changes will end up pretty similar as they are now, just be in the new |
if !args.is_empty() { | ||
// temporary work around for wasmedge bug | ||
// https://github.com/WasmEdge/wasmedge-rust-sdk/issues/10 | ||
if !(args.len() == 1 && args[0].is_empty()) { |
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.
@ipuustin this is the work around for the wasmedge bug.
I should also call out that this change set, is potentially a breaking change. Any module that took arguments, was throwing away the first argument as it was the module name. We no pass arguments as a program might expect.
So this PR isn't valid, I found it strange that the arguments didn't work in wasmtime the way I expected and did some more research and asked in the wasmtime channel (https://bytecodealliance.zulipchat.com/#narrow/stream/206238-general/topic/Arguments.20to.20wasm.20modules.20in.20wasmtime). Ends up I had a miss understanding here. I will fix this up, though the second bug where it hangs is still valid. But it does bring up the question of what do we pass as the name for the module since all we got was the hash of the module pacakge. |
I've decided most of the changes that are actually needed here really relate to the OCI work in #147 so I will close this and fix that up |
When working on adding OCI artifact support, I found two bugs:
module.wasm
artifact. This means the demo app was parsing the second arguement even though it was really the first.I've included in the tests the checks for the OCI artifacts. I can drop those and add back when add oci artifact support in the next PR but I thought i'd include it initially.
work towards #108