Skip to content
New issue

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

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

Already on GitHub? # to your account

No print output from within Spin app #123

Closed
0xE282B0 opened this issue Aug 12, 2023 · 7 comments · Fixed by #168
Closed

No print output from within Spin app #123

0xE282B0 opened this issue Aug 12, 2023 · 7 comments · Fixed by #168
Assignees
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@0xE282B0
Copy link
Contributor

Hi,
While testing the shims on the main branch I found that I can't see print from within the HTTP handler anymore.

Simple example:

use anyhow::Result;
use spin_sdk::{
    http::{Request, Response},
    http_component,
};

/// A simple Spin HTTP component.
#[http_component]
fn handle_hello_http(req: Request) -> Result<Response> {
    // #### This does not appear in log ####
    println!("{:?}", req.headers());
    // #############################
    Ok(http::Response::builder()
        .status(200)
        .header("foo", "bar")
        .body(Some("Hello, Fermyon".into()))?)
}

With v0.8.0 I can see the headers printed to the container log on every request. When using the shim from main there is no output. @Mossaka I guess it is related to the LibContainer change.

Btw. It's awesome that we have a Redis trigger now 😊

@Mossaka
Copy link
Member

Mossaka commented Aug 18, 2023

Umm it might be that we didn't pass in stdin, stdout, stderr for wiring up the std io.

@Mossaka
Copy link
Member

Mossaka commented Aug 18, 2023

I will take this as an action item to make our integration tests more robust on detecting HTTP headers.

@Mossaka
Copy link
Member

Mossaka commented Aug 23, 2023

Can you try it now? I think #121 resolved it

@0xE282B0
Copy link
Contributor Author

@Mossaka, the problem still exists:

#[http_component]
fn handle_spin_dapr(req: Request) -> Result<Response> {
    println!("{:?}\n", req);
    ...

When running with the shim, I only get this and no other output.

Serving http://0.0.0.0:80                                                                                                                                                                                                                                                                              
Available Routes:                                                                                                                                                                                                                                                                                    
  spin-dapr: http://0.0.0.0:80 (wildcard) 

With spin up I see the println! output on every request.

Serving http://127.0.0.1:3000
Available Routes:
  spin-dapr: http://127.0.0.1:3000 (wildcard)

Request { method: POST, uri: /, version: HTTP/1.1, headers: {"host": "localhost:3000", "user-agent": "curl/7.88.1", "accept": "*/*", "spin-path-info": "/", "spin-full-url": "http://localhost:3000/", "spin-matched-route": "/...", "spin-base-path": "/", "spin-raw-component-route": "/...", "spin-component-route": "", "spin-client-addr": "127.0.0.1:44264"}, body: Some(b"") }

@Mossaka
Copy link
Member

Mossaka commented Aug 29, 2023

Serving http://0.0.0.0:80                                                                                                                                                                                                                                                                              
Available Routes:                                                                                                                                                                                                                                                                                    
  spin-dapr: http://0.0.0.0:80 (wildcard) 

Is this from kubectl logs <pod>?

@thangchung
Copy link

With containerd-wasm-shims v0.9.0 when I daprized it, then I couldn't see any logs from spin app. See image below

image

@Mossaka @0xE282B0 Is it a bug?

@Mossaka Mossaka self-assigned this Sep 11, 2023
@Mossaka Mossaka added help wanted Extra attention is needed question Further information is requested labels Sep 11, 2023
@Mossaka
Copy link
Member

Mossaka commented Sep 11, 2023

I believe so. Will take a look today

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants