Skip to content

Example project function-handler-java does not work out of the box #115

@BoukeNijhuis

Description

@BoukeNijhuis

Hi there,

I would like to report my findings when using the example function-handler-java (in the containers folder).

Preparations

I followed the steps in Setup from the README.md. So I did the following steps:

git clone git@github.com:scaleway/serverless-examples.git
cd serverless-examples/containers/function-handler-java
npm install
serverless deploy

Expectations

The example will deploy to the Scaleway cloud.

Actual Result

I got the stacktrace below.

Using credentials from /Users/boukenijhuis/.config/scw/config.yaml
Using credentials from /Users/boukenijhuis/.config/scw/config.yaml
Using credentials from /Users/boukenijhuis/.config/scw/config.yaml
Using credentials from /Users/boukenijhuis/.config/scw/config.yaml
Using credentials from /Users/boukenijhuis/.config/scw/config.yaml
Using credentials from /Users/boukenijhuis/.config/scw/config.yaml
Environment: darwin, node 20.19.5, framework 3.58.0
Docs:        github.com/oss-serverless/serverless

Error:
TypeError: Cannot read properties of undefined (reading 'length')
    at ScalewayDeploy.validateCredentials (/Users/boukenijhuis/git/function-handler-java-clean/node_modules/serverless-scaleway-functions/shared/validate.js:163:30)
    at ScalewayDeploy.tryCatcher (/Users/boukenijhuis/git/function-handler-java-clean/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/boukenijhuis/git/function-handler-java-clean/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/boukenijhuis/git/function-handler-java-clean/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/boukenijhuis/git/function-handler-java-clean/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/boukenijhuis/git/function-handler-java-clean/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/boukenijhuis/git/function-handler-java-clean/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/boukenijhuis/git/function-handler-java-clean/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/boukenijhuis/git/function-handler-java-clean/node_modules/bluebird/js/release/async.js:102:5)
    at Async.drainQueues [as _onImmediate] (/Users/boukenijhuis/git/function-handler-java-clean/node_modules/bluebird/js/release/async.js:15:14)
    at process.processImmediate (node:internal/timers:483:21)

When you go the top item in the stacktrace, you will find this:

  validateCredentials() {
    if (
      this.provider.scwToken.length !== 36 ||
      this.provider.getScwProject().length !== 36
    ) {

After Googling 'scwToken' I found this example:

https://www.serverless.com/plugins/serverless-scaleway-serverless#general-configuration

This example shows that I have to add the following two keys:

  • scwToken
  • scwProject

I do not understand why I need these two keys. Especially because the output above states that it uses credentials from /Users/boukenijhuis/.config/scw/config.yaml. So this mechanism seems to be broken?

After adding the two keys above (scwToken & scwProject), I get the following error.

Using credentials from serverless.yml
Using credentials from serverless.yml
Using credentials from serverless.yml
Using credentials from serverless.yml
Using credentials from serverless.yml
Using credentials from serverless.yml
Updating container function-handler-java...
Environment: darwin, node 20.19.5, framework 3.58.0
Docs:        github.com/oss-serverless/serverless

Error:
Error: image not found in scaleway container registry
    at manageError (/Users/boukenijhuis/git/function-handler-java-clean/node_modules/serverless-scaleway-functions/shared/api/utils.js:53:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 0)

So the credential logging is changed from a config.yaml to the serverless.yml as expected, but now serverless expects me to use a scaleway container registry, but the serverless.yml specifies that I want to use a directory.

I went down the rabbit hole to get everything working with a registry image, but I prefer to just use a directory.

So two questions:

  1. How do I get serverless to use my credentials from the config.yaml?
  2. How do I get serverless to work with a directory (instead of a registryImage)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions