GithubHelp home page GithubHelp logo

adobe-apiplatform / apigateway Goto Github PK

View Code? Open in Web Editor NEW
301.0 34.0 57.0 2.13 MB

A Performant API Gateway based on NGINX and Openresty

License: MIT License

Makefile 4.01% Shell 16.67% HTML 3.31% Lua 31.89% Perl 5.18% Python 7.49% Dockerfile 31.46%

apigateway's Introduction

apigateway

A performant API Gateway based on Openresty and NGINX.

Table of Contents

Status

The current project is considered production ready.

Quick start

Standalone

$ docker run --name="apigateway" \
            -p 80:80 \
            -e "LOG_LEVEL=info" \
            adobeapiplatform/apigateway:latest

With Apache Mesos

$ docker run --name="apigateway" \
            -p 80:80 \
            -e "MARATHON_HOST=http://<marathon_host>:<port>" \
            -e "LOG_LEVEL=info" \
            adobeapiplatform/apigateway:latest

This command starts an API Gateway that automatically discovers the services running in Marathon. The discovered services are exposed on individual VHosts as you can see in the config file.

Accessing a Marathon app locally

For example, if you have an application named hello-world you can access it on its VHost in 2 ways:

  1. Edit /etc/hosts and add <docker_host_ip> hello-world.api.localhost then browse to http://hello-world.api.localhost
  2. Sending the Host header in a curl command: curl -H "Host:hello-world.api.localhost" http://<docker_host_ip>

The discovery script is provided as an example for a quick-start and it can be replaced with your favourite discovery mechanism. The script updates a configuration file containing all the NGINX upstreams that are used in the config file.

Accessing a Marathon app remotely

All you need to do is to create a DNS entry like *.api.example.com or *.gw.example.com and have it resolve to the nodes running the Gateway.

Assuming there is an application deployed in Marathon called hello-world it can be accessed at the URL: http://hello-world.api.example.com The Gateway is automatically proxying the request to the hello-world application in Marathon.

If you call http://my-custom-app.api.example.com the Gateway will proxy to a Marathon app named my-custom-app. If the application is not deployed in Marathon a 5xx error is returned back to the client. This behaviour is ofcourse configurable.

Running with a different configuration folder

One way to simplify the configuration of the Gateway is to copy the api-gateway-config folder in S3, having all nodes syncing from that location. For the moment only AWS S3 is supported but the plan is to add support for other clouds too.

In order to work with S3 the Gateway needs to know the bucket. The command is similar to the one above with an extra environment variable named REMOTE_CONFIG

docker run --name="apigateway" \
            -p 80:80 \
            -e "MARATHON_HOST=http://<marathon_host>:<port>" \
            -e "REMOTE_CONFIG=s3://api-gateway-config-bucket" \
            -e "LOG_LEVEL=info" \
            adobeapiplatform/apigateway:latest

s3://api-gateway-config-bucket should contain something similar to what's in the api-gateway-config folder. For any customization it would be good to start from there. There are only 2 files that won't be synchronised:

  • /etc/api-gateway/conf.d/includes/resolvers.conf . Read bellow for more info
  • https://github.com/adobe-apiplatform/apigateway/blob/master/api-gateway-config/environment.conf.d/api-gateway-upstreams.http.conf which is automatically generated by the Marathon Discovery script.

By default the access to the S3 bucket is done using IAM roles, but AWS Credentials can also be specified through environment variables:

docker run --name="apigateway" \
            -p 80:80 \
            -e "MARATHON_HOST=http://<marathon_host>:<port>" \
            -e "REMOTE_CONFIG=s3://api-gateway-config-bucket" \
            -e "AWS_ACCESS_KEY_ID=--change-me--" \
            -e "AWS_SECRET_ACCESS_KEY=--change-me--" \
            -e "LOG_LEVEL=info" \
            adobeapiplatform/apigateway:latest

By default the remote config is checked for changes every 10s. This interval is configurable through the REMOTE_CONFIG_SYNC_INTERVAL env variable. There are a few things to take into consideration when changing this value:

  • How often the configs really change
  • Cost. Some tools may make 1 API request per file to compare it. I.e. in S3 72 config files checked every 10s costs $7.46 but when checked every 30s it's only $2.4, times number of GW nodes.
  • Average time for an API Request. When reloading the GW the existing NGINX processes handling active connections are kept in the background until the request completes. So reloading the Gateway too fast may have the side effect of keeping too many processes running at the same time. This may, or may not be a problem but it's good to be aware of it.

Customizing the sync command

The sync command used for downloading the configuration files can be controlled via REMOTE_CONFIG_SYNC_CMD as well. This ENV VAR overrides the REMOTE_CONFIG one.

Resolvers

While starting up this container automatically creates the /etc/api-gateway/conf.d/includes/resolvers.conf config file using /etc/resolv.conf as the source. To learn more about the resolver directive in NGINX see the docs.

Running the API Gateway outside of Marathon and Mesos

Besides the discovery part which is dependent on Marathon at the moment, the API Gateway can run on its own as well. The Marathon service discovery is activated with the -e "MARATHON_HOST=http://<marathon_host>:<port>/".

What's inside

Module Version Details
Openresty 1.13.6.1 Installed in /usr/local/sbin/api-gateway
Openresty compiled --with-debug 1.13.6.1 Installed in /usr/local/sbin/api-gateway-debug which enables debugging log
Test Nginx 0.24 Useful for executing integration tests from the container.
It's installed in /usr/local/test-nginx-0.24/.
It's also used during Docker build to execute make test on lua modules.
PCRE 8.37 Enables PCRE JIT support
ZeroMQ 4.0.5 ZeroMQ
CZMQ 2.2.0 CZMQ - High-level C Binding for ZeroMQ
Modules for API Management and Logging
Module Version Description
api-gateway-config-supervisor 1.0.3 Syncs config files from Amazon S3 reloading the gateway with the updates
api-gateway-cachemanager 1.0.1 Lua library for managing multiple cache stores
api-gateway-hmac 1.0.0 HMAC support for Lua with multiple algorithms, via OpenSSL and FFI
api-gateway-aws 1.7.1 AWS SDK for Nginx in Lua
api-gateway-request-validation 1.2.4 API Request Validation framework
api-gateway-async-logger 1.0.1 Performant async logger
api-gateway-zmq-logger 1.0.0 Lua logger for ZMQ with FFI and CZMQ
api-gateway-request-tracking 1.0.1 Usage and Tracking Handler for the API Gateway
Other Lua Modules
Module Version Description
lua-resty-http v0.07 Lua HTTP client cosocket driver for OpenResty / ngx_lua
lua-resty-iputils v0.2.0 Utility functions for working with IP addresses in Openresty

Performance

The following performance tests results have been obtained on a virtual machine with 8 CPU cores and 4GB Memory.

The API Gateway container has been started with 4 CPU cores and net=host :

docker run --cpuset-cpus=0-3 --net=host --name="apigateway" -e "LOG_LEVEL=notice" adobeapiplatform/apigateway:latest

WRK test has been started with 4 CPU cores and net=host:

docker run --cpuset-cpus=4-7 --net=host williamyeh/wrk:4.0.1 -t4 -c1000 -d30s http://<docker_host_ip>/health-check
Running 30s test @ http://192.168.75.158/health-check
  4 threads and 1000 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    30.38ms   73.80ms   1.16s    90.90%
    Req/Sec    35.26k    11.98k   83.70k    68.72%
  4214013 requests in 30.06s, 1.28GB read

Requests/sec: 140165.09

Transfer/sec:     43.57MB

Developer guide

To build the docker image locally use:

 make docker

To SSH into the newly built image use ( note that this is not the running image):

 make docker-ssh

Running and Stopping the Docker image

 make docker-run

The main API Gateway process is exposed to port 80. To test that the Gateway works see its health-check:

 $ curl http://<docker_host_ip>/health-check
   API-Platform is running!

If you're up for a quick performance test, you can play with Apache Benchmark via Docker:

 docker run jordi/ab ab -k -n 200000 -c 500 http://<docker_host_ip>/health-check

To run docker mounting the local api-gateway-config directory into /etc/api-gateway/ issue:

$ make docker-debug

In debug mode the docker container starts a special api-gateway compiled --with-debug providing very detailed debugging information. When started with -e "LOG_LEVEL=info" the output is quite verbose. To learn more about this option visit NGINX docs.

When done stop the image:

make docker-stop

Enabling API KEY Management through Redis

This command starts two docker containers: redis and gateway

make docker-compose

SSH into the running image

make docker-attach

Running the container in Mesos with Marathon

Make an HTTP POST on http://<marathon-host>/v2/apps with the following payload. For optimal performance leave the network on HOST mode. To learn more about the network modes visit the Docker documentation.

{
  "id": "api-gateway",
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "adobeapiplatform/apigateway:latest",
      "forcePullImage": true,
      "network": "HOST"
    }
  },
  "cpus": 4,
  "mem": 4096.0,
  "env": {
    "MARATHON_HOST": "http://<marathon_host>:<marathon_port>"
  },
  "constraints": [  [ "hostname","UNIQUE" ]  ],
  "ports": [ 80 ],
  "healthChecks": [
    {
      "protocol": "HTTP",
      "portIndex": 0,
      "path": "/health-check",
      "gracePeriodSeconds": 3,
      "intervalSeconds": 10,
      "timeoutSeconds": 10
    }
  ],
  "instances": 1
}

To run the Gateway only on specific nodes marked with slave_public you can add the property bellow to the main JSON object:

"acceptedResourceRoles": [ "slave_public" ]
Auto-discover and register Marathon tasks in the Gateway

To enable auto-discovery in a Mesos with Marathon framework define the following Environment Variables:

MARATHON_URL=http://<marathon-url-1>
MARATHON_TASKS=ws-.* ( NOT USED NOW. TBD IF THERE'S A NEED TO FILTER OUT SOME TASKS )

So the Docker command is now :

docker run --name="apigateway" \
            -p 8080:80 \
            -e "MARATHON_HOST=http://<marathon_host>:<port>/" \
            -e "LOG_LEVEL=info" \
            adobeapiplatform/apigateway:latest

apigateway's People

Contributors

2mia avatar andralungu avatar asteed avatar atrifan avatar bogdanciuca avatar corinapurcarea avatar cristianconstantin avatar ddascal avatar ddragosd avatar doronrk avatar selfxp avatar vdatcu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apigateway's Issues

How to proxy HTTPS requests?

I run apigateway w/o Marathon and Mesos. After I edited /etc/host and added the upstream entry manually into /etc/api-gateway/environment.conf.d/api-gateway-upstreams.http.conf

upstream microservice {  
 server microservice:8080 fail_timeout=10s;           
 keepalive 16;
}

I could access my microservice via http://microservice.api.localhost/.

However, I couldn't figure out a way to proxy HTTPs request to another service listening on port 443. Does apigateway support HTTPs access?

Execute commands inside the container only with unprivileged users

The apigateway container needs to run with root privileges as some of the commands executed inside the container are executed by root. Example here.
One way to fix this would be to create a new user beside the api-gateway one, in the same usergroup, and only execute commands inside container with these two existing users.

make docker failure

ubuntu 15.10 error is like this

Executing busybox-1.23.2-r0.trigger
Executing ca-certificates-20150426-r3.trigger
1 errors; 260 MiB in 70 packages
The command '/bin/sh -c apk update     && apk add gcc tar libtool zlib jemalloc jemalloc-dev perl     make musl-dev openssl-dev pcre-dev g++ zlib-dev curl python     perl-test-longstring perl-list-moreutils perl-http-message' returned a non-zero code: 1
Makefile:5: recipe for target 'docker' failed
make: *** [docker] Error 1

Increase the default number of worker connections

Currently the worker_connections directive is set to 1000 which is a low number when worker_processes is set to 1 as NGINX would only accept 1000 concurrent connections.

We could increase the setting to maybe 2^14 which is 16384 or 2^15 which is 32768 in order to facilitate benchmarks. I would suggest 2^14 to be in alignment with TechEmpower's benchmark: https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/frameworks/Lua/openresty/nginx.conf

Since it's not easy to come up with a number that fits all cases, for production use-cases it's best to provide a different api-gateway-config directory that would tune these setting as per the expected workload.

make docker-debug failure

When trying to run make docker-debug, I get the following recursive 400 Bad Request response even though no request was issued.

> Tue Aug  9 11:52:22 2016
 receiver got: Request</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<hr><cen
> Tue Aug  9 11:52:22 2016
 receiver got: : text/html
Content-Length: 178
Connection: close
Server: api-gateway/1.9.3.1

make docker-compose also fails.

make docker-run works as expected.

make docker fails - Step 16

failure point exec: "gcc": executable file not found in $PATH

full trace

Step 16 : RUN echo " ... installing api-gateway-config-supervisor  ... "     && echo "http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories     && apk update     && apk add make git go     && mkdir -p /tmp/api-gateway     && curl -k -L https://github.com/adobe-apiplatform/api-gateway-config-supervisor/archive/${CONFIG_SUPERVISOR_VERSION}.tar.gz -o /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}.tar.gz     && cd /tmp/api-gateway     && tar -xf /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}.tar.gz     && mkdir -p /tmp/go     && mv /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}/* /tmp/go     && cd /tmp/go     && make setup     && mkdir -p /tmp/go/Godeps/_workspace     && ln -s /tmp/go/vendor /tmp/go/Godeps/_workspace/src     && mkdir -p /tmp/go-src/src/github.com/adobe-apiplatform     && ln -s /tmp/go /tmp/go-src/src/github.com/adobe-apiplatform/api-gateway-config-supervisor     && GOPATH=/tmp/go/vendor:/tmp/go-src CGO_ENABLED=0 GOOS=linux /usr/lib/go/bin/godep  go build -ldflags "-s" -a -installsuffix cgo -o api-gateway-config-supervisor ./     && mv /tmp/go/api-gateway-config-supervisor /usr/local/sbin/     && echo "installing rclone sync ... "     && go get github.com/ncw/rclone     && mv /usr/lib/go/bin/rclone /usr/local/sbin/     && echo " cleaning up ... "     && rm -rf /usr/lib/go/bin/src     && rm -rf /tmp/go     && rm -rf /tmp/go-src     && rm -rf /usr/lib/go/bin/pkg/     && rm -rf /usr/lib/go/bin/godep     && apk del make git go     && rm -rf /var/cache/apk/*
 ---> Running in 5f1b4896b50c
 ... installing api-gateway-config-supervisor  ...
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
fetch http://dl-4.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
v3.4.3-2-g595ce63 [http://dl-cdn.alpinelinux.org/alpine/v3.4/main]
v3.4.2-11-g9b41a63 [http://dl-cdn.alpinelinux.org/alpine/v3.4/community]
v3.4.0-2052-g56f675a [http://dl-4.alpinelinux.org/alpine/edge/community]
OK: 6867 distinct packages available
(1/2) Installing git (2.8.3-r0)
(2/2) Installing go (1.7_rc4-r0)
Executing busybox-1.24.2-r9.trigger
OK: 312 MiB in 58 packages
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   154    0   154    0     0    371      0 --:--:-- --:--:-- --:--:--   372
100 4Step 16 : RUN echo " ... installing api-gateway-config-supervisor  ... "     && echo "http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories     && apk update     && apk add make git go     && mkdir -p /tmp/api-gateway     && curl -k -L https://github.com/adobe-apiplatform/api-gateway-config-supervisor/archive/${CONFIG_SUPERVISOR_VERSION}.tar.gz -o /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}.tar.gz     && cd /tmp/api-gateway     && tar -xf /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}.tar.gz     && mkdir -p /tmp/go     && mv /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}/* /tmp/go     && cd /tmp/go     && make setup     && mkdir -p /tmp/go/Godeps/_workspace     && ln -s /tmp/go/vendor /tmp/go/Godeps/_workspace/src     && mkdir -p /tmp/go-src/src/github.com/adobe-apiplatform     && ln -s /tmp/go /tmp/go-src/src/github.com/adobe-apiplatform/api-gateway-config-supervisor     && GOPATH=/tmp/go/vendor:/tmp/go-src CGO_ENABLED=0 GOOS=linux /usr/lib/go/bin/godep  go build -ldflags "-s" -a -installsuffix cgo -o api-gateway-config-supervisor ./     && mv /tmp/go/api-gateway-config-supervisor /usr/local/sbin/     && echo "installing rclone sync ... "     && go get github.com/ncw/rclone     && mv /usr/lib/go/bin/rclone /usr/local/sbin/     && echo " cleaning up ... "     && rm -rf /usr/lib/go/bin/src     && rm -rf /tmp/go     && rm -rf /tmp/go-src     && rm -rf /usr/lib/go/bin/pkg/     && rm -rf /usr/lib/go/bin/godep     && apk del make git go     && rm -rf /var/cache/apk/*
 ---> Running in 5f1b4896b50c
 ... installing api-gateway-config-supervisor  ...
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
fetch http://dl-4.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
v3.4.3-2-g595ce63 [http://dl-cdn.alpinelinux.org/alpine/v3.4/main]
v3.4.2-11-g9b41a63 [http://dl-cdn.alpinelinux.org/alpine/v3.4/community]
v3.4.0-2052-g56f675a [http://dl-4.alpinelinux.org/alpine/edge/community]
OK: 6867 distinct packages available
(1/2) Installing git (2.8.3-r0)
(2/2) Installing go (1.7_rc4-r0)
Executing busybox-1.24.2-r9.trigger
OK: 312 MiB in 58 packages
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   154    0   154    0     0    371      0 --:--:-- --:--:-- --:--:--   372
100 49861    0 49861    0     0  56512      0 --:--:-- --:--:-- --:--:--  347k
go get github.com/tools/godep
# runtime/cgo
exec: "gcc": executable file not found in $PATH
make: *** [setup] Error 2
Makefile:6: recipe for target 'setup' failed
The command '/bin/sh -c echo " ... installing api-gateway-config-supervisor  ... "     && echo "http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories     && apk update     && apk add make git go     && mkdir -p /tmp/api-gateway     && curl -k -L https://github.com/adobe-apiplatform/api-gateway-config-supervisor/archive/${CONFIG_SUPERVISOR_VERSION}.tar.gz -o /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}.tar.gz     && cd /tmp/api-gateway     && tar -xf /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}.tar.gz     && mkdir -p /tmp/go     && mv /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}/* /tmp/go     && cd /tmp/go     && make setup     && mkdir -p /tmp/go/Godeps/_workspace     && ln -s /tmp/go/vendor /tmp/go/Godeps/_workspace/src     && mkdir -p /tmp/go-src/src/github.com/adobe-apiplatform     && ln -s /tmp/go /tmp/go-src/src/github.com/adobe-apiplatform/api-gateway-config-supervisor     && GOPATH=/tmp/go/vendor:/tmp/go-src CGO_ENABLED=0 GOOS=linux /usr/lib/go/bin/godep  go build -ldflags "-s" -a -installsuffix cgo -o api-gateway-config-supervisor ./     && mv /tmp/go/api-gateway-config-supervisor /usr/local/sbin/     && echo "installing rclone sync ... "     && go get github.com/ncw/rclone     && mv /usr/lib/go/bin/rclone /usr/local/sbin/     && echo " cleaning up ... "     && rm -rf /usr/lib/go/bin/src     && rm -rf /tmp/go     && rm -rf /tmp/go-src     && rm -rf /usr/lib/go/bin/pkg/     && rm -rf /usr/lib/go/bin/godep     && apk del make git go     && rm -rf /var/cache/apk/*' returned a non-zero code: 2
make: *** [docker] Error 2
```9861    0 49861    0     0  56512      0 --:--:-- --:--:-- --:--:--  347k
go get github.com/tools/godep
# runtime/cgo
exec: "gcc": executable file not found in $PATH
make: *** [setup] Error 2
Makefile:6: recipe for target 'setup' failed
The command '/bin/sh -c echo " ... installing api-gateway-config-supervisor  ... "     && echo "http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories     && apk update     && apk add make git go     && mkdir -p /tmp/api-gateway     && curl -k -L https://github.com/adobe-apiplatform/api-gateway-config-supervisor/archive/${CONFIG_SUPERVISOR_VERSION}.tar.gz -o /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}.tar.gz     && cd /tmp/api-gateway     && tar -xf /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}.tar.gz     && mkdir -p /tmp/go     && mv /tmp/api-gateway/api-gateway-config-supervisor-${CONFIG_SUPERVISOR_VERSION}/* /tmp/go     && cd /tmp/go     && make setup     && mkdir -p /tmp/go/Godeps/_workspace     && ln -s /tmp/go/vendor /tmp/go/Godeps/_workspace/src     && mkdir -p /tmp/go-src/src/github.com/adobe-apiplatform     && ln -s /tmp/go /tmp/go-src/src/github.com/adobe-apiplatform/api-gateway-config-supervisor     && GOPATH=/tmp/go/vendor:/tmp/go-src CGO_ENABLED=0 GOOS=linux /usr/lib/go/bin/godep  go build -ldflags "-s" -a -installsuffix cgo -o api-gateway-config-supervisor ./     && mv /tmp/go/api-gateway-config-supervisor /usr/local/sbin/     && echo "installing rclone sync ... "     && go get github.com/ncw/rclone     && mv /usr/lib/go/bin/rclone /usr/local/sbin/     && echo " cleaning up ... "     && rm -rf /usr/lib/go/bin/src     && rm -rf /tmp/go     && rm -rf /tmp/go-src     && rm -rf /usr/lib/go/bin/pkg/     && rm -rf /usr/lib/go/bin/godep     && apk del make git go     && rm -rf /var/cache/apk/*' returned a non-zero code: 2
make: *** [docker] Error 2

GO error when building Dockerfile

I get this error when running make docker

go get github.com/tools/godep
godep: [WARNING]: godep should only be used inside a valid go package directory and
godep: [WARNING]: may not function correctly. You are probably outside of your $GOPATH.
godep: [WARNING]:	Current Directory: /tmp/go
godep: [WARNING]:	$GOPATH: /tmp/go/vendor:/tmp/go-src
godep: WARNING: Godep workspaces (./Godeps/_workspace) are deprecated and support for them will be removed when go1.8 is released.
godep: WARNING: Go version (go1.11) & $GO15VENDOREXPERIMENT= wants to enable the vendor experiment, but disabling because a Godep workspace (Godeps/_workspace) exists
# _/tmp/go
/usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/tmp/go-link-977644414/go.o:(.data+0x8): undefined reference to `x_cgo_callers'
/tmp/go-link-977644414/go.o:(.data+0x10): undefined reference to `x_cgo_init'
/tmp/go-link-977644414/go.o:(.data+0x18): undefined reference to `x_cgo_mmap'
/tmp/go-link-977644414/go.o:(.data+0x20): undefined reference to `x_cgo_munmap'
/tmp/go-link-977644414/go.o:(.data+0x28): undefined reference to `x_cgo_notify_runtime_init_done'
/tmp/go-link-977644414/go.o:(.data+0x30): undefined reference to `x_cgo_sigaction'
/tmp/go-link-977644414/go.o:(.data+0x38): undefined reference to `x_cgo_thread_start'
/tmp/go-link-977644414/go.o:(.data+0x160): undefined reference to `x_cgo_setenv'
/tmp/go-link-977644414/go.o:(.data+0x168): undefined reference to `x_cgo_unsetenv'
/tmp/go-link-977644414/go.o:(.data+0x170): undefined reference to `_cgo_yield'
collect2: error: ld returned 1 exit status

godep: go exit status 2

add build script for executing tests

Add another make test directive in the Makefile for executing the unit tests found in api-gateway-config/tests folder. The idea with this folder is that when extending the container and maybe add more scripts to a custom configuration, it would be great to run tests against those scripts. That's what really ensures the quality.

Eventually we can also consider running these tests as part of the Docker build.

integrate the conf folder with S3

If we can have the API Gateway pulling from S3 the folder api-gateway-config we get the flexibility to easily run it with different configurations without building a new container.

The alternative approach would be to have the sync'ing in a separate container but that's a little more complicated to handle in Mesos which is currently lacking Pods support. When Pods-like concepts get implemented then we can extract this code into its own container.

Please make proxy_read_timeout configurable

Hey guys,
we've hit an issue with requests that take more than 10s.

https://github.com/adobe-apiplatform/apigateway/blob/master/api-gateway-config/conf.d/marathon_apis.conf#L74-L76

The proxy_read_timeout is set at 10 seconds in the nginx server of apigateway and can not be changed via a setting in the dcos package.
https://git.corp.adobe.com/adobe-platform/dcos-universe-private/tree/master/repo/packages/A/apigateway/3

We can confirm that calls over 10s are getting 504 results.
We can't assume our API calls take less than 10s.
Could you please add this as an configurable parameter or provide a workaround for calls >10s?

193.105.140.131 - - [20/Apr/2017:07:59:12 +0000] request="GET /api/v1/072449F857E4EA160A49411B%40AdobeOrg/connections/58e74daea90440000ee5539a/objects HTTP/1.1" api_key="" status=504 bbs=84 rl=2025 rt=10.001 hr="http://connectorsrest-dev-c3ddb09d52--cr.gw.dev.mc.adobe.net/docs/" ua="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" xfwdf="-" upadd="10.13.100.7:26856" upstat=504 uprt="10.001" sid="connectorsrest-dev-c3ddb09d52--cr" sname="TBD" reqid=qGMkwjo5hR9ZeAOFNFEzaLQVnfnKv3dp
193.105.140.131 - - [20/Apr/2017:07:59:48 +0000] request="GET /api/v1/072449F857E4EA160A49411B%40AdobeOrg/connections/58e74daea90440000ee5539a/objects HTTP/1.1" api_key="" status=504 bbs=84 rl=2068 rt=10.002 hr="http://connectorsrest-dev-c3ddb09d52--cr.gw.dev.mc.adobe.net/docs/" ua="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" xfwdf="-" upadd="10.13.100.7:26856" upstat=504 uprt="10.002" sid="connectorsrest-dev-c3ddb09d52--cr" sname="TBD" reqid=ce6VTzuqWWdGKaRzIDiX3ChKfB60dCFw
193.105.140.131 - - [20/Apr/2017:08:06:17 +0000] request="GET /api/v1/072449F857E4EA160A49411B%40AdobeOrg/connections/58e74daea90440000ee5539a/objects HTTP/1.1" api_key="" status=504 bbs=84 rl=2068 rt=10.002 hr="http://connectorsrest-dev-c3ddb09d52--cr.gw.dev.mc.adobe.net/docs/" ua="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" xfwdf="-" upadd="10.13.100.7:26856" upstat=504 uprt="10.002" sid="connectorsrest-dev-c3ddb09d52--cr" sname="TBD" reqid=nfjnOGTldPSTDDqAyQeobSTvM5nAKMHP
193.105.140.131 - - [20/Apr/2017:09:33:18 +0000] request="GET /api/v1/072449F857E4EA160A49411B%40AdobeOrg/connections/58e74daea90440000ee5539a/objects HTTP/1.1" api_key="" status=504 bbs=84 rl=2062 rt=10.003 hr="http://connectorsrest-dev-c3ddb09d52--cr.gw.dev.mc.adobe.net/docs/" ua="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" xfwdf="-" upadd="10.13.100.7:7665" upstat=504 uprt="10.003" sid="connectorsrest-dev-c3ddb09d52--cr" sname="TBD" reqid=dtbTluSKImvdCgyodm2X6FXHCvMb1Ytq
193.105.140.131 - - [20/Apr/2017:12:27:04 +0000] request="GET /api/v1/072449F857E4EA160A49411B%40AdobeOrg/connections/58e74daea90440000ee5539a/objects HTTP/1.1" api_key="" status=504 bbs=84 rl=2062 rt=10.003 hr="http://connectorsrest-dev-c3ddb09d52--cr.gw.dev.mc.adobe.net/docs/" ua="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" xfwdf="-" upadd="10.13.100.7:7665" upstat=504 uprt="10.003" sid="connectorsrest-dev-c3ddb09d52--cr" sname="TBD" reqid=Pccf2KWrS0i2q6JqoKo9FkBSJofLOcdy
193.105.140.131 - - [20/Apr/2017:12:39:58 +0000] request="GET /api/v1/072449F857E4EA160A49411B%40AdobeOrg/connections/58e74daea90440000ee5539a/objects HTTP/1.1" api_key="" status=504 bbs=84 rl=2062 rt=10.003 hr="http://connectorsrest-dev-c3ddb09d52--cr.gw.dev.mc.adobe.net/docs/" ua="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" xfwdf="-" upadd="10.13.100.7:7665" upstat=504 uprt="10.003" sid="connectorsrest-dev-c3ddb09d52--cr" sname="TBD" reqid=VmOPIgZeqGGYsPV6uikbVZyfQpwSmQoy
193.105.140.131 - - [20/Apr/2017:12:53:07 +0000] request="GET /api/v1/072449F857E4EA160A49411B%40AdobeOrg/connections/58e74daea90440000ee5539a/objects HTTP/1.1" api_key="" status=504 bbs=84 rl=2062 rt=10.002 hr="http://connectorsrest-dev-c3ddb09d52--cr.gw.dev.mc.adobe.net/docs/" ua="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" xfwdf="-" upadd="10.13.100.7:7665" upstat=504 uprt="10.002" sid="connectorsrest-dev-c3ddb09d52--cr" sname="TBD" reqid=kEifTYGn7SnmFIKpfQtFUlNCWgJIa6fq
193.105.140.131 - - [20/Apr/2017:12:53:07 +0000] request="GET /api/v1/072449F857E4EA160A49411B%40AdobeOrg/connections/58e74daea90440000ee5539a/objects HTTP/1.1" api_key="" status=504 bbs=84 rl=2062 rt=10.001 hr="http://connectorsrest-dev-c3ddb09d52--cr.gw.dev.mc.adobe.net/docs/" ua="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" xfwdf="-" upadd="10.13.100.7:7665" upstat=504 uprt="10.001" sid="connectorsrest-dev-c3ddb09d52--cr" sname="TBD" reqid=n3ONgAcNjbZmTvWz3qCznhGJXCFOq1nH
127.0.0.1 - - [20/Apr/2017:13:21:18 +0000] request="GET /api/v1/072449F857E4EA160A49411B%40AdobeOrg/connections/58e74daea90440000ee5539a/objects HTTP/1.1" api_key="" status=504 bbs=84 rl=2028 rt=10.002 hr="http://connectorsrest-dev-c3ddb09d52--cr.gw.dev.mc.adobe.net/docs/" ua="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" xfwdf="-" upadd="10.13.100.7:7665" upstat=504 uprt="10.002" sid="connectorsrest-dev-c3ddb09d52--cr" sname="TBD" reqid=ApJD6zgwOkkwpQLqgcRVDzgELzqFxWWJ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.