serverless / serverless-knative

Serverless Knative Provider Plugin – Adds Knative to the Serverless Framework
https://serverless.com
28 stars 19 forks source link

exception, when I use serverless deploy #14

Closed huyyxy closed 2 years ago

huyyxy commented 2 years ago

when I try knative-docker, like this:

export SERVERLESS_PLATFORM_VENDOR=knative
export SLS_GEO_LOCATION=us serverless deploy

serverless create --template knative-docker --path myService
[root@VM-6-2-centos myService]# cat serverless.yml
service: myservice

frameworkVersion: '3'

provider:
  name: knative
  # optional Docker Hub credentials you need if you're using local Dockerfiles as function handlers
  docker:
    username: ${env:DOCKER_HUB_USERNAME}
    password: ${env:DOCKER_HUB_PASSWORD}

functions:
  hello:
    handler: hello-world.dockerfile
    context: ./code
    # either use a container image URL for your function `handler` as the commented out `handler`
    # below shows or make sure that you update the application code and corresponding Dockerfile
    # to process incoming CloudEvents event data when using the event sources listed below
    # handler: gcr.io/knative-releases/github.com/knative/eventing-contrib/cmd/event_display:latest
    # events:
    #   - custom:
    #       filter:
    #         attributes:
    #           type: greeting
    #   - kafka:
    #       consumerGroup: KAFKA_CONSUMER_GROUP_NAME
    #       bootstrapServers:
    #         - server1
    #         - server2
    #       topics:
    #         - my-topic
    #   - awsSqs:
    #       secretName: aws-credentials
    #       secretKey: credentials
    #       queue: QUEUE_URL
    #   - gcpPubSub:
    #       project: knative-hackathon
    #       topic: foo
    #   - cron:
    #       schedule: '* * * * *'
    #       data: '{"message": "Hello world from a Cron event source!"}'

plugins:
  - serverless-knative
[root@VM-6-2-centos myService]# sls deploy
Warning: You're relying on provider "knative" defined by a plugin which doesn't provide a validation schema for its config.
Please report the issue at its bug tracker linking: https://www.serverless.com/framework/docs/providers/aws/guide/plugins#extending-validation-schema
You may turn off this message with "configValidationMode: off" setting

Building Docker image "******/myservice-hello:166616657****"...
✖ Uncaught exception
Environment: linux, node 16.15.0, framework 3.23.0, plugin 6.2.2, SDK 4.3.2
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
TypeError: Cannot read properties of undefined (reading 'slice')
    at ReadFileContext.<anonymous> (/root/knative/myService/node_modules/dockerode/lib/util.js:94:32)
    at ReadFileContext.callback (/usr/local/lib/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:123:16)
    at FSReqCallback.readFileAfterOpen [as oncomplete] (node:fs:314:13)
[root@VM-6-2-centos myService]#
medikoo commented 2 years ago

@huyyxy please report at serverless-knative plugin repository

huyyxy commented 2 years ago

OK, thinks

Trojanku commented 1 year ago

Hi. Do we have any solution to that? I cannot find any details about this anywhere else.

roskee commented 1 year ago

@Trojanku Hi, Did you find a solution for this?

kennyhyun commented 10 months ago

it's from dockerode/lib/util.js:94

fix dockerode version to 3.3.2 in your package.json

for npm

  "overrides": {
    "dockerode": "3.3.2"
  },

for pnpm

  "pnpm": {
    "overrides": {
      "dockerode": "3.3.2"
    }
  },

for yarn v1

  "resolutions": {
    "dockerode": "3.3.2"
  },

then it will allow you to build the docker image but will lead you to the issue #10 lol


got this working using my fork

  "pnpm": {
    "overrides": {
      "serverless-knative": "git://github.com/kennyhyun/serverless-knative#kennyhyun-patch-custom-image",
      "@serverless/knative-serving": "git://github.com/kennyhyun/knative-serving#kennyhyun-patch-image-pull-secrets",
      "dockerode": "3.3.2"
    }
  }

pls have a look https://github.com/kennyhyun/serverless-knative/pull/1