summaryrefslogtreecommitdiff
path: root/trove/db
diff options
context:
space:
mode:
authorPetr Malik <pmalik@tesora.com>2016-10-26 18:01:41 -0400
committerPetr Malik <pmalik@tesora.com>2017-01-19 17:13:43 +0000
commit9bca402ec3f651fb9017c20dc27601a548cc79e1 (patch)
treec3cc547bfc57341aa518d354eaf604de3b56a3b6 /trove/db
parent6e7fa196dcc305e3d7ba324fb6306d5d7f450bc5 (diff)
downloadtrove-9bca402ec3f651fb9017c20dc27601a548cc79e1.tar.gz
Add configuration support for clusters
Implement configuration attach and detach API for clusters. Implement rolling strategy for applying configuration changes (both attach and detach follow the same pattern). 1. Persist the changes on all nodes (leaving nodes in RESTART_REQUIRED state). 2. Update Trove records. 3. Apply changes dynamically via one or all node(s) if possible (and remove RESTART_REQUIRED flag from all nodes). Notes: The single instance implementation has been restructured (similar to above) such that it always leaves the instance in one of the three states: a) Unchanged b) Changes persisted but not applied (Instance has configuration attached but requires restart. It is safe restart manually or detach the group to avoid any changes) c) Changes persisted and applied (if possible) This implemenation should always leave the cluster (and each instance) in a consistent state. Runtime configuration will not be changed until it is first persisted on all nodes. If there is a failure during step 1) the cluster is still running the old configuration. Some instances may have new configuration persisted, but not applied. The cluster will not have configuration attached unless it can be applied to all nodes. The individual nodes will have configuration attached as soon as it is persisted on the guest. It is safe to retry, reapplying the same configuration on a node is noop. It is safe to detach. Removing configuration from nodes without one is a noop. It is safe to detach the configuration from individual nodes via single-instance API. It is safe to attach the configuration to remaining nodes via single-instance API and rerun cluster attach to update Trove records. If 3) fails for whatewer reason the instances are left in RESTART_REQUIRED state. It is safe to retry or detach configuration or restart the instances manually. Also fixed various minor cluster issues. Implements: blueprint cluster-configuration-groups Change-Id: I7c0a22c6a0287128d0c37e100589c78173fd9c1a
Diffstat (limited to 'trove/db')
-rw-r--r--trove/db/sqlalchemy/migrate_repo/versions/042_add_cluster_configuration_id.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/trove/db/sqlalchemy/migrate_repo/versions/042_add_cluster_configuration_id.py b/trove/db/sqlalchemy/migrate_repo/versions/042_add_cluster_configuration_id.py
new file mode 100644
index 00000000..9d4c199f
--- /dev/null
+++ b/trove/db/sqlalchemy/migrate_repo/versions/042_add_cluster_configuration_id.py
@@ -0,0 +1,38 @@
+# Copyright 2016 Tesora, Inc.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from oslo_log import log as logging
+from sqlalchemy import ForeignKey
+from sqlalchemy.schema import Column
+from sqlalchemy.schema import MetaData
+
+from trove.common import cfg
+from trove.db.sqlalchemy.migrate_repo.schema import String
+from trove.db.sqlalchemy.migrate_repo.schema import Table
+
+
+CONF = cfg.CONF
+logger = logging.getLogger('trove.db.sqlalchemy.migrate_repo.schema')
+
+meta = MetaData()
+
+
+def upgrade(migrate_engine):
+ meta.bind = migrate_engine
+ # Load 'configurations' table to MetaData.
+ Table('configurations', meta, autoload=True, autoload_with=migrate_engine)
+ instances = Table('clusters', meta, autoload=True)
+ instances.create_column(Column('configuration_id', String(36),
+ ForeignKey("configurations.id")))