summaryrefslogtreecommitdiff
path: root/trove/cluster
diff options
context:
space:
mode:
authorPetr Malik <pmalik@tesora.com>2016-11-01 17:44:55 -0400
committerPetr Malik <pmalik@tesora.com>2017-01-13 11:41:09 -0500
commit6e7fa196dcc305e3d7ba324fb6306d5d7f450bc5 (patch)
tree871bbfd1ac628d72e64038a78f40ff05d47ce20b /trove/cluster
parent6a917bab58e987f7fabde5b31d0bb055b89ffc61 (diff)
downloadtrove-6e7fa196dcc305e3d7ba324fb6306d5d7f450bc5.tar.gz
Add support for cluster restart
Implement cluster rolling restart strategy. Add support for Cassandra and PXC. Add some missing cluster upgrade infrastructure. Implements: blueprint cluster-restart Co-Authored-By: Petr Malik <pmalik@tesora.com> Co-Authored-By: Peter Stachowski <peter@tesora.com> Change-Id: I21e654a8dd2dc6a74aa095604f78db4e96c70d64
Diffstat (limited to 'trove/cluster')
-rw-r--r--trove/cluster/models.py47
-rw-r--r--trove/cluster/tasks.py4
2 files changed, 48 insertions, 3 deletions
diff --git a/trove/cluster/models.py b/trove/cluster/models.py
index 82ed5fa5..69a80f06 100644
--- a/trove/cluster/models.py
+++ b/trove/cluster/models.py
@@ -21,8 +21,9 @@ from trove.cluster.tasks import ClusterTasks
from trove.common import cfg
from trove.common import exception
from trove.common.i18n import _
-from trove.common.notification import DBaaSClusterGrow, DBaaSClusterShrink
-from trove.common.notification import DBaaSClusterResetStatus
+from trove.common.notification import (DBaaSClusterGrow, DBaaSClusterShrink,
+ DBaaSClusterResetStatus,
+ DBaaSClusterRestart)
from trove.common.notification import DBaaSClusterUpgrade
from trove.common.notification import StartNotification
from trove.common import remote
@@ -316,6 +317,11 @@ class Cluster(object):
with StartNotification(context, cluster_id=self.id):
return self.reset_status()
+ elif action == 'restart':
+ context.notification = DBaaSClusterRestart(context, request=req)
+ with StartNotification(context, cluster_id=self.id):
+ return self.restart()
+
elif action == 'upgrade':
context.notification = DBaaSClusterUpgrade(context, request=req)
dv_id = param['datastore_version']
@@ -332,8 +338,43 @@ class Cluster(object):
def shrink(self, instance_ids):
raise exception.BadRequest(_("Action 'shrink' not supported"))
+ def rolling_restart(self):
+ self.validate_cluster_available()
+ self.db_info.update(task_status=ClusterTasks.RESTARTING_CLUSTER)
+ try:
+ cluster_id = self.db_info.id
+ task_api.load(self.context, self.ds_version.manager
+ ).restart_cluster(cluster_id)
+ except Exception:
+ self.db_info.update(task_status=ClusterTasks.NONE)
+ raise
+
+ return self.__class__(self.context, self.db_info,
+ self.ds, self.ds_version)
+
+ def rolling_upgrade(self, datastore_version):
+ """Upgrades a cluster to a new datastore version."""
+ LOG.debug("Upgrading cluster %s." % self.id)
+
+ self.validate_cluster_available()
+ self.db_info.update(task_status=ClusterTasks.UPGRADING_CLUSTER)
+ try:
+ cluster_id = self.db_info.id
+ ds_ver_id = datastore_version.id
+ task_api.load(self.context, self.ds_version.manager
+ ).upgrade_cluster(cluster_id, ds_ver_id)
+ except Exception:
+ self.db_info.update(task_status=ClusterTasks.NONE)
+ raise
+
+ return self.__class__(self.context, self.db_info,
+ self.ds, self.ds_version)
+
+ def restart(self):
+ raise exception.BadRequest(_("Action 'restart' not supported"))
+
def upgrade(self, datastore_version):
- raise exception.BadRequest(_("Action 'upgrade' not supported"))
+ raise exception.BadRequest(_("Action 'upgrade' not supported"))
@staticmethod
def load_instance(context, cluster_id, instance_id):
diff --git a/trove/cluster/tasks.py b/trove/cluster/tasks.py
index b91fc1a5..44d6d301 100644
--- a/trove/cluster/tasks.py
+++ b/trove/cluster/tasks.py
@@ -69,6 +69,10 @@ class ClusterTasks(object):
0x05, 'GROWING_CLUSTER', 'Increasing the size of the cluster.')
SHRINKING_CLUSTER = ClusterTask(
0x06, 'SHRINKING_CLUSTER', 'Decreasing the size of the cluster.')
+ UPGRADING_CLUSTER = ClusterTask(
+ 0x07, 'UPGRADING_CLUSTER', 'Upgrading the cluster to new version.')
+ RESTARTING_CLUSTER = ClusterTask(
+ 0x08, 'RESTARTING_CLUSTER', 'Restarting the cluster.')
# Dissuade further additions at run-time.