knative / func

Knative Functions client API and CLI
Apache License 2.0
276 stars 138 forks source link

Unable to build go function (default cloudevents template) with s2i builder. #2404

Closed jrangelramos closed 2 months ago

jrangelramos commented 3 months ago

The go function bin is not generated for the default go cloudevent template, when builder is s2i.

The below output is observed

func deploy -v -b s2i -p ./goce --build  
Building function image
STEP 1/9: FROM registry.access.redhat.com/ubi8/go-toolset
Trying to pull registry.access.redhat.com/ubi8/go-toolset:latest...
Getting image source signatures
Checking if image destination supports signatures
Copying blob sha256:c7965aa7086045a59bdb113a1fb8a19d7ccf7af4133e59af8ecefd39cda8e0b1
Copying blob sha256:e4706acfbe892da315930dd08feabfc16d226505ade8ad67e72e3bc1fff9f81d
Copying blob sha256:629f5551eb35561edd4fb4df147019d1b61fecb5cff49308880466f66c7c3287
Copying blob sha256:16ddefe5f14352018ae1c6d282fc52a20f927977b0380560385edd45497eb051
Copying config sha256:739bfcbe2e6544af048e6846c6045d8ffefbb81130b1aa70139d334106aa24ad
Writing manifest to image destination
Storing signatures
STEP 2/9: LABEL "io.k8s.display-name"="image-registry.openshift-image-registry.svc:5000/gotest/goce:latest"       "io.openshift.s2i.build.image"="registry.access.redhat.com/ubi8/go-toolset"       "io.openshift.s2i.build.source-location"="./goce"
--> ce39766932d0
STEP 3/9: USER root
--> af6521d653ba
STEP 4/9: COPY upload/scripts /tmp/scripts
--> 9936452e87ab
STEP 5/9: COPY upload/src /tmp/src
--> 9811923a1c40
STEP 6/9: RUN chown -R 1001:0 /tmp/scripts /tmp/src
--> 74715b4c1e8a
STEP 7/9: USER 1001
--> d2711032412c
STEP 8/9: RUN /tmp/scripts/assemble
/tmp/src ~
This is a S2I go-toolset base image:
To use it, install S2I: https://github.com/openshift/source-to-image
Sample invocation:
s2i build -e IMPORT_URL='github.com/cpuguy83/go-md2man' git://github.com/cpuguy83/go-md2man rhel8/go-toolset go-sample-app
You can then run the resulting image via:
docker run go-sample-app
--> 3f6b5c939015
STEP 9/9: CMD /usr/libexec/s2i/run
COMMIT image-registry.openshift-image-registry.svc:5000/gotest/goce:latest
--> 914731484e04
Successfully tagged image-registry.openshift-image-registry.svc:5000/gotest/goce:latest
914731484e04937fdeafafe98eae5da5c6ff45b597b68676473937def5a78d2a
Successfully built 914731484e04
Successfully tagged image-registry.openshift-image-registry.svc:5000/gotest/goce:latest
Writing built image: 'image-registry.openshift-image-registry.svc:5000/gotest/goce:latest' at path: 'goce/.func/built-image'
🙌 Function built: image-registry.openshift-image-registry.svc:5000/gotest/goce:latest
Pushing function image to the registry "image-registry.openshift-image-registry.svc:5000" using the "openshift" user credentials
progress: 100%
⬆️  Deploying 
Waiting for Knative Service to become ready
/usr/libexec/s2i/run: line 5: /opt/app-root/gobinary: No such file or directory
/usr/libexec/s2i/run: line 5: /opt/app-root/gobinary: No such file or directory
/usr/libexec/s2i/run: line 5: /opt/app-root/gobinary: No such file or directory
/usr/libexec/s2i/run: line 5: /opt/app-root/gobinary: No such file or directory

Note: Step 8/9 (assemble script execution output) indicates the source code is not built, thus not producing the gobinary (function executable) This happens from the default go cloudevents template only.

jrangelramos commented 3 months ago

This error can be observed on the new test being added on the https://github.com/knative/func/pull/2401, action https://github.com/knative/func/actions/runs/9682013055/job/26714012883?pr=2401

jrangelramos commented 3 months ago

/cc @lkingland

matzew commented 2 months ago

Seeing the same:

➜  ~ func version
v0.41.0-85-ge08155dd

➜  ~ func create -l go -t cloudevents simple-thing
Created go function in /home/matzew/simple-thing

➜  ~ cd simple-thing 
➜  simple-thing func deploy -b=s2i -v --build
Building function image
STEP 1/9: FROM registry.access.redhat.com/ubi8/go-toolset
Trying to pull registry.access.redhat.com/ubi8/go-toolset:latest...
Getting image source signatures
Checking if image destination supports signatures
Copying blob sha256:7027f4e4058bde8aaa497e47562e962c293039ba16f5fbfd07ff43a0d1dbd5a2
Copying blob sha256:8694db102e5bd27fa30106f87d5a0f0c5ccccac0e5cc38ba56080d7559377096
Copying blob sha256:4b9a4024958afa3724e362728a57bdab102b2b88bb08d8afdb71fdb91c12290f
Copying blob sha256:4bf857cc6c500bf0d87fc5c833c6491660c90f849350642ce46e33185b8bea48
Copying config sha256:10586e3cef9d89aa09e0bce7411c38df11913b5cbda1096320f1a835b295c056
Writing manifest to image destination
Storing signatures
STEP 2/9: LABEL "io.k8s.display-name"="index.docker.io/matzew/simple-thing:latest"       "io.openshift.s2i.build.image"="registry.access.redhat.com/ubi8/go-toolset"       "io.openshift.s2i.build.source-location"="/home/matzew/simple-thing"
--> dac4a5858e2a
STEP 3/9: USER root
--> fb3781c4dec5
STEP 4/9: COPY upload/scripts /tmp/scripts
--> e091d68d15b2
STEP 5/9: COPY upload/src /tmp/src
--> ae47e64ad55d
STEP 6/9: RUN chown -R 1001:0 /tmp/scripts /tmp/src
--> 509de9675332
STEP 7/9: USER 1001
--> cb7f7dae49a6
STEP 8/9: RUN /tmp/scripts/assemble
/tmp/src ~
This is a S2I go-toolset base image:
To use it, install S2I: https://github.com/openshift/source-to-image
Sample invocation:
s2i build -e IMPORT_URL='github.com/cpuguy83/go-md2man' git://github.com/cpuguy83/go-md2man rhel8/go-toolset go-sample-app
You can then run the resulting image via:
docker run go-sample-app
--> 3d27b840aec3
STEP 9/9: CMD /usr/libexec/s2i/run
COMMIT docker.io/matzew/simple-thing:latest
--> 1e256604c538
Successfully tagged docker.io/matzew/simple-thing:latest
1e256604c5381df968ccd5a7e1f1942e5cdeab214cd7ea1d9e3a3eec5d22b442
Successfully built 1e256604c538
Successfully tagged index.docker.io/matzew/simple-thing:latest
Writing built image: 'index.docker.io/matzew/simple-thing:latest' at path: '/home/matzew/simple-thing/.func/built-image'
🙌 Function built: index.docker.io/matzew/simple-thing:latest
Pushing function image to the registry "index.docker.io" using the "matzew" user credentials
The push refers to repository [docker.io/matzew/simple-thing:latest]
latest: digest: sha256:60ba4e4d467ea84b438e0276c32c0357361ffb0a2bd2e9ddfc72d8bb2d338277 size: 1538
⬆️  Deploying 
Waiting for Knative Service to become ready
/usr/libexec/s2i/run: line 5: /opt/app-root/gobinary: No such file or directory
/usr/libexec/s2i/run: line 5: /opt/app-root/gobinary: No such file or directory
/usr/libexec/s2i/run: line 5: /opt/app-root/gobinary: No such file or directory

checking the ksvc:

k get ksvc simple-thing 
NAME           URL                                                                                       LATESTCREATED        LATESTREADY   READY     REASON
simple-thing   https://simple-thing-default.apps.ci-ln-hg7x2st-76ef8.origin-ci-int-aws.dev.rhcloud.com   simple-thing-00002                 Unknown   RevisionMissing

describe:

k describe ksvc simple-thing 
Name:         simple-thing
Namespace:    default
Labels:       app.kubernetes.io/instance=simple-thing
              app.openshift.io/runtime=golang
              boson.dev/function=true
              boson.dev/runtime=go
              function.knative.dev=true
              function.knative.dev/name=simple-thing
              function.knative.dev/runtime=go
Annotations:  app.openshift.io/vcs-ref: 
              app.openshift.io/vcs-uri: 
              dapr.io/app-id: simple-thing
              dapr.io/app-port: 8080
              dapr.io/enable-api-logging: true
              dapr.io/enabled: true
              dapr.io/metrics-port: 9092
              serving.knative.dev/creator: system:admin
              serving.knative.dev/lastModifier: system:admin
API Version:  serving.knative.dev/v1
Kind:         Service
Metadata:
  Creation Timestamp:  2024-07-04T10:43:47Z
  Generation:          2
  Resource Version:    74436
  UID:                 50b86d2a-6606-4460-8b8b-baada24efc27
Spec:
  Template:
    Metadata:
      Annotations:
        app.openshift.io/vcs-ref:     
        app.openshift.io/vcs-uri:     
        dapr.io/app-id:               simple-thing
        dapr.io/app-port:             8080
        dapr.io/enable-api-logging:   true
        dapr.io/enabled:              true
        dapr.io/metrics-port:         9092
        serving.knative.dev/creator:  system:admin
      Creation Timestamp:             <nil>
      Labels:
        app.kubernetes.io/instance:    simple-thing
        app.openshift.io/runtime:      golang
        boson.dev/function:            true
        boson.dev/runtime:             go
        function.knative.dev:          true
        function.knative.dev/name:     simple-thing
        function.knative.dev/runtime:  go
    Spec:
      Container Concurrency:  0
      Containers:
        Env:
          Name:   BUILT
          Value:  20240704T124754
          Name:   ADDRESS
          Value:  0.0.0.0
        Image:    index.docker.io/matzew/simple-thing@sha256:41ea6c69292c01192ba824666623893d8f61f5e952eaad2aede9faca30eeff63
        Liveness Probe:
          Http Get:
            Path:  /health/liveness
            Port:  0
        Name:      user-container
        Readiness Probe:
          Http Get:
            Path:             /health/readiness
            Port:             0
          Success Threshold:  1
        Resources:
        Security Context:
          Allow Privilege Escalation:  false
          Capabilities:
            Drop:
              ALL
          Run As Non Root:  true
          Seccomp Profile:
            Type:            RuntimeDefault
      Enable Service Links:  false
      Timeout Seconds:       300
  Traffic:
    Latest Revision:  true
    Percent:          100
Status:
  Conditions:
    Last Transition Time:        2024-07-04T10:47:54Z
    Status:                      Unknown
    Type:                        ConfigurationsReady
    Last Transition Time:        2024-07-04T10:43:47Z
    Message:                     Configuration "simple-thing" is waiting for a Revision to become ready.
    Reason:                      RevisionMissing
    Status:                      Unknown
    Type:                        Ready
    Last Transition Time:        2024-07-04T10:43:47Z
    Message:                     Configuration "simple-thing" is waiting for a Revision to become ready.
    Reason:                      RevisionMissing
    Status:                      Unknown
    Type:                        RoutesReady
  Latest Created Revision Name:  simple-thing-00002
  Observed Generation:           2
  URL:                           https://simple-thing-default.apps.ci-ln-hg7x2st-76ef8.origin-ci-int-aws.dev.rhcloud.com
Events:
  Type    Reason   Age    From                Message
  ----    ------   ----   ----                -------
  Normal  Created  5m20s  service-controller  Created Configuration "simple-thing"
  Normal  Created  5m20s  service-controller  Created Route "simple-thing"

and describe of the deployment:

k describe deployments.apps simple-thing-00001-deployment 
Name:                   simple-thing-00001-deployment
Namespace:              default
CreationTimestamp:      Thu, 04 Jul 2024 12:43:47 +0200
Labels:                 app=simple-thing-00001
                        app.kubernetes.io/instance=simple-thing
                        app.openshift.io/runtime=golang
                        boson.dev/function=true
                        boson.dev/runtime=go
                        function.knative.dev=true
                        function.knative.dev/name=simple-thing
                        function.knative.dev/runtime=go
                        serving.knative.dev/configuration=simple-thing
                        serving.knative.dev/configurationGeneration=1
                        serving.knative.dev/configurationUID=b2568fb2-df75-4edb-acd8-6c813a2f9c24
                        serving.knative.dev/revision=simple-thing-00001
                        serving.knative.dev/revisionUID=9324672a-35ed-4617-ab93-eea063f7e26b
                        serving.knative.dev/service=simple-thing
                        serving.knative.dev/serviceUID=50b86d2a-6606-4460-8b8b-baada24efc27
Annotations:            app.openshift.io/vcs-ref: 
                        app.openshift.io/vcs-uri: 
                        dapr.io/app-id: simple-thing
                        dapr.io/app-port: 8080
                        dapr.io/enable-api-logging: true
                        dapr.io/enabled: true
                        dapr.io/metrics-port: 9092
                        deployment.kubernetes.io/revision: 1
                        serving.knative.dev/creator: system:admin
Selector:               serving.knative.dev/revisionUID=9324672a-35ed-4617-ab93-eea063f7e26b
Replicas:               1 desired | 1 updated | 1 total | 0 available | 1 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  0 max unavailable, 25% max surge
Pod Template:
  Labels:       app=simple-thing-00001
                app.kubernetes.io/instance=simple-thing
                app.openshift.io/runtime=golang
                boson.dev/function=true
                boson.dev/runtime=go
                function.knative.dev=true
                function.knative.dev/name=simple-thing
                function.knative.dev/runtime=go
                serving.knative.dev/configuration=simple-thing
                serving.knative.dev/configurationGeneration=1
                serving.knative.dev/configurationUID=b2568fb2-df75-4edb-acd8-6c813a2f9c24
                serving.knative.dev/revision=simple-thing-00001
                serving.knative.dev/revisionUID=9324672a-35ed-4617-ab93-eea063f7e26b
                serving.knative.dev/service=simple-thing
                serving.knative.dev/serviceUID=50b86d2a-6606-4460-8b8b-baada24efc27
  Annotations:  app.openshift.io/vcs-ref: 
                app.openshift.io/vcs-uri: 
                dapr.io/app-id: simple-thing
                dapr.io/app-port: 8080
                dapr.io/enable-api-logging: true
                dapr.io/enabled: true
                dapr.io/metrics-port: 9092
                serving.knative.dev/creator: system:admin
  Containers:
   user-container:
    Image:           index.docker.io/matzew/simple-thing@sha256:aeec70dc5b8dbfe5d393db0df076bffdf6e0bde5f3c6dd911935763735bdb6fd
    Port:            8080/TCP
    Host Port:       0/TCP
    SeccompProfile:  RuntimeDefault
    Liveness:        http-get http://:8080/health/liveness delay=0s timeout=1s period=10s #success=1 #failure=3
    Environment:
      BUILT:            20240704T124346
      ADDRESS:          0.0.0.0
      PORT:             8080
      K_REVISION:       simple-thing-00001
      K_CONFIGURATION:  simple-thing
      K_SERVICE:        simple-thing
    Mounts:             <none>
   queue-proxy:
    Image:       registry.redhat.io/openshift-serverless-1/serving-queue-rhel8@sha256:20fa7da4753f888dbb495950cf1c946cbbf7c7fddc23ee3a58c8160687198428
    Ports:       8022/TCP, 9090/TCP, 9091/TCP, 8012/TCP, 8112/TCP
    Host Ports:  0/TCP, 0/TCP, 0/TCP, 0/TCP, 0/TCP
    Requests:
      cpu:      25m
    Readiness:  http-get http://:8012/ delay=0s timeout=1s period=10s #success=1 #failure=3
    Environment:
      SERVING_NAMESPACE:                                 default
      SERVING_SERVICE:                                   simple-thing
      SERVING_CONFIGURATION:                             simple-thing
      SERVING_REVISION:                                  simple-thing-00001
      QUEUE_SERVING_PORT:                                8012
      QUEUE_SERVING_TLS_PORT:                            8112
      CONTAINER_CONCURRENCY:                             0
      REVISION_TIMEOUT_SECONDS:                          300
      REVISION_RESPONSE_START_TIMEOUT_SECONDS:           0
      REVISION_IDLE_TIMEOUT_SECONDS:                     0
      SERVING_POD:                                        (v1:metadata.name)
      SERVING_POD_IP:                                     (v1:status.podIP)
      SERVING_LOGGING_CONFIG:                            
      SERVING_LOGGING_LEVEL:                             
      SERVING_REQUEST_LOG_TEMPLATE:                      {"httpRequest": {"requestMethod": "{{.Request.Method}}", "requestUrl": "{{js .Request.RequestURI}}", "requestSize": "{{.Request.ContentLength}}", "status": {{.Response.Code}}, "responseSize": "{{.Response.Size}}", "userAgent": "{{js .Request.UserAgent}}", "remoteIp": "{{js .Request.RemoteAddr}}", "serverIp": "{{.Revision.PodIP}}", "referer": "{{js .Request.Referer}}", "latency": "{{.Response.Latency}}s", "protocol": "{{.Request.Proto}}"}, "traceId": "{{index .Request.Header "X-B3-Traceid"}}"}
      SERVING_ENABLE_REQUEST_LOG:                        false
      SERVING_REQUEST_METRICS_BACKEND:                   prometheus
      SERVING_REQUEST_METRICS_REPORTING_PERIOD_SECONDS:  5
      TRACING_CONFIG_BACKEND:                            none
      TRACING_CONFIG_ZIPKIN_ENDPOINT:                    
      TRACING_CONFIG_DEBUG:                              false
      TRACING_CONFIG_SAMPLE_RATE:                        0.1
      USER_PORT:                                         8080
      SYSTEM_NAMESPACE:                                  knative-serving
      METRICS_DOMAIN:                                    knative.dev/internal/serving
      SERVING_READINESS_PROBE:                           {"httpGet":{"path":"/health/readiness","port":8080,"host":"127.0.0.1","scheme":"HTTP","httpHeaders":[{"name":"K-Kubelet-Probe","value":"queue"}]},"successThreshold":1}
      ENABLE_PROFILING:                                  false
      SERVING_ENABLE_PROBE_REQUEST_LOG:                  false
      METRICS_COLLECTOR_ADDRESS:                         
      HOST_IP:                                            (v1:status.hostIP)
      ENABLE_HTTP2_AUTO_DETECTION:                       false
      ENABLE_HTTP_FULL_DUPLEX:                           false
      ROOT_CA:                                           
      ENABLE_MULTI_CONTAINER_PROBES:                     false
    Mounts:                                              <none>
  Volumes:                                               <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      False   MinimumReplicasUnavailable
  Progressing    True    ReplicaSetUpdated
OldReplicaSets:  <none>
NewReplicaSet:   simple-thing-00001-deployment-99d689849 (1/1 replicas created)
Events:
  Type    Reason             Age    From                   Message
  ----    ------             ----   ----                   -------
  Normal  ScalingReplicaSet  6m15s  deployment-controller  Scaled up replica set simple-thing-00001-deployment-99d689849 to 1

I am also not able to CURL it...

jrangelramos commented 2 months ago

Fixed by https://github.com/knative/func/pull/2441