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

Updating the component with a new WebAssembly file results in the following error: #1226

Open
rajesh-jonnalagadda opened this issue Jan 8, 2025 · 6 comments

Comments

@rajesh-jonnalagadda
Copy link

Updating the component with a new WebAssembly file results in the following error:

replication steps:

  1. Create a component using the <wasm1.wasm> file.
  2. Create a new worker, and its invocation works without any errors.
  3. Update the component to use a different WebAssembly file.
  4. Create a new worker with the updated version of the component.
  5. The worker invocations no longer behave as expected.

https://www.loom.com/share/9b8c0e25b79f462991897806e965244d
https://www.loom.com/share/975db7e6fc824242bbf78c5bf8f168c6

Note: I am not entirely sure if the component update I am making is correct.

@vigoo
Copy link
Contributor

vigoo commented Jan 8, 2025

A probably unrelated remark: ephemeral workers should not be explicitly created - they must be invoked using the component's invoke endpoints and Golem automatically creates a new, single use worker every time.

@vigoo
Copy link
Contributor

vigoo commented Jan 8, 2025

I was trying to understand what's going on based on the video but it's a bit hard as it is quite long.

What I thought I'm seeing on it is reproduced by the following integration test:

#[test]
#[tracing::instrument]
async fn bug_1226(
    deps: &EnvBasedTestDependencies,
    _tracing: &Tracing,
) {
    let component_id = deps.store_component("shopping-cart").await;
    let worker_id = deps
        .start_worker(&component_id, "shopping-cart-1226")
        .await;

    let contents = deps
        .invoke_and_await(&worker_id, "golem:it/api.{get-cart-contents}", vec![])
        .await;

    let _ = deps.update_component(&component_id, "python-1").await;

    let worker_id2 = deps.start_worker(&component_id, "shopping-cart-1226-2").await;

    let (metadata2, _) = deps.get_worker_metadata(&worker_id2).await.unwrap();

    let contents2 = deps
        .invoke_and_await(&worker_id2, "golem:it/api.{get-cart-contents}", vec![])
        .await;
    let get2 = deps
        .invoke_and_await(&worker_id2, "golem:it/api.{get}", vec![])
        .await;

    assert_eq!(metadata2.last_known_status.component_version, 1); // worker2 uses the updated component version
    assert_eq!(contents, Ok(vec![Value::List(vec![])])); // result from worker1
    assert_eq!(contents2.is_err(), true); // can't call get-cart-contents on worker2
    assert_eq!(get2, Ok(vec![Value::U64(0)])); // can call get on worker2
}

but this works as expected.

@afsalthaj
Copy link
Contributor

afsalthaj commented Jan 8, 2025

@rajesh-jonnalagadda I just tried your workflow in the video myself using golem-cli which is essentially equivalent to you doing those Postman requests

golem-cli component add --component-name shopping-cart --ephemeral shopping-cart.wasm

golem-cli worker add --worker-name foo --component-name shopping-cart

golem-cli worker invoke-and-await --worker-name foo --component-name shopping-cart --function golem:it/api.{get-cart-contents}

golem-cli component update --component urn:component:f86acafe-f5f6-4fa2-becd-3d6945627648 python-1.wasm

golem-cli worker add --worker-name bar --component-name shopping-cart

golem-cli worker invoke-and-await --worker-name bar --component-name shopping-cart --function golem:it/api.{get-cart-contents} 
// can't find function in component

 golem-cli worker invoke-and-await --worker-name bar --component-name shopping-cart --function golem:it/api.{get}

// Invocation results in WAVE format:
// - '0'

I re-watched the video, to see if there is anything silly going on there, but couldn't spot in particular. The only difference I think in my workflow is worker names foo and bar which doesn't matter.

In short, python-1.wasm has get function, and I am able to invoke it on top of a worker based on an ephemeral component that was previously shopping-cart.wasm

@rajesh-jonnalagadda
Copy link
Author

@rajesh-jonnalagadda I just tried your workflow in the video myself using golem-cli which is essentially equivalent to you doing those Postman requests

golem-cli component add --component-name shopping-cart --ephemeral shopping-cart.wasm

golem-cli worker add --worker-name foo --component-name shopping-cart

golem-cli worker invoke-and-await --worker-name foo --component-name shopping-cart --function golem:it/api.{get-cart-contents}

golem-cli component update --component urn:component:f86acafe-f5f6-4fa2-becd-3d6945627648 python-1.wasm

golem-cli worker add --worker-name bar --component-name shopping-cart

golem-cli worker invoke-and-await --worker-name bar --component-name shopping-cart --function golem:it/api.{get-cart-contents} 
// can't find function in component

 golem-cli worker invoke-and-await --worker-name bar --component-name shopping-cart --function golem:it/api.{get}

// Invocation results in WAVE format:
// - '0'

I re-watched the video, to see if there is anything silly going on there, but couldn't spot in particular. The only difference I think in my workflow is worker names foo and bar which doesn't matter.

In short, python-1.wasm has get function, and I am able to invoke it on top of a worker based on an ephemeral component that was previously shopping-cart.wasm

Thank you for checking. I see that you replicated my Postman requests using the Golem CLI, and based on the comments, it appears to be working as expected. I'm genuinely confused as to why it's not functioning in Postman via the REST API. Could you help me identify what I might be doing wrong?

@rajesh-jonnalagadda
Copy link
Author

@rajesh-jonnalagadda I just tried your workflow in the video myself using golem-cli which is essentially equivalent to you doing those Postman requests

golem-cli component add --component-name shopping-cart --ephemeral shopping-cart.wasm

golem-cli worker add --worker-name foo --component-name shopping-cart

golem-cli worker invoke-and-await --worker-name foo --component-name shopping-cart --function golem:it/api.{get-cart-contents}

golem-cli component update --component urn:component:f86acafe-f5f6-4fa2-becd-3d6945627648 python-1.wasm

golem-cli worker add --worker-name bar --component-name shopping-cart

golem-cli worker invoke-and-await --worker-name bar --component-name shopping-cart --function golem:it/api.{get-cart-contents} 
// can't find function in component

 golem-cli worker invoke-and-await --worker-name bar --component-name shopping-cart --function golem:it/api.{get}

// Invocation results in WAVE format:
// - '0'

I re-watched the video, to see if there is anything silly going on there, but couldn't spot in particular. The only difference I think in my workflow is worker names foo and bar which doesn't matter.
In short, python-1.wasm has get function, and I am able to invoke it on top of a worker based on an ephemeral component that was previously shopping-cart.wasm

Thank you for checking. I see that you replicated my Postman requests using the Golem CLI, and based on the comments, it appears to be working as expected. I'm genuinely confused as to why it's not functioning in Postman via the REST API. Could you help me identify what I might be doing wrong?

If you have the time, you might consider replicating it using Postman or another tool via the REST API. While I understand it may require some effort, it would be incredibly helpful, and I would greatly appreciate your support.

@vigoo
Copy link
Contributor

vigoo commented Jan 8, 2025

@afsalthaj with -vvv golem-cli will print the actual http requests it sends

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

No branches or pull requests

3 participants