knative / eventing

Event-driven application platform for Kubernetes
https://knative.dev/docs/eventing
Apache License 2.0
1.42k stars 597 forks source link

Hello world sample doesn't work #3011

Closed haf closed 4 years ago

haf commented 4 years ago

Describe the bug The hello world sample here doesn't work: https://knative.dev/development/eventing/samples/helloworld/helloworld-go/

Expected behavior Should be possible to compile the app with the dockerfile.

To Reproduce

Follow the hello world guide.

1) missing package statement in the entry point file 2) missing instructions on how to download/initialise go mod or otherwise download "github.com/cloudevents/sdk-go/v2" 3) once it compiles locally (macOS, Go 1.14), the linux build fails with:

Step 4/8 : RUN CGO_ENABLED=0 GOOS=linux go build -v -o helloworld
 ---> Running in 25fe283ac2f8
github.com/knative/docs/helloworld/vendor/go.opencensus.io/internal/tagencoding
github.com/knative/docs/helloworld/vendor/github.com/hashicorp/golang-lru/simplelru
github.com/knative/docs/helloworld/vendor/go.opencensus.io/trace/internal
github.com/knative/docs/helloworld/vendor/go.opencensus.io
github.com/knative/docs/helloworld/vendor/go.uber.org/zap/buffer
github.com/knative/docs/helloworld/vendor/go.uber.org/atomic
github.com/knative/docs/helloworld/vendor/go.opencensus.io/resource
github.com/knative/docs/helloworld/vendor/github.com/pkg/errors
github.com/knative/docs/helloworld/vendor/github.com/cloudevents/sdk-go/v2/types
github.com/knative/docs/helloworld/vendor/go.opencensus.io/tag
github.com/knative/docs/helloworld/vendor/go.uber.org/zap/internal/color
github.com/knative/docs/helloworld/vendor/go.uber.org/zap/internal/bufferpool
github.com/knative/docs/helloworld/vendor/go.uber.org/multierr
github.com/knative/docs/helloworld/vendor/go.uber.org/zap/internal/exit
github.com/knative/docs/helloworld/vendor/go.opencensus.io/metric/metricdata
net
github.com/knative/docs/helloworld/vendor/github.com/lightstep/tracecontext.go/traceparent
github.com/knative/docs/helloworld/vendor/github.com/lightstep/tracecontext.go/tracestate
github.com/knative/docs/helloworld/vendor/go.opencensus.io/metric/metricproducer
github.com/knative/docs/helloworld/vendor/go.uber.org/zap/zapcore
github.com/knative/docs/helloworld/vendor/go.opencensus.io/stats/internal
github.com/knative/docs/helloworld/vendor/go.opencensus.io/internal
github.com/knative/docs/helloworld/vendor/go.opencensus.io/trace/tracestate
github.com/knative/docs/helloworld/vendor/go.opencensus.io/stats
github.com/knative/docs/helloworld/vendor/go.opencensus.io/trace
github.com/knative/docs/helloworld/vendor/github.com/cloudevents/sdk-go/v2/observability
github.com/knative/docs/helloworld/vendor/go.opencensus.io/stats/view
github.com/knative/docs/helloworld/vendor/github.com/cloudevents/sdk-go/v2/event/datacodec/text
github.com/knative/docs/helloworld/vendor/github.com/cloudevents/sdk-go/v2/event/datacodec/xml
github.com/knative/docs/helloworld/vendor/github.com/cloudevents/sdk-go/v2/event/datacodec/json
github.com/knative/docs/helloworld/vendor/github.com/cloudevents/sdk-go/v2/event/datacodec
github.com/knative/docs/helloworld/vendor/github.com/cloudevents/sdk-go/v2/event
github.com/knative/docs/helloworld/vendor/github.com/cloudevents/sdk-go/v2/binding/format
github.com/knative/docs/helloworld/vendor/github.com/cloudevents/sdk-go/v2/binding/spec
github.com/knative/docs/helloworld/vendor/github.com/cloudevents/sdk-go/v2/extensions
github.com/knative/docs/helloworld/vendor/github.com/cloudevents/sdk-go/v2/binding
net/textproto
internal/x/net/http/httpproxy
crypto/x509
github.com/knative/docs/helloworld/vendor/github.com/google/uuid
github.com/knative/docs/helloworld/vendor/github.com/cloudevents/sdk-go/v2/protocol
# github.com/knative/docs/helloworld/vendor/github.com/cloudevents/sdk-go/v2/protocol
vendor/github.com/cloudevents/sdk-go/v2/protocol/result.go:19:16: undefined: errors.Is
vendor/github.com/cloudevents/sdk-go/v2/protocol/result.go:35:16: undefined: errors.As
vendor/github.com/cloudevents/sdk-go/v2/protocol/result.go:89:9: undefined: errors.Is
internal/x/net/http/httpguts
crypto/tls
net/http/httptrace
net/http
github.com/knative/docs/helloworld/vendor/go.opencensus.io/trace/propagation
github.com/knative/docs/helloworld/vendor/go.uber.org/zap
github.com/knative/docs/helloworld/vendor/go.opencensus.io/plugin/ochttp/propagation/b3
github.com/knative/docs/helloworld/vendor/go.opencensus.io/plugin/ochttp/propagation/tracecontext
github.com/knative/docs/helloworld/vendor/go.opencensus.io/plugin/ochttp
github.com/knative/docs/helloworld/vendor/github.com/cloudevents/sdk-go/v2/context
The command '/bin/sh -c CGO_ENABLED=0 GOOS=linux go build -v -o helloworld' returned a non-zero code: 2

After fixing this you get:

$ kubectl --namespace knative-samples run curl --image=radial/busyboxplus:curl -it
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
If you don't see a command prompt, try pressing enter.
[ root@curl-6bf6db5c4f-crcfb:/ ]$ curl -v "default-broker.knative-samples.svc.cluster.local" \
>     -X POST \
>     -H "Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f79" \
>     -H "Ce-Specversion: 1.0" \
>     -H "Ce-Type: dev.knative.samples.helloworld" \
>     -H "Ce-Source: dev.knative.samples/helloworldsource" \
>     -H "Content-Type: application/json" \
>     -d '{"msg":"Hello World from the curl pod."}'
* Couldn't resolve host 'default-broker.knative-samples.svc.cluster.local'
curl: (6) Couldn't resolve host 'default-broker.knative-samples.svc.cluster.local'

when you've followed everything here https://knative.dev/development/install/any-kubernetes-cluster/ specifically, this makefile:

i_is:
    istioctl manifest apply --set profile=demo
    kubectl label namespace default istio-injection=enabled
    kubectl apply -f istio/samples/bookinfo/networking/bookinfo-gateway.yaml
    kubectl get svc istio-ingressgateway -n istio-system
    ./verify

i_kn_s:
    kubectl apply --filename https://storage.googleapis.com/knative-nightly/serving/latest/serving-crds.yaml
    kubectl apply --filename https://storage.googleapis.com/knative-nightly/serving/latest/serving-core.yaml

i_kn_istio:
    kubectl apply --filename https://storage.googleapis.com/knative-nightly/net-istio/latest/release.yaml

i_kn_e:
    kubectl apply --filename istio/k8s/istio-knative-extras.yaml
    kubectl apply --filename https://storage.googleapis.com/knative-nightly/eventing/latest/eventing-crds.yaml
    kubectl apply --filename https://storage.googleapis.com/knative-nightly/eventing/latest/eventing-core.yaml
    kubectl apply --filename https://storage.googleapis.com/knative-nightly/eventing/latest/channel-broker.yaml
    kustomize build knative-eventing/base | kubectl apply -f -

i_kafka:
    curl -L "https://github.com/strimzi/strimzi-kafka-operator/releases/download/0.16.2/strimzi-cluster-operator-0.16.2.yaml" \
        | sed 's/namespace: .*/namespace: kafka/' \
        | kubectl -n kafka apply -f -
    kustomize build kafka/base | kubectl apply -f -
    kubectl apply --filename https://storage.googleapis.com/knative-nightly/eventing-contrib/latest/kafka-source.yaml

install: i_is i_kn_s i_kn_istio i_kn_e i_kafka

optional:
    curl -L https://istio.io/downloadIstio | sh -

kiali:
    istioctl dashboard kiali

hello:
    (cd helloworld && make)

Knative release version HEAD of this repo

Additional context Priority: fairly low, but it stopped me right in my tracks with onboarding

vaikas commented 4 years ago

@akashrv would you mind taking a look here? I think you wrote this sample?

akashrv commented 4 years ago

Ack. Will take a look.

sebgoa commented 4 years ago

I confirm that this is a bug. I am commenting on the PR

vaikas commented 4 years ago

@akashrv have you had a chance to take a look at this?

akashrv commented 4 years ago

@akashrv have you had a chance to take a look at this?

Looking at it now. I have the build fix + switch to go mod. I'll wait for a day to see if @haf responds on his PR, or else will send a PR and we can get this fixed.

akashrv commented 4 years ago

https://github.com/knative/docs/pull/2438 --> Please approve.