Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/dns2 cli tcp override #1647

Merged
merged 21 commits into from
Sep 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f000979
Merge pull request #1599 from Mashape/hotfix/changelog
subnetmarco Sep 6, 2016
e04273f
Merge branch 'hotfix/dao-migrations-errors'
thibaultcha Sep 8, 2016
b2b5b18
docs(gh-templ) include startup logs info
Tieske Sep 8, 2016
b77581a
Merge branch 'docs/issue-template'
thibaultcha Sep 8, 2016
a6301dd
Merge branch 'master' into next
thibaultcha Sep 8, 2016
23c4f56
fix(cli) prevent xpcall handler to crash
thibaultcha Sep 13, 2016
46f9380
docs(readme) fix the second luacheck link
mortonfox Sep 13, 2016
558ec50
docs(readme) fix the second luacheck link
mortonfox Sep 13, 2016
cc1c446
added some debug stuff, failing all over...
Tieske Sep 13, 2016
3fc057f
wtf
Tieske Sep 13, 2016
3144e77
fix(globalpatches) randomseed throws error when seeded in wrong context
thibaultcha Sep 10, 2016
19ba990
added patches to make the cli work with co-sockets instead of luasocket
Tieske Sep 14, 2016
3ed9468
fix(oauth2) removing Kong from error message
subnetmarco Sep 14, 2016
934fa86
Merge branch 'master' into next
thibaultcha Sep 14, 2016
e4f0fae
Merge pull request #1613 from Mashape/fix/randomseed-patch
thibaultcha Sep 14, 2016
33c2483
Merge pull request #1633 from Mashape/fix/oauth2-error-message
thibaultcha Sep 14, 2016
4ff3068
chore(ci) better Travis-CI setup_env.sh
thibaultcha Sep 14, 2016
b0fce3e
Merge pull request #1636 from Mashape/chore/ci
thibaultcha Sep 14, 2016
ddc7230
Merge branch 'next' of https://github.com/Mashape/kong into fix/dns2-…
Tieske Sep 15, 2016
e089725
fix Kong starting errors, due to yield across c-boundary error
Tieske Sep 15, 2016
04d1489
fixes the cassandra tests
Tieske Sep 16, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set -e

export BUSTED_ARGS="-o gtest -v --exclude-tags=ci"
export TEST_CMD="KONG_SERF_PATH=$SERF_INSTALL/serf bin/busted $BUSTED_ARGS"
export TEST_CMD="KONG_SERF_PATH=$SERF_PATH bin/busted $BUSTED_ARGS"

if [ "$TEST_SUITE" == "lint" ]; then
make lint
Expand Down
97 changes: 58 additions & 39 deletions .ci/setup_env.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,61 @@
set -e

export OPENRESTY_INSTALL=$CACHE_DIR/openresty
export LUAROCKS_INSTALL=$CACHE_DIR/luarocks
export SERF_INSTALL=$CACHE_DIR/serf
#---------
# Download
#---------
OPENSSL_DOWNLOAD=$DOWNLOAD_CACHE/openssl-$OPENSSL
OPENRESTY_DOWNLOAD=$DOWNLOAD_CACHE/openresty-$OPENRESTY
LUAROCKS_DOWNLOAD=$DOWNLOAD_CACHE/luarocks-$LUAROCKS
SERF_DOWNLOAD=$DOWNLOAD_CACHE/serf-$SERF

mkdir -p $CACHE_DIR
mkdir -p $OPENSSL_DOWNLOAD $OPENRESTY_DOWNLOAD $LUAROCKS_DOWNLOAD $SERF_DOWNLOAD

if [ ! "$(ls -A $CACHE_DIR)" ]; then
# Not in cache
if [ ! "$(ls -A $OPENSSL_DOWNLOAD)" ]; then
pushd $DOWNLOAD_CACHE
curl -L http://www.openssl.org/source/openssl-$OPENSSL.tar.gz | tar xz
popd
fi

if [ ! "$(ls -A $OPENRESTY_DOWNLOAD)" ]; then
pushd $DOWNLOAD_CACHE
curl -L https://openresty.org/download/openresty-$OPENRESTY.tar.gz | tar xz
popd
fi

if [ ! "$(ls -A $LUAROCKS_DOWNLOAD)" ]; then
git clone https://github.com/keplerproject/luarocks.git $LUAROCKS_DOWNLOAD
fi

if [ ! "$(ls -A $SERF_DOWNLOAD)" ]; then
pushd $SERF_DOWNLOAD
wget https://releases.hashicorp.com/serf/${SERF}/serf_${SERF}_linux_amd64.zip
unzip serf_${SERF}_linux_amd64.zip
popd
fi

#--------
# Install
#--------
OPENSSL_INSTALL=$INSTALL_CACHE/openssl-$OPENSSL
OPENRESTY_INSTALL=$INSTALL_CACHE/openresty-$OPENRESTY
LUAROCKS_INSTALL=$INSTALL_CACHE/luarocks-$LUAROCKS
SERF_INSTALL=$INSTALL_CACHE/serf-$SERF

# ---------------
# Install OpenSSL
# ---------------
OPENSSL_BASE=openssl-$OPENSSL
curl -L http://www.openssl.org/source/$OPENSSL_BASE.tar.gz | tar xz
mkdir -p $OPENSSL_INSTALL $OPENRESTY_INSTALL $LUAROCKS_INSTALL $SERF_INSTALL

# -----------------
# Install OpenResty
# -----------------
OPENRESTY_BASE=openresty-$OPENRESTY
mkdir -p $OPENRESTY_INSTALL
curl -L https://openresty.org/download/$OPENRESTY_BASE.tar.gz | tar xz
if [ ! "$(ls -A $OPENSSL_INSTALL)" ]; then
pushd $OPENSSL_DOWNLOAD
./config shared --prefix=$OPENSSL_INSTALL
make
make install
popd
fi

pushd $OPENRESTY_BASE
if [ ! "$(ls -A $OPENRESTY_INSTALL)" ]; then
pushd $OPENRESTY_DOWNLOAD
./configure \
--prefix=$OPENRESTY_INSTALL \
--with-openssl=../$OPENSSL_BASE \
--with-openssl=$OPENSSL_DOWNLOAD \
--with-ipv6 \
--with-pcre-jit \
--with-http_ssl_module \
Expand All @@ -34,17 +64,10 @@ if [ ! "$(ls -A $CACHE_DIR)" ]; then
make
make install
popd
fi

rm -rf $OPENRESTY_BASE

# ----------------
# Install Luarocks
# ----------------
LUAROCKS_BASE=luarocks-$LUAROCKS
mkdir -p $LUAROCKS_INSTALL
git clone https://github.com/keplerproject/luarocks.git $LUAROCKS_BASE

pushd $LUAROCKS_BASE
if [ ! "$(ls -A $LUAROCKS_INSTALL)" ]; then
pushd $LUAROCKS_DOWNLOAD
git checkout v$LUAROCKS
./configure \
--prefix=$LUAROCKS_INSTALL \
Expand All @@ -54,19 +77,15 @@ if [ ! "$(ls -A $CACHE_DIR)" ]; then
make build
make install
popd
fi

rm -rf $LUAROCKS_BASE

# ------------
# Install Serf
# ------------
mkdir -p $SERF_INSTALL
pushd $SERF_INSTALL
wget https://releases.hashicorp.com/serf/${SERF}/serf_${SERF}_linux_amd64.zip
unzip serf_${SERF}_linux_amd64.zip
popd
if [ ! "$(ls -A $SERF_INSTALL)" ]; then
ln -s $SERF_DOWNLOAD/serf $SERF_INSTALL/serf
fi

export OPENSSL_DIR=$OPENSSL_INSTALL # for LuaSec install
export SERF_PATH=$SERF_INSTALL/serf # for our test instance (not in default bin/sh $PATH)

export PATH=$PATH:$OPENRESTY_INSTALL/nginx/sbin:$OPENRESTY_INSTALL/bin:$LUAROCKS_INSTALL/bin:$SERF_INSTALL

eval `luarocks path`
Expand Down
13 changes: 10 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
sudo: false

language: c

compiler:
- gcc

notifications:
email: false

Expand All @@ -15,11 +20,12 @@ addons:
env:
global:
- SERF=0.7.0
- LUAROCKS=2.3.0
- LUAROCKS=2.4.0
- OPENSSL=1.0.2h
- CASSANDRA=2.2.7
- OPENRESTY=1.9.15.1
- $CACHE_DIR=$HOME/cache
- DOWNLOAD_CACHE=$HOME/download-cache
- INSTALL_CACHE=$HOME/install-cache
matrix:
- TEST_SUITE=lint
- TEST_SUITE=unit
Expand All @@ -39,5 +45,6 @@ cache:
apt: true
pip: true
directories:
- $CACHE_DIR
- $DOWNLOAD_CACHE
- $INSTALL_CACHE
- $HOME/.ccm/repository
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ usage of the tests suites and the Makefile.

Finally, a very useful tool in Lua development (as with many other dynamic
languages) is performing static linting of your code. You can use [luacheck]
(installed with `make dev`) for this:
\(installed with `make dev`\) for this:

```
$ make lint
Expand Down
14 changes: 4 additions & 10 deletions bin/busted
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
#!/usr/bin/env resty

-- force LuaSocket usage to resolve `/etc/hosts` until
-- supported by resty-cli.
-- See https://github.com/Mashape/kong/issues/1523
for _, namespace in ipairs({"cassandra", "pgmoon-mashape"}) do
local socket = require(namespace .. ".socket")
socket.force_luasocket(ngx.get_phase(), true)
end
#!/usr/bin/env resty -c 65535

package.path = "?/init.lua;"..package.path

require "kong.core.globalpatches"

if ngx ~= nil then
ngx.exit = function()end
ngx.exit = function() end
end

-- Busted command-line runner
Expand Down
10 changes: 3 additions & 7 deletions bin/kong
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/usr/bin/env resty

-- force LuaSocket usage to resolve `/etc/hosts` until
-- supported by resty-cli.
-- See https://github.com/Mashape/kong/issues/1523
for _, namespace in ipairs({"cassandra", "pgmoon-mashape"}) do
local socket = require(namespace .. ".socket")
socket.force_luasocket(ngx.get_phase(), true)
end
-- require global patches, to enable dns resolution by the internal client
-- initializing the dns client is done in `./kong/conf_loader.lua`
require "kong.core.globalpatches"

require("kong.cmd.init")(arg)
4 changes: 2 additions & 2 deletions kong-0.9.1-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ dependencies = {
"version == 0.2",
"lapis == 1.5.1",
"lua-cassandra == 0.5.3",
"pgmoon-mashape == 2.0.0",
"pgmoon == 1.6.0",
"luatz == 0.3",
"lua_system_constants == 0.1.1",
"lua-resty-iputils == 0.2.1",
"luacrypto == 0.3.2",
"luasyslog == 1.0.0",
"lua_pack == 1.0.4",
"dns == 0.1",
"dns == 0.1.0",
}
build = {
type = "builtin",
Expand Down
10 changes: 5 additions & 5 deletions kong/cmd/start.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ local function execute(args)
local dao = DAOFactory(conf)
local err
xpcall(function()
assert(dao:run_migrations())
assert(prefix_handler.prepare_prefix(conf, args.nginx_conf))
assert(dao:run_migrations())
assert(serf_signals.start(conf, dao))
assert(nginx_signals.start(conf))
log("Kong started")
end, function(e)
log.verbose("could not start Kong, stopping services")
nginx_signals.stop(conf)
serf_signals.stop(conf, dao)
err = e -- cannot throw from this function
log.verbose("stopped services")
end)

if err then
log.verbose("could not start Kong, stopping services")
pcall(nginx_signals.stop(conf))
pcall(serf_signals.stop(conf, dao))
log.verbose("stopped services")
error(err) -- report to main error handler
end
end
Expand Down
4 changes: 4 additions & 0 deletions kong/conf_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ local function load(path, custom_conf)

log.verbose("prefix in use: %s", conf.prefix)

-- initialize the dns client, so the globally patched tcp.connect method
-- will work from here onwards.
assert(require("kong.tools.dns")(conf))

return setmetatable(conf, nil) -- remove Map mt
end

Expand Down
Loading