Creating container for route directive adapter [SOLVED]

Hello!

Please let me know if I should post this topic in a different category!

I am having problems creating a custom out-of-process adapter, specifically my current problem is building a container that can successfully starts. I am following this guide and modifying as I go: https://github.com/istio/istio/wiki/Route-directive-adapter-development-guide

Contextual info:

My environment includes:

  • archlinux 5.1.6-arch1-1-ARCH
  • a checkout of istio 1.1.7
  • go1.12.5
  • docker 18.09.6-ce
  • fish shell 3.0.2

And any code referenced should be available here:
rlfi adapter source repo

I am running into the following error when running the built container which also fails when deployed to kubernetes:

15:11 user@localhost ~/.g/i/s/i/istio ((1.1.7)) docker run -it disorderlylabs/rlfi-adapter:latest
standard_init_linux.go:211: exec user process caused “no such file or directory”

I am creating (and building) an adapter, named rlfi (this is the content of a fish script):

set CGO_ENABLED 0
set GOOS linux
set GOARCH amd64

go build -a -o rlfi/rlfi ./rlfi/main/main.go

and building the container with the following Dockerfile:

FROM scratch
ADD rlfi /rlfi
EXPOSE 9070
ENTRYPOINT ["/rlfi"]

I can run the executable, rlfi/rlfi, which should be mounted as /rlfi in the container:

15:17 user@localhost ~/.g/i/s/i/istio ((1.1.7)) pwd
/home/user/.go-paths/istio-d41d8cd98f/src/istio.io/istio

15:18 user@localhost ~/.g/i/s/i/istio ((1.1.7)) ls -1 rlfi/
build.fish
config/
Dockerfile
handler.yaml
input-instance.yaml
main/
rlfi*
rlfi.go
rlfi.pb.html
template_handler.gen.go
template_handler_service.descriptor_set
template_handler_service.pb.go
template_handler_service.proto
template.proto
template_proto.descriptor_set
template.yaml
test-handler-rule.yaml

15:17 user@localhost ~/.g/i/s/i/istio ((1.1.7)) rlfi/rlfi &

which I send an empty GET to:

15:17 user@localhost ~/.g/i/s/i/istio ((1.1.7)) curl -vv -s localhost:9070

  • Trying ::1:9070…
  • TCP_NODELAY set
  • Connected to localhost (::1) port 9070 (#0)

GET / HTTP/1.1
Host: localhost:9070
User-Agent: curl/7.65.0
Accept: /

  • Failed writing body (0 != 9)
  • Closing connection 0

And logs the following (I assume this error is due to me sending an empty request that fails validation in the handler):

2019-06-08T22:17:40.903473Z info grpc: Server.Serve failed to create ServerTransport: connection error: desc = “transport: http2Server.HandleStreams received bogus greeting from client: “GET / HTTP/1.1\r\nHost: lo””

I actually seem to have found the problem, which if I were to guess, appears to be the formatting of the code for the config protobuf:
https://github.com/disorderlylabs/envoyage/blob/bfd32b33e45263a32796fee58248ff9a998b58f6/code/istio/mixer-adapters/rlfi/config/config.proto

if anyone can tell me whether this code really does cause a problem and why, that would be greatly appreciated!

message Params {
    google.protobuf.Duration valid_duration = 1 [
        (gogoproto.nullable)    = false,
        (gogoproto.stdduration) = true
    ];
}

Thanks!

P.S. I’ll leave this topic without any [solved] designation for a few days.

A couple of things:

  1. Port 9070 is a gRPC port which is based off HTTP/2. Using curl directly is not expected to work. At the very least it should be HTTP/2 POST with gRPC method in the request.

  2. The annotations are optional, so you can safely remove them to narrow down the scope.

  3. It could be something about the binary itself, which causes it to be not statically linked on your OS. In that case, I recommend using a full OS image (ubuntu:xenial) as the base image in the docker.

Thanks very much for the response! I also just realized you are the author of that route adapter guide I had been using, so thanks a lot for that too!

  1. That totally makes sense, although after fixing the issue, still using curl doesn’t result in the error log message. I will have to test again to see if that’s only if I use the --http2 option, though.

  2. Are the “annotations” you’re referring to the gogoproto.nullable, etc.? For example, if I were to remove the annotations, would I have:

message Params {
google.protobuf.Duration valid_duration = 1;
}

  1. it didn’t seem to be a problem with the binary, but I am curious if using a full OS image might make initial development easier, so I’ll certainly give that a try.

Thanks again!