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(config) error when specifying port for cassandra #2263

Merged
merged 1 commit into from
Mar 28, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions kong/conf_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,18 @@ local function check_and_infer(conf)
"DCAwareRoundRobin policy is in use"
end

for _, contact_point in ipairs(conf.cassandra_contact_points) do
local endpoint, err = utils.normalize_ip(contact_point)
if not endpoint then
errors[#errors+1] = "bad cassandra contact point '" .. contact_point ..
Copy link
Member

Choose a reason for hiding this comment

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

The two error messages inconsistently capitalize "cassandra". Ideally, both should be lowercase.

"': " .. err

elseif endpoint.port then
errors[#errors+1] = "bad cassandra contact point '" .. contact_point ..
"': port must be specified in cassandra_port"
end
end

if conf.ssl then
if conf.ssl_cert and not conf.ssl_cert_key then
errors[#errors+1] = "ssl_cert_key must be specified"
Expand Down
14 changes: 14 additions & 0 deletions spec/01-unit/02-conf_loader_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,20 @@ describe("Configuration loader", function()
assert.is_nil(err)
assert.is_table(conf)
end)
it("errors when hosts have a bad format in cassandra_contact_points", function()
local conf, err = conf_loader(nil, {
cassandra_contact_points = [[some/really\bad/host\name,addr2]]
})
assert.equal([[bad cassandra contact point 'some/really\bad/host\name': invalid hostname: some/really\bad/host\name]], err)
assert.is_nil(conf)
end)
it("errors when specifying a port in cassandra_contact_points", function()
local conf, err = conf_loader(nil, {
cassandra_contact_points = "addr1:9042,addr2"
})
assert.equal("bad cassandra contact point 'addr1:9042': port must be specified in cassandra_port", err)
assert.is_nil(conf)
end)
it("cluster_ttl_on_failure cannot be lower than 60 seconds", function()
local conf, err = conf_loader(nil, {
cluster_ttl_on_failure = 40
Expand Down