serverless icon indicating copy to clipboard operation
serverless copied to clipboard

Failed to invoke Go function on AWS or locally: /lib64/libc.so.6: version `GLIBC_2.32' not found

Open przmv opened this issue 5 years ago • 7 comments

I created a service using the following template:

sls create --template aws-go-mod --path myService

I did the initial build as the following:

cd myService
make build

I was trying to invoke an AWS Lambda Go function locally (with serverless invoke local --function hello), but got the error message: /lib64/libc.so.6: version `GLIBC_2.32' not found

serverless.yml
service: myservice
frameworkVersion: '2'

provider:
  name: aws
  runtime: go1.x

package:
  exclude:
    - ./**
  include:
    - ./bin/**

functions:
  hello:
    handler: bin/hello
    events:
      - http:
          path: hello
          method: get
  world:
    handler: bin/world
    events:
      - http:
          path: world
          method: get
serverless invoke local --function hello output
Serverless: Load command interactiveCli                                                                                                                                                   
Serverless: Load command config                                                                                                                                                           
Serverless: Load command config:credentials                                                                                                                                               
Serverless: Load command config:tabcompletion                                                                                                                                             
Serverless: Load command config:tabcompletion:install                                                                                                                                     
Serverless: Load command config:tabcompletion:uninstall                                                                                                                                   
Serverless: Load command create                                                                                                                                                           
Serverless: Load command install                                                                                                                                                          
Serverless: Load command package                                                                                                                                                          
Serverless: Load command deploy                                                                                                                                                           
Serverless: Load command deploy:function                                                                                                                                                  
Serverless: Load command deploy:list                                                                                                                                                      
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Deprecation warning: Starting with next major version, API Gateway naming will be changed from "{stage}-{service}" to "{service}-{stage}".
            Set "provider.apiGateway.shouldStartNameWithService" to "true" to adapt to the new behavior now.
            More Info: https://www.serverless.com/framework/docs/deprecations/#AWS_API_GATEWAY_NAME_STARTING_WITH_SERVICE
Serverless: Invoke invoke:local
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Invoke aws:package:finalize
Serverless: Invoke aws:common:moveArtifactsToPackage
/var/task/bin/hello: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by /var/task/bin/hello)
START RequestId: ddbe6b2f-1501-1df6-3a49-abe30eae31bb Version: $LATEST
END RequestId: ddbe6b2f-1501-1df6-3a49-abe30eae31bb
REPORT RequestId: ddbe6b2f-1501-1df6-3a49-abe30eae31bb  Init Duration: 300000.00 ms     Duration: 4.47 ms       Billed Duration: 100 ms Memory Size: 1024 MB    Max Memory Used: 23 MB

{"errorType":"exitError","errorMessage":"RequestId: c4622e10-992a-15d7-16f7-2a9a373c182b Error: 2020-11-23T10:41:09.468Z c4622e10-992a-15d7-16f7-2a9a373c182b Task timed out after 300.00 seconds"}

Installed version

Framework Core: 2.12.0
Plugin: 4.1.2
SDK: 2.3.2
Components: 3.4.2

przmv avatar Nov 23 '20 10:11 przmv

The same problem is when the service is deployed on AWS:

SLS_DEBUG=* serverless invoke -f hello
Serverless: Load command interactiveCli
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command config:tabcompletion
Serverless: Load command config:tabcompletion:install
Serverless: Load command config:tabcompletion:uninstall
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command upgrade
Serverless: Load command uninstall
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: Load command output
Serverless: Load command output:get
Serverless: Load command output:list
Serverless: Load command param
Serverless: Load command param:get
Serverless: Load command param:list
Serverless: Load command studio
Serverless: Deprecation warning: Starting with next major version, API Gateway naming will be changed from "{stage}-{service}" to "{service}-{stage}".
            Set "provider.apiGateway.shouldStartNameWithService" to "true" to adapt to the new behavior now.
            More Info: https://www.serverless.com/framework/docs/deprecations/#AWS_API_GATEWAY_NAME_STARTING_WITH_SERVICE
Serverless: Invoke invoke
Serverless: [AWS lambda 200 1.096s 0 retries] invoke({
  FunctionName: 'myservice-dev-hello',
  InvocationType: 'RequestResponse',
  LogType: 'None',
  Payload: '***SensitiveInformation***'
})
{
    "errorMessage": "RequestId: 123fa09e-ab7c-45a6-a9b9-04e20801b4c9 Process exited before completing request"
}
 
  Error --------------------------------------------------
 
  Error: Invoked function failed
      at AwsInvoke.log (/home/petr/.npm/lib/node_modules/serverless/lib/plugins/aws/invoke/index.js:105:31)
  From previous event:
      at Object.invoke:invoke [as hook] (/home/petr/.npm/lib/node_modules/serverless/lib/plugins/aws/invoke/index.js:23:12)
      at /home/petr/.npm/lib/node_modules/serverless/lib/classes/PluginManager.js:510:55
  From previous event:
      at PluginManager.invoke (/home/petr/.npm/lib/node_modules/serverless/lib/classes/PluginManager.js:510:22)
      at /home/petr/.npm/lib/node_modules/serverless/lib/classes/PluginManager.js:545:24
  From previous event:
      at PluginManager.run (/home/petr/.npm/lib/node_modules/serverless/lib/classes/PluginManager.js:545:8)
      at /home/petr/.npm/lib/node_modules/serverless/lib/Serverless.js:170:33
      at processImmediate (internal/timers.js:461:21)
  From previous event:
      at Serverless.run (/home/petr/.npm/lib/node_modules/serverless/lib/Serverless.js:157:74)
      at /home/petr/.npm/lib/node_modules/serverless/scripts/serverless.js:50:26
 
  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com
 
  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              12.19.0
     Framework Version:         2.12.0
     Plugin Version:            4.1.2
     SDK Version:               2.3.2
     Components Version:        3.4.2
serverless logs -f hello
Serverless: Deprecation warning: Starting with next major version, API Gateway naming will be changed from "{stage}-{service}" to "{service}-{stage}".
            Set "provider.apiGateway.shouldStartNameWithService" to "true" to adapt to the new behavior now.
            More Info: https://www.serverless.com/framework/docs/deprecations/#AWS_API_GATEWAY_NAME_STARTING_WITH_SERVICE
/var/task/bin/hello: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by /var/task/bin/hello)
2020/11/23 11:23:59 exit status 1
START RequestId: 123fa09e-ab7c-45a6-a9b9-04e20801b4c9 Version: $LATEST
/var/task/bin/hello: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by /var/task/bin/hello)
2020/11/23 11:23:59 exit status 1
END RequestId: 123fa09e-ab7c-45a6-a9b9-04e20801b4c9
REPORT RequestId: 123fa09e-ab7c-45a6-a9b9-04e20801b4c9  Duration: 31.67 ms      Billed Duration: 100 ms Memory Size: 1024 MB    Max Memory Used: 7 MB

RequestId: 123fa09e-ab7c-45a6-a9b9-04e20801b4c9 Process exited before completing request

przmv avatar Nov 23 '20 11:11 przmv

I tried to reproduced it on another machine (Debain 10, npm 6.14.8, node v10.14.2) and it worked OK.

So, it only fails on openSUSE Tumbleweed (npm 6.14.8, node v12.19.0)

przmv avatar Nov 23 '20 11:11 przmv

@pshevtsov local invocation demands that given runtime is locally installed, and that's out of scope of the Framework.

In this case it appears you don't have it properly installed in openSuse box. What could probably be improved is error reporting, which you should clearly point that there's an issue with installed runtime. We welcome a PR that improves that

It's hard to say what happens in AWS deployed lambda, best if you inspect logs on AWS side

medikoo avatar Nov 23 '20 12:11 medikoo

I experienced the same error message using the aws-go-mod template. It can be fixed by disabling cgo. The following adjustments were required to the Makefile:

.PHONY: build clean deploy gomodgen

build: gomodgen
	export GO111MODULE=on
        # FIX: Add CGO_ENABLED=0 when building go files
	env CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o bin/hello hello/main.go
	env CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o bin/world world/main.go

clean:
	rm -rf ./bin ./vendor go.sum

deploy: clean build
	sls deploy --verbose

gomodgen:
	chmod u+x gomod.sh
	./gomod.sh

shodgson avatar Dec 09 '20 12:12 shodgson

It's 2023, and this is still open, and the instruction from shodgson didn't help me, but I recognized it as generally the right approach as I knew the problem had to do with a need to specify CGO_ENABLED=0 while building the lambda function.

Instead of modifying the Makefile, I found it helpful to edit the samconfig.toml file's [default.build.parameters] to add a line specifying the container_env_var to include 'function_name.CGO_ENABLED=0' for each function. If you'd previously built your function with the cache enabled, you might need to disable the cache and rebuild, as it won't update your function unless you make a change to it.

So, in the hello-world example change the file to have:

[default.build] [default.build.parameters] container_env_var = ["hello-world.CGO_ENABLED=0"] parallel = true

If you're building a stack with a lot of lambda function, you might try using container_env_var_file = "env.json" and creating an env.json file with all of this instead. That file looks something like:

{ "hello-world": { "CGO_ENABLED": "0" } }

... but with all your functions instead of just the hello-world one.

tvanriper avatar Feb 27 '23 13:02 tvanriper

I feel a bit silly that I got stuck on this for so long, but I feel like sharing it might help someone.

After making @shodgson's recommended change, above. You'll need to re-run make build before trying to run sls invoke again.

bradsk88 avatar Mar 15 '24 15:03 bradsk88

I experienced the same error message using the aws-go-mod template. It can be fixed by disabling cgo. The following adjustments were required to the Makefile:

.PHONY: build clean deploy gomodgen

build: gomodgen
	export GO111MODULE=on
        # FIX: Add CGO_ENABLED=0 when building go files
	env CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o bin/hello hello/main.go
	env CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o bin/world world/main.go

clean:
	rm -rf ./bin ./vendor go.sum

deploy: clean build
	sls deploy --verbose

gomodgen:
	chmod u+x gomod.sh
	./gomod.sh

Thanks, worked for me, it happened because I am using Ubuntu 24

aicam avatar Aug 25 '24 04:08 aicam