Skip to content

Commit

Permalink
chore(renamings) rename config hosts property to contact_points
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultcha committed Aug 31, 2015
1 parent 25a8ce8 commit 0fa2b1c
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ This release contains breaking changes.

### Breaking changes

Several breaking changes are introduced. You will have to slightly change your configuration file and a migration script will take care of updating your database cluster. Please follow the instructions in [UPDATE.md](/UPDATE.md#update-to-kong-050) for an update without downtime.
Several breaking changes are introduced. You will have to slightly change your configuration file and a migration script will take care of updating your database cluster. **Please follow the instructions in [UPDATE.md](/UPDATE.md#update-to-kong-050) for an update without downtime**.

- Many plugins were renamed due to new naming conventions for consistency. [#480](https://github.com/Mashape/kong/issues/480)
- In the configuration file, the Cassandra `hosts` property was renamed to `contact_points`. [#513](https://github.com/Mashape/kong/issues/513)
- `public_dns` and `target_url` properties of APIs were respectively renamed to `inbound_dns` and `upstream_url`. [#513](https://github.com/Mashape/kong/issues/513)
- `plugins_configurations` have been renamed to `plugins`, and their `value` property has been renamed to `config` to avoid confusions. [#513](https://github.com/Mashape/kong/issues/513)
- The database schema has been updated to handle the separation of plugins outside of the core repository.
Expand Down
23 changes: 16 additions & 7 deletions UPDATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Migrating to 0.5.0 can be done **without downtime** by following those instructi
##### 1. Configuration file

You will need to update your configuration file. Replace the `plugins_available` property with:
You will need to update your configuration file. Replace the `plugins_available` values with:

```yaml
plugins_available:
Expand All @@ -32,6 +32,18 @@ plugins_available:
You can still remove plugins you don't use for a lighter Kong.
Also replace the Cassandra `hosts` property with `contact_points`:

```yaml
properties:
contact_points:
- "..."
- "..."
timeout: 1000
keyspace: kong
keepalive: 60000
```

##### 2. Migration script

[This Python script](/scripts/migration.py) will take care of migrating your database schema should you execute the following instructions:
Expand All @@ -48,9 +60,8 @@ $ cd kong/scripts
# Install the Python script dependencies:
$ pip install cassandra-driver pyyaml
# The script will use the first Cassandra contact point
# in your Kong configuration file (the first of the 'hosts' property)
# so make sure it is valid and has the format 'host:port'.
# The script will use the first Cassandra contact point in your Kong configuration file
# (the first of the 'contact_points' property) so make sure it is valid and has the format 'host:port'.
# Run the migration script:
$ python migration.py -c /path/to/kong/config
Expand All @@ -66,8 +77,6 @@ You can now update Kong to 0.5.0. Proceed as a regular update and install the pa
$ kong reload
```

Your cluster should successfully be migrated to Kong `0.5.0`.

##### 4. Purge your Cassandra cluster

Finally, once Kong has restarted in 0.5.0, run the migration script again, with the `--purge` flag:
Expand All @@ -76,7 +85,7 @@ Finally, once Kong has restarted in 0.5.0, run the migration script again, with
$ python migration.py -c /path/to/kong/config --purge
```

Your cluster is now fully migrated to 0.5.0.
Your cluster is now fully migrated to `0.5.0`.

##### Other changes to acknowledge

Expand Down
2 changes: 1 addition & 1 deletion kong.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ database: cassandra
databases_available:
cassandra:
properties:
hosts:
contact_points:
- "localhost:9042"
timeout: 1000
keyspace: kong
Expand Down
2 changes: 1 addition & 1 deletion kong/dao/cassandra/base_dao.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function BaseDao:_open_session(keyspace)

local options = self._factory:get_session_options()

ok, err = session:connect(self._properties.hosts, nil, options)
ok, err = session:connect(self._properties.hosts or self._properties.contact_points, nil, options)
if not ok then
return nil, DaoError(err, error_types.DATABASE)
end
Expand Down
2 changes: 1 addition & 1 deletion kong/dao/cassandra/factory.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function CassandraFactory:execute_queries(queries, no_keyspace)

local options = self:get_session_options()

ok, err = session:connect(self._properties.hosts, nil, options)
ok, err = session:connect(self._properties.hosts or self._properties.contact_points, nil, options)
if not ok then
return DaoError(err, constants.DATABASE_ERROR_TYPES.DATABASE)
end
Expand Down
4 changes: 2 additions & 2 deletions scripts/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
Arguments:
-c, --config path to your Kong configuration file
-p, --purge if already migrated, purge the old values
Flags:
--purge if already migrated, purge the old values
-h print help
'''

Expand Down Expand Up @@ -60,7 +60,7 @@ def load_cassandra_config(kong_config):
"""
cass_properties = kong_config["databases_available"]["cassandra"]["properties"]

host, port = cass_properties["hosts"][0].split(":")
host, port = cass_properties["contact_points"][0].split(":")
keyspace = cass_properties["keyspace"]

return (host, port, keyspace)
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/dao/cassandra/base_dao_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("Cassandra", function()
session = cassandra:new()
session:set_timeout(configuration.cassandra.timeout)

local _, err = session:connect(configuration.cassandra.hosts)
local _, err = session:connect(configuration.cassandra.contact_points)
assert.falsy(err)

local _, err = session:set_keyspace("kong_tests")
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/dao/cassandra/migrations_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe("Migrations", function()
local migrations

setup(function()
local ok, err = session:connect(test_cassandra_properties.hosts, test_cassandra_properties.port)
local ok, err = session:connect(test_cassandra_properties.contact_points, test_cassandra_properties.port)
if not ok then
error(err)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/proxy/database_cache_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Database cache", function()
end)

it("should expire cache after five seconds", function()
local _, status = http_client.get(spec_helper.PROXY_URL.."/get", {}, {host = "cache.test"})
local _ = http_client.get(spec_helper.PROXY_URL.."/get", {}, {host = "cache.test"})

-- Let's add the authentication plugin configuration
local _, err = env.dao_factory.plugins:insert {
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/proxy/realip_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("Real IP", function()
local uuid = utils.random_string()

-- Making the request
local _, status = http_client.get(spec_helper.STUB_GET_URL, nil,
local _ = http_client.get(spec_helper.STUB_GET_URL, nil,
{
host = "realip.com",
["X-Forwarded-For"] = "4.4.4.4, 1.1.1.1, 5.5.5.5",
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/statics_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ database: cassandra
databases_available:
cassandra:
properties:
hosts:
contact_points:
- "localhost:9042"
timeout: 1000
keyspace: kong
Expand Down

0 comments on commit 0fa2b1c

Please sign in to comment.