summaryrefslogtreecommitdiff
path: root/ironic/db/sqlalchemy
diff options
context:
space:
mode:
authorDmitry Tantsur <dtantsur@protonmail.com>2020-09-07 18:50:53 +0200
committerDmitry Tantsur <dtantsur@protonmail.com>2020-09-22 15:39:36 +0200
commitd8dccc8d06017e79f2b49afec069a18b3c7413fc (patch)
tree7b1301027f3ea4c257bf25bfe7f3916fe53ab601 /ironic/db/sqlalchemy
parented0ef6cf59b9d85096b4e897667524a6cdd5da4c (diff)
downloadironic-d8dccc8d06017e79f2b49afec069a18b3c7413fc.tar.gz
Deprecate the iscsi deploy interface
This change marks the iscsi deploy interface as deprecated and stops enabling it by default. An online data migration is provided for iscsi->direct, provided that: 1) the direct deploy is enabled, 2) image_download_source!=swift. The CI coverage for iscsi deploy is left only on standalone jobs. Story: #2008114 Task: #40830 Change-Id: I4a66401b24c49c705861e0745867b7fc706a7509
Diffstat (limited to 'ironic/db/sqlalchemy')
-rw-r--r--ironic/db/sqlalchemy/api.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/ironic/db/sqlalchemy/api.py b/ironic/db/sqlalchemy/api.py
index 374898bdb..3e859226c 100644
--- a/ironic/db/sqlalchemy/api.py
+++ b/ironic/db/sqlalchemy/api.py
@@ -1527,6 +1527,53 @@ class Connection(api.Connection):
return total_to_migrate, total_migrated
+ @oslo_db_api.retry_on_deadlock
+ def migrate_from_iscsi_deploy(self, context, max_count, force=False):
+ """Tries to migrate away from the iscsi deploy interface.
+
+ :param context: the admin context
+ :param max_count: The maximum number of objects to migrate. Must be
+ >= 0. If zero, all the objects will be migrated.
+ :returns: A 2-tuple, 1. the total number of objects that need to be
+ migrated (at the beginning of this call) and 2. the number
+ of migrated objects.
+ """
+ # TODO(dtantsur): maybe change to force=True by default in W?
+ if not force:
+ if 'direct' not in CONF.enabled_deploy_interfaces:
+ LOG.warning('The direct deploy interface is not enabled, will '
+ 'not migrate nodes to it. Run with --option '
+ 'force=true to override.')
+ return 0, 0
+
+ if CONF.agent.image_download_source == 'swift':
+ LOG.warning('The direct deploy interface is using swift, will '
+ 'not migrate nodes to it. Run with --option '
+ 'force=true to override.')
+ return 0, 0
+
+ total_to_migrate = (model_query(models.Node)
+ .filter_by(deploy_interface='iscsi')
+ .count())
+ if not total_to_migrate:
+ return 0, 0
+
+ max_to_migrate = max_count or total_to_migrate
+
+ with _session_for_write():
+ query = (model_query(models.Node.id)
+ .filter_by(deploy_interface='iscsi')
+ .slice(0, max_to_migrate))
+ ids = [row[0] for row in query]
+
+ num_migrated = (model_query(models.Node)
+ .filter_by(deploy_interface='iscsi')
+ .filter(models.Node.id.in_(ids))
+ .update({'deploy_interface': 'direct'},
+ synchronize_session=False))
+
+ return total_to_migrate, num_migrated
+
@staticmethod
def _verify_max_traits_per_node(node_id, num_traits):
"""Verify that an operation would not exceed the per-node trait limit.