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/1160 fix clustering #1437

Merged
merged 7 commits into from
Jul 27, 2016
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
3 changes: 3 additions & 0 deletions kong/cmd/utils/serf_signals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ function _M.start(kong_config, dao)
return nil, "could not start Serf: "..err
end

-- cleanup current node from cluster to prevent inconsistency of data
serf:cleanup()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asknaskan can you please check for errors here?

local ok, err = serf:cleanup()
if not ok then return nil, err end


log.verbose("auto-joining Serf cluster...")
local ok, err = serf:autojoin()
if not ok then return nil, err end
Expand Down
4 changes: 3 additions & 1 deletion kong/serf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ function Serf:reachability()
return self:invoke_signal("reachability")
end

function Serf:autojoin()
function Serf:cleanup()
-- Delete current node just in case it was there
-- (due to an inconsistency caused by a crash)
local _, err = self.dao.nodes:delete {name = self.node_name}
if err then return nil, tostring(err) end
end

function Serf:autojoin()
local nodes, err = self.dao.nodes:find_all()
if err then return nil, tostring(err)
elseif #nodes == 0 then
Expand Down