diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e07dced2d3..53c573d7d01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/UPDATE.md b/UPDATE.md index 0892716862e..29c213e2baf 100644 --- a/UPDATE.md +++ b/UPDATE.md @@ -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: @@ -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: @@ -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 @@ -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: @@ -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 diff --git a/kong.yml b/kong.yml index daabc5cf5ec..2516312a100 100644 --- a/kong.yml +++ b/kong.yml @@ -36,7 +36,7 @@ database: cassandra databases_available: cassandra: properties: - hosts: + contact_points: - "localhost:9042" timeout: 1000 keyspace: kong diff --git a/kong/dao/cassandra/base_dao.lua b/kong/dao/cassandra/base_dao.lua index 59bbec6c047..19cf55ba217 100644 --- a/kong/dao/cassandra/base_dao.lua +++ b/kong/dao/cassandra/base_dao.lua @@ -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 diff --git a/kong/dao/cassandra/factory.lua b/kong/dao/cassandra/factory.lua index 13cde324507..933c3a00a91 100644 --- a/kong/dao/cassandra/factory.lua +++ b/kong/dao/cassandra/factory.lua @@ -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 diff --git a/scripts/migration.py b/scripts/migration.py index 5dc8b4349af..96054332a0e 100755 --- a/scripts/migration.py +++ b/scripts/migration.py @@ -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 ''' @@ -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) diff --git a/spec/integration/dao/cassandra/base_dao_spec.lua b/spec/integration/dao/cassandra/base_dao_spec.lua index 306d48d95de..0a0b3390f0d 100644 --- a/spec/integration/dao/cassandra/base_dao_spec.lua +++ b/spec/integration/dao/cassandra/base_dao_spec.lua @@ -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") diff --git a/spec/integration/dao/cassandra/migrations_spec.lua b/spec/integration/dao/cassandra/migrations_spec.lua index 56fb2002d07..d91278ac8eb 100644 --- a/spec/integration/dao/cassandra/migrations_spec.lua +++ b/spec/integration/dao/cassandra/migrations_spec.lua @@ -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 diff --git a/spec/integration/proxy/database_cache_spec.lua b/spec/integration/proxy/database_cache_spec.lua index a9a6e1e0366..95224f13311 100644 --- a/spec/integration/proxy/database_cache_spec.lua +++ b/spec/integration/proxy/database_cache_spec.lua @@ -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 { diff --git a/spec/integration/proxy/realip_spec.lua b/spec/integration/proxy/realip_spec.lua index 9fb3a8495b2..11ff3eef858 100644 --- a/spec/integration/proxy/realip_spec.lua +++ b/spec/integration/proxy/realip_spec.lua @@ -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", diff --git a/spec/unit/statics_spec.lua b/spec/unit/statics_spec.lua index f52e3c85100..b3581fb845f 100644 --- a/spec/unit/statics_spec.lua +++ b/spec/unit/statics_spec.lua @@ -78,7 +78,7 @@ database: cassandra databases_available: cassandra: properties: - hosts: + contact_points: - "localhost:9042" timeout: 1000 keyspace: kong