Skip to content

Commit

Permalink
Merge pull request Kong#1917 from Mashape/release/0.9.7
Browse files Browse the repository at this point in the history
release(0.9.7)
  • Loading branch information
subnetmarco authored Dec 22, 2016
2 parents 96bb336 + cc5ce0d commit 8e628cd
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 13 deletions.
23 changes: 22 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
## [Unreleased][unreleased]

## [0.9.7] - 2016/12/21

### Fixed

- Fixed a performance issue in Cassandra by removing an old workaround that was
forcing Cassandra to use LuaSocket instead of cosockets.
[#1916](https://github.com/Mashape/kong/pull/1916)
- Fixed an issue that was causing a recursive attempt to stop Kong's services
when an error was occurring.
[#1877](https://github.com/Mashape/kong/pull/1877)
- Custom plugins are now properly loaded again.
[#1910](https://github.com/Mashape/kong/pull/1910)
- Plugins:
- Galileo: properly encode empty arrays.
[#1909](https://github.com/Mashape/kong/pull/1909)
- OAuth 2: implements a missing Postgres migration for `redirect_uri` in
every OAuth 2 credential. [#1911](https://github.com/Mashape/kong/pull/1911)
- OAuth 2: safely parse the request body even when no data has been sent.
[#1915](https://github.com/Mashape/kong/pull/1915)

## [0.9.6] - 2016/11/29

### Fixed
Expand Down Expand Up @@ -792,7 +812,8 @@ First version running with Cassandra.
- CLI `bin/kong` script.
- Database migrations (using `db.lua`).

[unreleased]: https://github.com/mashape/kong/compare/0.9.6...next
[unreleased]: https://github.com/mashape/kong/compare/0.9.7...next
[0.9.7]: https://github.com/mashape/kong/compare/0.9.6...0.9.7
[0.9.6]: https://github.com/mashape/kong/compare/0.9.5...0.9.6
[0.9.5]: https://github.com/mashape/kong/compare/0.9.4...0.9.5
[0.9.4]: https://github.com/mashape/kong/compare/0.9.3...0.9.4
Expand Down
2 changes: 2 additions & 0 deletions bin/busted
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env resty

require("kong.core.globalpatches")({cli = true})

-- force LuaSocket usage to resolve `/etc/hosts` until
-- supported by resty-cli.
-- See https://github.com/Mashape/kong/issues/1523
Expand Down
4 changes: 1 addition & 3 deletions bin/kong
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env resty

-- a flag to detect whether our modules (especially kong.core.globalpatches)
-- are running under resty-cli or in a real ngx_lua, runtime environment.
ngx.RESTY_CLI = true
require("kong.core.globalpatches")({cli = true})

-- force LuaSocket usage to resolve `/etc/hosts` until
-- supported by resty-cli.
Expand Down
4 changes: 2 additions & 2 deletions kong-0.9.6-0.rockspec → kong-0.9.7-0.rockspec
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package = "kong"
version = "0.9.6-0"
version = "0.9.7-0"
supported_platforms = {"linux", "macosx"}
source = {
url = "git://github.com/Mashape/kong",
tag = "0.9.6"
tag = "0.9.7"
}
description = {
summary = "Kong is a scalable and customizable API Management Layer built on top of Nginx.",
Expand Down
121 changes: 115 additions & 6 deletions kong/core/globalpatches.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ return function(opts)
if not seed then
if not opts.cli and ngx.get_phase() ~= "init_worker" then
ngx.log(ngx.WARN, "math.randomseed() must be called in init_worker ",
"context\n", debug.traceback('', 2)) -- nil [message] arg doesn't work with level
"context\n", debug.traceback('', 2)) -- nil [message] arg doesn't work with level
end

local bytes, err = util.get_rand_bytes(8)
Expand All @@ -44,14 +44,14 @@ return function(opts)
seed = tonumber(str)
else
ngx.log(ngx.ERR, "could not seed from OpenSSL RAND_bytes, seeding ",
"PRNG with time and worker pid instead (this can ",
"result to duplicated seeds): ", err)
"PRNG with time and worker pid instead (this can ",
"result to duplicated seeds): ", err)

seed = ngx.now()*1000 + ngx.worker.pid()
end

ngx.log(ngx.DEBUG, "random seed: ", seed, " for worker nb ",
ngx.worker.id())
ngx.worker.id())

if not opts.cli then
local ok, err = ngx.shared.kong:safe_set("pid: " .. ngx.worker.pid(), seed)
Expand All @@ -63,11 +63,120 @@ return function(opts)
randomseed(seed)
else
ngx.log(ngx.DEBUG, "attempt to seed random number generator, but ",
"already seeded with: ", seed, "\n",
debug.traceback('', 2)) -- nil [message] arg doesn't work with level
"already seeded with: ", seed, "\n",
debug.traceback('', 2)) -- nil [message] arg doesn't work with level
end

return seed
end
end

if opts.cli then
-- ngx.shared.DICT proxy
-- https://github.com/bsm/fakengx/blob/master/fakengx.lua
-- with minor fixes and addtions such as exptime
--
-- See https://github.com/openresty/resty-cli/pull/12
-- for a definitive solution ot using shms in CLI
local SharedDict = {}
local function set(data, key, value)
data[key] = {
value = value,
info = {expired = false}
}
end
function SharedDict:new()
return setmetatable({data = {}}, {__index = self})
end
function SharedDict:get(key)
return self.data[key] and self.data[key].value, nil
end
function SharedDict:set(key, value)
set(self.data, key, value)
return true, nil, false
end
SharedDict.safe_set = SharedDict.set
function SharedDict:add(key, value, exptime)
if self.data[key] ~= nil then
return false, "exists", false
end

if exptime then
ngx.timer.at(exptime, function()
self.data[key] = nil
end)
end

set(self.data, key, value)
return true, nil, false
end
function SharedDict:replace(key, value)
if self.data[key] == nil then
return false, "not found", false
end
set(self.data, key, value)
return true, nil, false
end
function SharedDict:delete(key)
if self.data[key] ~= nil then
self.data[key] = nil
end
return true
end
function SharedDict:incr(key, value)
if not self.data[key] then
return nil, "not found"
elseif type(self.data[key].value) ~= "number" then
return nil, "not a number"
end
self.data[key].value = self.data[key].value + value
return self.data[key].value, nil
end
function SharedDict:flush_all()
for _, item in pairs(self.data) do
item.info.expired = true
end
end
function SharedDict:flush_expired(n)
local data = self.data
local flushed = 0

for key, item in pairs(self.data) do
if item.info.expired then
data[key] = nil
flushed = flushed + 1
if n and flushed == n then
break
end
end
end
self.data = data
return flushed
end
function SharedDict:get_keys(n)
n = n or 1024
local i = 0
local keys = {}
for k in pairs(self.data) do
keys[#keys+1] = k
i = i + 1
if n ~= 0 and i == n then
break
end
end
return keys
end

-- hack
_G.ngx.shared = setmetatable({}, {
__index = function(self, key)
local shm = rawget(self, key)
if not shm then
shm = SharedDict:new()
rawset(self, key, SharedDict:new())
end
return shm
end
})
end
end
2 changes: 1 addition & 1 deletion kong/meta.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local version = setmetatable({
major = 0,
minor = 9,
patch = 6,
patch = 7,
pre_release = nil
}, {
__tostring = function(t)
Expand Down

0 comments on commit 8e628cd

Please sign in to comment.