Skip to content

Option for using qemu internal iscsi driver #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 138 commits into
base: stable/wallaby-m3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
ac86edf
[SAP] implement size expansion when creating volume from template-bas…
imitevm Mar 30, 2018
b8c064f
[SAP] netapp/dataontap: ignore certificate
notandy Jul 25, 2018
947cd24
[SAP] Fix pep8 warnings
fwiesel Sep 6, 2018
5f8f5b5
[SAP] Change the minimal virtual disk capacity to 4MB
joker-at-work Nov 30, 2018
8d4394f
[SAP] Create volume from image with expected size
joker-at-work Jun 27, 2019
c180a8c
[SAP] Remove all NICs from snapshot
joker-at-work Oct 14, 2019
4a21cb6
[SAP] Online resize of cinder volumes (#24)
Scsabiii Nov 13, 2019
d97d831
[SAP] scheduler: Add ShardFilter
joker-at-work Jan 17, 2020
c96a098
[SAP] Backup: send data needed to build an ImportVApp spec
leust Jan 8, 2020
c499b7b
[SAP] Normalize the new backing during terminate_connection
leust Jan 15, 2020
6da64e5
[SAP] fix pep8
joker-at-work Jan 29, 2020
d7f97b6
[SAP] run `tox -e genopts` for "scheduler: Add ShardFilter"
joker-at-work Jan 29, 2020
062c460
[SAP] vmware: Optionally storage-profile on attach
joker-at-work Jan 29, 2020
79663b4
[SAP] scheduler: ShardFilter lets snapshots pass
joker-at-work Feb 10, 2020
0100852
[SAP] scheduler: Allow shard override via hint
joker-at-work Feb 10, 2020
3d74cab
[SAP] Add loci consumed custom requirements
hemna Feb 24, 2020
f1c2b19
[SAP] add reporting of thin provisioning
hemna Feb 24, 2020
e4562bb
[SAP] added some missing custom requirements
hemna Feb 27, 2020
9ca50d6
[SAP] need redis for osprofiler
hemna Feb 27, 2020
dfe89cb
[SAP] Chunkeddriver - no seek (#30)
mariusleu Mar 24, 2020
9069c9b
[SAP] add concourse_unit_test_task
hemna Mar 26, 2020
e43d6a1
[SAP] upgrade pip for concourse_unit_test_task
hemna Mar 27, 2020
e0ecf12
[SAP] fix volume migration for vmware
hemna Mar 30, 2020
0d387ca
[SAP] Fix when migration status is None
hemna Apr 14, 2020
0341cf9
[SAP] fix force detach when connector is None
hemna Apr 14, 2020
01e99ff
[SAP] add cinder host to notify log line
hemna May 6, 2020
bae19ea
[SAP] Added validation for vmware_storage_profile
hemna May 7, 2020
de840f9
[SAP] Improve the deletion of object readers in BackupRestoreHandle (…
mariusleu May 19, 2020
e859ff9
[SAP] Allow a driver to specify additional RPC endpoints
leust Apr 9, 2020
e66d31e
[SAP] implementation of volume migration
leust Apr 9, 2020
cc8329b
[SAP] Reporting location_info
leust Apr 23, 2020
5a1159d
[SAP] Ability to reschedule and migrate volumes upon attachment (#50)
mariusleu Jun 9, 2020
a1d23b0
[SAP] fix - scheduler manager find_backend_for_connector return value
leust Jun 12, 2020
50ae9a7
[SAP] FIX vmware migrations issues (#55)
mariusleu Jun 15, 2020
22cc755
[SAP] Added fix for check_for_setup_error
hemna Jun 19, 2020
14505a4
[SAP] need jaeger-client for osprofiler
chuan137 Aug 6, 2020
a2b2904
[SAP] Randomize the selection of best datastores
hemna Sep 4, 2020
418ca01
[SAP] added openstack-rate-limit-middleware to custom requirements.
galkindmitrii Dec 18, 2020
0527a11
[SAP] fix pep8 checks
leust May 28, 2020
a6d8688
[SAP] fix DB migration scripts
hemna Sep 15, 2020
d615c5d
[SAP] Add db 120_cinder_init.py migration
hemna Sep 25, 2020
170cd23
[SAP] Fix create from snapshot with larger size
hemna Nov 16, 2020
7d61921
[SAP] add sap custom requirements
hemna Jan 28, 2021
5b86d60
[SAP] Add libpq-dev to concourse_unit_test_task
hemna Sep 28, 2020
4b7be4b
[SAP] Fix pep8, missing backup restore feature
hemna Sep 14, 2020
0b63faa
[SAP] Fix more pep8 checks
hemna Sep 11, 2020
44ceecd
[SAP] Handle sharding-enabled in scheduler shard filter
grandchild Jan 6, 2021
81293d6
[SAP] Fix py3 unit tests
hemna Sep 25, 2020
558767c
SAP Rework backup process to make it async
hemna Apr 1, 2021
dda712c
SAP fix the backup_rework unit tests
hemna May 10, 2021
8f950a1
[SAP] Force volume create from backup to restoring
hemna Jul 8, 2021
b342d4e
VmWare: Relocate with Storage IO Profile
fwiesel Aug 2, 2021
b9842b2
Vmware: Create empty backing for live-migration
fwiesel Jul 12, 2021
c86e9cb
[SAP] Also migrate on attachment creation
fwiesel Aug 6, 2021
d011a1c
VmWare: Use WithRetrieval instead of own continue_/cancel_retrieval
fwiesel Aug 3, 2021
19b3058
[SAP] Filter out hosts that are marked buildup
hemna Aug 16, 2021
7c0261c
[SAP] Add vmware extension for migration
hemna Sep 22, 2021
6745ff3
[SAP] Removed the automatic call to migration
hemna Oct 8, 2021
91c25f6
[SAP] Fixed name of migrate_volume method name
hemna Oct 19, 2021
8cd3ac6
[SAP] add support for reporting pools
hemna Mar 11, 2020
6cb40d8
[SAP] Change the API return code for ConnectorRejected
hemna Oct 20, 2021
d4d002e
[SAP] put volume in maintenance mode during migrate
hemna Nov 3, 2021
558651e
[SAP] Update connection_capabilities reporting in stats
hemna Nov 29, 2021
46f9f56
[SAP] ShardFilter passes everything for find_backend_for_connector
joker-at-work Jan 14, 2022
5a7bfeb
[SAP] add SAPLargeVolumeFilter
hemna Jan 21, 2022
501ae69
[SAP] Fix log.debug entry for migrate_by_connector
hemna Jan 25, 2022
c06f761
[SAP] Remove the tracing from _get_datastores_for_profiles
hemna Jan 26, 2022
8ebe3d4
[SAP] Handle reserved status in live-migrations
fwiesel Feb 1, 2022
9fb3b0e
[SAP] Pass cinder_host for live-migrations
fwiesel Feb 1, 2022
22aebc7
Delete attachment on exception in create
fwiesel Feb 2, 2022
0c8e330
[SAP] Fix an issue with SAPLargeVolumeFilter
hemna Feb 3, 2022
0c8dbb4
[SAP] Ensure pools specify thick_provisioning_support enabled
hemna Feb 14, 2022
811422a
[SAP] update size check to Gib units
hemna Feb 24, 2022
d8904b9
Vmware: Remove nvp.vm-uuid extraConfig
fwiesel Mar 4, 2022
9c1a9bf
[SAP] Add any custom attributes to pool stats
hemna Feb 21, 2022
649da0e
[SAP] Account for volumes already provisioned to a host
hemna Feb 24, 2022
c0d4df2
[SAP] Added sap_affinity_filter.py
hemna Mar 24, 2022
66aba1c
[SAP] Fixes to better account for allocated_capacity_gb
hemna Apr 1, 2022
8ac2252
[SAP] Rework Capacitty filter
hemna Mar 11, 2022
fa5ef9a
[SAP] Replace CapacityFilter
hemna Mar 15, 2022
3c5938b
[SAP] Update allocated_capacity on remote host
hemna May 4, 2022
80d7774
[SAP] Trap negative values for allocated_capacity_gb
hemna May 12, 2022
faf5ab7
[vmware] Allow pulling images from Swift
leust May 10, 2022
d0417c6
[SAP] ensure affinty/antiaffinity is maintained at migration time
hemna Apr 21, 2022
4459b66
[SAP] Fix migration by connector filter_properties
hemna Jun 8, 2022
11f4c77
[SAP] fix the metadata for affinity/anti-affinity
hemna Jun 13, 2022
7de8f44
[SAP] Fix for allocated_capacity_gb not being updated
hemna Jun 20, 2022
a9414f3
[SAP] Added pool_state tracking. Updated backend_state
hemna Jul 1, 2022
a3b61c6
[SAP] update the new remote host allocated_capacity_gb
hemna Jul 6, 2022
5603647
[SAP] Add attached volume migration for vmware
Scsabiii Mar 10, 2022
c61e268
[SAP] prevent cross host/shard migration
hemna Jul 11, 2022
dcf8784
[SAP] Add option to disable incremental backup
hemna Jul 21, 2022
df23464
Migrate the volume if resize can't happen on current host
leust Jul 17, 2022
3d367d8
[SAP] Fix misnamed StorageMigrationFailed call
hemna Aug 30, 2022
8da1f61
[SAP] Add new recount_host_stats API
hemna Aug 17, 2022
8231100
[SAP] Add ability to disable updating provider_info
hemna Sep 22, 2022
08423f6
[SAP] Fix multiattach reporting for vmdk
hemna Sep 22, 2022
924ca0e
[SAP] Fix rpc call to remote host to update host capacity
hemna Sep 23, 2022
b92b133
SAP propagate scheduler hints for volumes
hemna Sep 19, 2022
9c64a17
[SAP] Mark a pool as down if overcommited
hemna Sep 7, 2022
ca8bdd4
[SAP] Mark datastore down if it has specific alert
hemna Aug 16, 2022
0835fa4
[SAP] change overcommit log to info
hemna Sep 30, 2022
932756e
[SAP] fix default max_oversubscription_ratio to float
hemna Oct 3, 2022
116a90c
[SAP] fix default max_oversubscription_ratio to float
hemna Oct 3, 2022
83e52cc
[SAP] Add context to the volume-stats tooz lock
hemna Oct 5, 2022
67bb4ba
[SAP] vmware: Add helper to fetch properties for given objects
joker-at-work Oct 6, 2022
7273960
[SAP] Optimize vCenter queries in filter_hosts()
joker-at-work Oct 6, 2022
68c6726
[SAP] catch TemplateNotFoundException during delete
hemna Oct 11, 2022
e926af6
update custom-requirements to wallaby-m3
leust Oct 24, 2022
bcff80f
fix concourse_unit_test_task for wallaby
leust Oct 24, 2022
58fe616
remove oslo-vmware and os-brick from requirements.txt
leust Oct 24, 2022
56b9029
fix pep8 and unit for wallaby
leust Nov 1, 2022
00253a4
[SAP] Update requirements.txt to include memcached for tooz
hemna Nov 2, 2022
846ffd6
Merge pull request #152 from sapcc/memcached
hemna Nov 2, 2022
e7c761b
[SAP] set the correct vmdk_size when restoring backups
leust Oct 31, 2022
861b2a1
[SAP] Fix the shard filter for group creation
hemna Nov 3, 2022
539df99
Merge pull request #154 from sapcc/correct_vmdk_size
hemna Nov 4, 2022
31fb035
Merge pull request #155 from sapcc/shard_filter
hemna Nov 4, 2022
c6f18d4
Allow snapshots to be independent
hemna Nov 17, 2022
da60e86
Merge pull request #158 from sapcc/wallaby_independent_snapshots
hemna Dec 5, 2022
1957259
Allow independent cloning of volumes
hemna Dec 6, 2022
28a34d2
SAPCC: don't log in method called by eventlet.tpool.execute()
Carthaca Dec 14, 2022
1060975
Mark pool as down if datastore draining
hemna Jan 5, 2023
c69af86
[SAP] drop existing SAP constraint
hemna Jan 25, 2023
92dfac2
Merge pull request #162 from sapcc/fix_constraint
hemna Jan 26, 2023
21d021b
Fix setting the restore handle size
hemna Feb 9, 2023
8e8665e
Merge pull request #164 from sapcc/restore_size_fix
hemna Feb 15, 2023
f738943
[SAP] Fix logging formats
hemna Feb 28, 2023
ceabe4b
Merge pull request #167 from sapcc/sap_fix_logging
hemna Feb 28, 2023
41928d6
[SAP]Get ready for tox 4
hemna Feb 28, 2023
d235272
Merge pull request #168 from sapcc/sap_fix_tox
hemna Mar 3, 2023
95dc3ba
[SAP] Update shard filter to filter only on vmware
hemna Feb 23, 2023
a3d083c
[SAP] Fix vmdk stats reporting
hemna Mar 16, 2023
b6e6452
Merge pull request #170 from sapcc/fix_stats
hemna Mar 16, 2023
9aab279
Merge pull request #166 from sapcc/vmware_sharding_only
hemna Mar 16, 2023
09da7b3
[SAP] Add action_track to format specific logs for easier debugging
hemna Feb 1, 2023
4cca7e4
Merge pull request #163 from sapcc/walt-trace
hemna Apr 28, 2023
f4feba9
Option for using qemu internal iscsi driver
fwiesel Apr 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 200 additions & 0 deletions cinder/action_track.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
# Copyright 2023 Openstack Foundation.
# 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.

import abc
import inspect
import traceback

import decorator
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import excutils

from cinder import context as cinder_context


CONF = cfg.CONF
LOG = logging.getLogger(__name__)

ACTION_VOLUME_CREATE = "volume_create"
ACTION_VOLUME_DELETE = "volume_delete"
ACTION_VOLUME_RESERVE = "volume_reserve"
ACTION_VOLUME_ATTACH = "volume_attach"
ACTION_VOLUME_EXTEND = "volume_extend"
ACTION_VOLUME_DETACH = "volume_detach"
ACTION_VOLUME_MIGRATE = "volume_migrate"
ACTION_VOLUME_RETYPE = "volume_retype"
ACTION_VOLUME_BACKUP = "volume_backup"
ACTION_BACKUP_RESTORE = "volume_restore"
ACTION_VOLUME_BACKUP_DELETE = "volume_backup_delete"
ACTION_VOLUME_COPY_TO_IMAGE = "volume_copy_to_image"
ACTION_VOLUME_BACKUP_RESET_STATUS = "volume_backup_reset_status"
ACTION_SNAPSHOT_CREATE = "snapshot_create"
ACTION_SNAPSHOT_DELETE = "snapshot_delete"


VALID_RESOURCE_NAMES = [
'volume', 'backup', 'snapshot'
]
VALID_CONTEXT_NAMES = [
'context', 'ctxt'
]

log_level_map = {
logging.CRITICAL: LOG.error,
logging.ERROR: LOG.error,
logging.WARNING: LOG.warning,
logging.INFO: LOG.info,
logging.DEBUG: LOG.debug,
}


class ActionTrack(object, metaclass=abc.ABCMeta):
"""Base class for the 'trace' api.

The purpose of this trace facility is to be able to
keep track of critical parts of operations against resources.
This will create a standardized object/log entry for troubleshooting
actions against resources.

This is not for performance tracing, but for action/operation tracking.
by default it will simply format a log entry such that the entries are
easy to find with a standard format and information.
"""

@staticmethod
@abc.abstractmethod
def track(context, action, resource, message, loglevel=logging.INFO):
pass

@staticmethod
@abc.abstractmethod
def track_with_file_info(context, action, resource, message,
filename, line_number, function,
loglevel=logging.INFO):
pass


class LogActionTrack(ActionTrack):
@staticmethod
def _track_with_info(context, action, resource, message,
filename, line_number, function,
loglevel=logging.INFO):
entry = f"ACTION:'{action}' "
if loglevel == logging.ERROR or loglevel == logging.CRITICAL:
# The action failed and this trace is the reason
entry += "FAILED "

msg = message.replace("\n", "")

entry += (
f"MSG:'{msg}' "
f"FILE:{filename}:{line_number}:{function} "
f"RSC:{resource} "
)
log_func = log_level_map[loglevel]
log_func(entry, resource=resource)

@staticmethod
def track(context, action, resource, message, loglevel=logging.INFO):
# Do not call this directly. Call action_track.track() instead.

# We only want the frame of the caller
# we should always be called from the trace() method in this module
# not called directly in this static method
info = list(traceback.walk_stack(None))[1][0]
LogActionTrack._track_with_info(context, action, resource, message,
info.f_code.co_filename,
info.f_lineno,
info.f_code.co_name,
loglevel=loglevel)

@staticmethod
def track_with_file_info(context, action, resource, message,
filename, line_number, function,
loglevel=logging.INFO):
# Do not call this directly.
# Call action_track.track_with_file_info() instead.
LogActionTrack._track_with_info(
context, action, resource, message,
filename, line_number, function, loglevel=loglevel
)


def track(context, action, resource, message, loglevel=logging.INFO):
"""For now we only implement LogActionTrack.

TODO(waboring): add rabbitmq trace? to send entries to a msg queue
or add: DBtrace to send traces to the DB instead?
"""
LogActionTrack.track(context, action, resource, message,
loglevel=loglevel)


def track_with_info(context, action, resource, message, file, line_number,
function, loglevel=logging.INFO):
"""For now we only implement LogActionTrack.

TODO(waboring): add rabbitmq trace? to send entries to a msg queue
or add: DBtrace to send traces to the DB instead?
"""
LogActionTrack.track_with_file_info(context, action, resource, message,
file, line_number, function,
loglevel=loglevel)


def track_decorator(action):
"""Decorator to automatically handle exceptions raised as failures.

Place this decorator on a function that you want to mark as an
action failure and the action_track tracing will get called
for the action.

@track_decorator(action_track.ACTION_VOLUME_ATTACH)
def initialize_connection(....)
If initialize_connection raises an exception then you will get a
action_track.track called with action of ACTION_VOLUME_ATTACH
and a failure.

"""
@decorator.decorator
def inner(func, *args, **kwargs):
# Find the context and the volume/backup object
resource = None
context = None
call_args = inspect.getcallargs(func, *args, **kwargs)
for key in call_args:
if key in VALID_RESOURCE_NAMES:
resource = call_args[key]
elif (key in VALID_CONTEXT_NAMES and
isinstance(call_args[key], cinder_context.RequestContext)):
context = call_args[key]

track(context, action, resource, "called")

try:
return func(*args, **kwargs)
except Exception:
with excutils.save_and_reraise_exception() as exc:
# We only want the frame of the caller
tl = traceback.extract_tb(exc.tb)
i = tl[1]
message = str(exc.value)
track_with_info(
context, action, resource, message,
i.filename, i.lineno, i.name,
loglevel=logging.ERROR
)
return inner
2 changes: 2 additions & 0 deletions cinder/api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@

METADATA_TYPES = enum.Enum('METADATA_TYPES', 'user image')

SAP_HIDDEN_METADATA_KEY = "__cinder_internal"


def get_pagination_params(params, max_limit=None):
"""Return marker, limit, offset tuple from request.
Expand Down
11 changes: 11 additions & 0 deletions cinder/api/contrib/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ def _failover(self, req, context, clustered, body):
cluster_name, body.get('backend_id'))
return webob.Response(status_int=HTTPStatus.ACCEPTED)

@validation.schema(os_services.recount_host_stats)
def _recount_host_stats(self, req, context, body):
"""Ask the volume manager to recount allocated capacity for host."""
cluster_name, host = common.get_cluster_host(req, body,
mv.REPLICATION_CLUSTER)
self._volume_api_proxy(self.volume_api.recount_host_stats, context,
host)
return webob.Response(status_int=HTTPStatus.ACCEPTED)

def _log_params_binaries_services(self, context, body):
"""Get binaries and services referred by given log set/get request."""
query_filters = {'is_up': True}
Expand Down Expand Up @@ -273,6 +282,8 @@ def update(self, req, id, body):
return self._set_log(req, context, body=body)
elif support_dynamic_log and id == 'get-log':
return self._get_log(req, context, body=body)
elif id == "recount_host_stats":
return self._recount_host_stats(req, context, body=body)
else:
raise exception.InvalidInput(reason=_("Unknown action"))

Expand Down
74 changes: 74 additions & 0 deletions cinder/api/contrib/vmware_migrate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright (c) 2021 SAP Corporation
# 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.

"""The Migrate by connector API."""


from oslo_log import log as logging
from oslo_utils import strutils
from six.moves import http_client

from cinder.api.contrib import admin_actions
from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.api.schemas import vmware_extension_actions as vmware_actions
from cinder.api import validation


LOG = logging.getLogger(__name__)


class VMWareVolumeExtensionsController(admin_actions.VolumeAdminController):

collection = 'volumes'

@wsgi.response(http_client.ACCEPTED)
@wsgi.action('os-migrate_volume_by_connector')
@validation.schema(vmware_actions.migrate_volume_by_connector)
def _migrate_volume_by_connector(self, req, id, body):
"""Migrate a volume based on connector.

This is an SAP VMWare extension that requires
the connector of the vmware vcenter to be provided.
The connector will contain the correct vcenter uuid
so that the scheduler can find the right cinder backend
to migrate the volume.
"""
context = req.environ['cinder.context']
# Not found exception will be handled at the wsgi level
volume = self._get(context, id)
self.authorize(context, 'migrate_volume', target_obj=volume)
params = body['os-migrate_volume_by_connector']
connector = params.get('connector', {})
lock_volume = strutils.bool_from_string(
params.get('lock_volume', False),
strict=True)

self.volume_api.migrate_volume_by_connector(
context, volume, connector, lock_volume)


class Vmware_migrate(extensions.ExtensionDescriptor):
"""Enable admin actions."""

name = "Vmware_migrate"
alias = "os-vmware-admin-actions"
updated = "2021-09-25T00:00:00+00:00"

def get_controller_extensions(self):
controller = VMWareVolumeExtensionsController()
extension = extensions.ControllerExtension(
self, controller.collection, controller)
return [extension]
35 changes: 35 additions & 0 deletions cinder/api/contrib/volume_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
# License for the specific language governing permissions and limitations
# under the License.
from http import HTTPStatus
import logging

from castellan import key_manager
from oslo_config import cfg
import oslo_messaging as messaging
from oslo_utils import strutils
import webob

from cinder import action_track
from cinder.api import extensions
from cinder.api import microversions as mv
from cinder.api.openstack import wsgi
Expand Down Expand Up @@ -77,11 +79,20 @@ def _attach(self, req, id, body):
msg = _("Error attaching volume - %(err_type)s: "
"%(err_msg)s") % {
'err_type': error.exc_type, 'err_msg': error.value}
action_track.track(
context, action_track.ACTION_VOLUME_ATTACH,
volume, msg, loglevel=logging.ERROR
)
raise webob.exc.HTTPBadRequest(explanation=msg)
else:
# There are also few cases where attach call could fail due to
# db or volume driver errors. These errors shouldn't be exposed
# to the user and in such cases it should raise 500 error.
action_track.track(
context, action_track.ACTION_VOLUME_ATTACH,
volume, f"Attach failed because {error}",
loglevel=logging.ERROR
)
raise

@wsgi.response(HTTPStatus.ACCEPTED)
Expand Down Expand Up @@ -159,16 +170,40 @@ def _initialize_connection(self, req, id, body):
volume = self.volume_api.get(context, id)
connector = body['os-initialize_connection']['connector']
try:
action_track.track(
context, action_track.ACTION_VOLUME_ATTACH,
volume, "Call initialize_connection",
)
info = self.volume_api.initialize_connection(context,
volume,
connector)
except exception.InvalidInput as err:
action_track.track(
context, action_track.ACTION_VOLUME_ATTACH,
volume, "Invalid Input", loglevel=logging.ERROR
)
raise webob.exc.HTTPBadRequest(
explanation=err.msg)
except exception.ConnectorRejected:
msg = _("Volume needs to be migrated before attaching to this "
"instance")
action_track.track(
context, action_track.ACTION_VOLUME_ATTACH,
volume, msg
)
raise webob.exc.HTTPNotAcceptable(explanation=msg)
except exception.VolumeBackendAPIException:
msg = _("Unable to fetch connection information from backend.")
action_track.track(
context, action_track.ACTION_VOLUME_ATTACH,
volume, msg, loglevel=logging.ERROR
)
raise webob.exc.HTTPInternalServerError(explanation=msg)
except messaging.RemoteError as error:
action_track.track(
context, action_track.ACTION_VOLUME_ATTACH,
volume, f"Failed because {error}", loglevel=logging.ERROR
)
if error.exc_type == 'InvalidInput':
raise exception.InvalidInput(reason=error.value)
raise
Expand Down
Loading