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

Open
#115 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
cloud

Research direction

Start with containers/function-handler-java, following README.md and the reported serverless deploy command. Inspect serverless.yml alongside the plugin's validateCredentials path and the directory versus registryImage configuration; done means credentials from config.yaml work and the example deploys from its directory without the registry-image error.

Written by the indexing model from the issue text.

Description

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)?
Dominant language
Go
Stars
64
Forks
14
Avg merge
6d 23h
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from scaleway/serverless-examples

All issues in scaleway/serverless-examples

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.