-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Native / Docker runtime does not reuse variables outside of main function in Golang #5044
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
Comments
Or is this a known limitation of this runtime that uses binary? |
The golang OpenWhisk runtime does reuse variables. You can try a properly working version here: and see the code here: |
I am aware that the golang runtime does reuse variables outside of main function. But the native / docker does not. So probably if you use another programming language say Rust then compile statically then you could expect the same behaviour. I would appreciate a confirmation that this is a limitation of the runtime and not a bug. Thanks! |
Ah sorry - I missed the "native" qualification. In this model, each invocation is a new process, so there won't be any reuse. It's possible to implement an alternate protocol though but that involves using file descriptors (this is referred to as the action loop). |
Reference for the action loop: https://github.com/apache/openwhisk/blob/master/docs/actions-actionloop.md. |
Environment details:
Steps to reproduce the issue:
ibmcloud fn action get helloGo --url <- returns your url
curl -X POST -d '{"name":"sfdsfs4 "}' https://us-south.functions.appdomain.cloud/api/v1/xxx/helloGo.json
ibmcloud wsk activation logs --last # returns the logs
notice that variable t0 is never reused. You always see "new t0" in the logs
Provide the expected results and outputs:
Provide the actual results and outputs:
Additional information you deem important:
Code for native / docker runtime
save as main.go
GOOS=linux GOARCH=amd64 go build -o exec
zip exec.zip exec
ibmcloud wsk action update helloGo --native exec.zip
ibmcloud fn action get helloGo --url <- returns your url
curl -X POST -d '{"name":"sfdsfs4 "}' https://us-south.functions.appdomain.cloud/api/v1//helloGo.json
ibmcloud wsk activation logs --last # returns the logs
The text was updated successfully, but these errors were encountered: