<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/openstack/nova.git/nova/tests/unit/objects/test_instance_action.py, branch master</title>
<subtitle>opendev.org: openstack/nova.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/'/>
<entry>
<title>Use unittest.mock instead of third party mock</title>
<updated>2022-08-01T15:46:26+00:00</updated>
<author>
<name>Stephen Finucane</name>
<email>stephenfin@redhat.com</email>
</author>
<published>2020-03-24T15:12:07+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=89ef050b8c049b9a6f0e2c70408fc93c826c55e0'/>
<id>89ef050b8c049b9a6f0e2c70408fc93c826c55e0</id>
<content type='text'>
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib. Most of this
is autogenerated, as described below, but there is one manual change
necessary:

nova/tests/functional/regressions/test_bug_1781286.py
  We need to avoid using 'fixtures.MockPatch' since fixtures is using
  'mock' (the library) under the hood and a call to 'mock.patch.stop'
  found in that test will now "stop" mocks from the wrong library. We
  have discussed making this configurable but the option proposed isn't
  that pretty [1] so this is better.

The remainder was auto-generated with the following (hacky) script, with
one or two manual tweaks after the fact:

  import glob

  for path in glob.glob('nova/tests/**/*.py', recursive=True):
      with open(path) as fh:
          lines = fh.readlines()
      if 'import mock\n' not in lines:
          continue
      import_group_found = False
      create_first_party_group = False
      for num, line in enumerate(lines):
          line = line.strip()
          if line.startswith('import ') or line.startswith('from '):
              tokens = line.split()
              for lib in (
                  'ddt', 'six', 'webob', 'fixtures', 'testtools'
                  'neutron', 'cinder', 'ironic', 'keystone', 'oslo',
              ):
                  if lib in tokens[1]:
                      create_first_party_group = True
                      break
              if create_first_party_group:
                  break
              import_group_found = True
          if not import_group_found:
              continue
          if line.startswith('import ') or line.startswith('from '):
              tokens = line.split()
              if tokens[1] &gt; 'unittest':
                  break
              elif tokens[1] == 'unittest' and (
                  len(tokens) == 2 or tokens[4] &gt; 'mock'
              ):
                  break
          elif not line:
              break
      if create_first_party_group:
          lines.insert(num, 'from unittest import mock\n\n')
      else:
          lines.insert(num, 'from unittest import mock\n')
      del lines[lines.index('import mock\n')]
      with open(path, 'w+') as fh:
          fh.writelines(lines)

Note that we cannot remove mock from our requirements files yet due to
importing pypowervm unit test code in nova unit tests. This library
still uses the mock lib, and since we are importing test code and that
lib (correctly) only declares mock in its test-requirements.txt, mock
would not otherwise be installed and would cause errors while loading
nova unit test code.

[1] https://github.com/testing-cabal/fixtures/pull/49

Change-Id: Id5b04cf2f6ca24af8e366d23f15cf0e5cac8e1cc
Signed-off-by: Stephen Finucane &lt;stephenfin@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib. Most of this
is autogenerated, as described below, but there is one manual change
necessary:

nova/tests/functional/regressions/test_bug_1781286.py
  We need to avoid using 'fixtures.MockPatch' since fixtures is using
  'mock' (the library) under the hood and a call to 'mock.patch.stop'
  found in that test will now "stop" mocks from the wrong library. We
  have discussed making this configurable but the option proposed isn't
  that pretty [1] so this is better.

The remainder was auto-generated with the following (hacky) script, with
one or two manual tweaks after the fact:

  import glob

  for path in glob.glob('nova/tests/**/*.py', recursive=True):
      with open(path) as fh:
          lines = fh.readlines()
      if 'import mock\n' not in lines:
          continue
      import_group_found = False
      create_first_party_group = False
      for num, line in enumerate(lines):
          line = line.strip()
          if line.startswith('import ') or line.startswith('from '):
              tokens = line.split()
              for lib in (
                  'ddt', 'six', 'webob', 'fixtures', 'testtools'
                  'neutron', 'cinder', 'ironic', 'keystone', 'oslo',
              ):
                  if lib in tokens[1]:
                      create_first_party_group = True
                      break
              if create_first_party_group:
                  break
              import_group_found = True
          if not import_group_found:
              continue
          if line.startswith('import ') or line.startswith('from '):
              tokens = line.split()
              if tokens[1] &gt; 'unittest':
                  break
              elif tokens[1] == 'unittest' and (
                  len(tokens) == 2 or tokens[4] &gt; 'mock'
              ):
                  break
          elif not line:
              break
      if create_first_party_group:
          lines.insert(num, 'from unittest import mock\n\n')
      else:
          lines.insert(num, 'from unittest import mock\n')
      del lines[lines.index('import mock\n')]
      with open(path, 'w+') as fh:
          fh.writelines(lines)

Note that we cannot remove mock from our requirements files yet due to
importing pypowervm unit test code in nova unit tests. This library
still uses the mock lib, and since we are importing test code and that
lib (correctly) only declares mock in its test-requirements.txt, mock
would not otherwise be installed and would cause errors while loading
nova unit test code.

[1] https://github.com/testing-cabal/fixtures/pull/49

Change-Id: Id5b04cf2f6ca24af8e366d23f15cf0e5cac8e1cc
Signed-off-by: Stephen Finucane &lt;stephenfin@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>db: Unify 'nova.db.api', 'nova.db.sqlalchemy.api'</title>
<updated>2021-08-09T14:34:40+00:00</updated>
<author>
<name>Stephen Finucane</name>
<email>stephenfin@redhat.com</email>
</author>
<published>2021-04-01T16:49:02+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=100b9dc62c0ec9f7b38739837c06646122c818d5'/>
<id>100b9dc62c0ec9f7b38739837c06646122c818d5</id>
<content type='text'>
Merge these, removing an unnecessary layer of abstraction, and place
them in the new 'nova.db.main' directory. The resulting change is huge,
but it's mainly the result of 's/sqlalchemy import api/main import api/'
and 's/nova.db.api/nova.db.main.api/' with some necessary cleanup. We
also need to rework how we do the blocking of API calls since we no
longer have a 'DBAPI' object that we can monkey patch as we were doing
before. This is now done via a global variable that is set by the 'main'
function of 'nova.cmd.compute'.

The main impact of this change is that it's no longer possible to set
'[database] use_db_reconnect' and have all APIs automatically wrapped in
a DB retry. Seeing as this behavior is experimental, isn't applied to
any of the API DB methods (which don't use oslo.db's 'DBAPI' helper),
and is used explicitly in what would appear to be the critical cases
(via the explicit 'oslo_db.api.wrap_db_retry' decorator), this doesn't
seem like a huge loss.

Change-Id: Iad2e4da4546b80a016e477577d23accb2606a6e4
Signed-off-by: Stephen Finucane &lt;stephenfin@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Merge these, removing an unnecessary layer of abstraction, and place
them in the new 'nova.db.main' directory. The resulting change is huge,
but it's mainly the result of 's/sqlalchemy import api/main import api/'
and 's/nova.db.api/nova.db.main.api/' with some necessary cleanup. We
also need to rework how we do the blocking of API calls since we no
longer have a 'DBAPI' object that we can monkey patch as we were doing
before. This is now done via a global variable that is set by the 'main'
function of 'nova.cmd.compute'.

The main impact of this change is that it's no longer possible to set
'[database] use_db_reconnect' and have all APIs automatically wrapped in
a DB retry. Seeing as this behavior is experimental, isn't applied to
any of the API DB methods (which don't use oslo.db's 'DBAPI' helper),
and is used explicitly in what would appear to be the critical cases
(via the explicit 'oslo_db.api.wrap_db_retry' decorator), this doesn't
seem like a huge loss.

Change-Id: Iad2e4da4546b80a016e477577d23accb2606a6e4
Signed-off-by: Stephen Finucane &lt;stephenfin@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove six.text_type (2/2)</title>
<updated>2020-12-13T11:26:35+00:00</updated>
<author>
<name>Takashi Natsume</name>
<email>takanattie@gmail.com</email>
</author>
<published>2020-05-14T15:01:28+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=1cf2431f4bf815fc828a7878bd80f5f5bd8e8319'/>
<id>1cf2431f4bf815fc828a7878bd80f5f5bd8e8319</id>
<content type='text'>
Replace six.text_type with str.
This patch completes six removal.

Change-Id: I779bd1446dc1f070fa5100ccccda7881fa508d79
Implements: blueprint six-removal
Signed-off-by: Takashi Natsume &lt;takanattie@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Replace six.text_type with str.
This patch completes six removal.

Change-Id: I779bd1446dc1f070fa5100ccccda7881fa508d79
Implements: blueprint six-removal
Signed-off-by: Takashi Natsume &lt;takanattie@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Store instance action event exc_val fault details</title>
<updated>2020-03-21T06:08:34+00:00</updated>
<author>
<name>Matt Riedemann</name>
<email>mriedem.os@gmail.com</email>
</author>
<published>2019-11-14T23:27:01+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=a81d27beba2262ef42e63bb281ef61bbbe2dde70'/>
<id>a81d27beba2262ef42e63bb281ef61bbbe2dde70</id>
<content type='text'>
The InstanceActionEvent.pack_action_event_finish method was
not storing the exc_val in a field that was actually part
of the data model so it was never stored ("message" isn't a
column in the instance_actions_events table, "details" is).

This formats and stores the exc_val, if provided, using the
same utility code that is used to record the message for
an instance fault record.

Eventually we can build on this in the os-instance-actions API
by exposing the fault details to the user without needing to
expose the traceback (like the server fault "details" traceback).

Co-Authored-By: Brin Zhang &lt;zhangbailin@inspur.com&gt;

Part of blueprint action-event-fault-details

Change-Id: Ie3e11b38aac251c3f8911ed57dc5e7503aa91301
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The InstanceActionEvent.pack_action_event_finish method was
not storing the exc_val in a field that was actually part
of the data model so it was never stored ("message" isn't a
column in the instance_actions_events table, "details" is).

This formats and stores the exc_val, if provided, using the
same utility code that is used to record the message for
an instance fault record.

Eventually we can build on this in the os-instance-actions API
by exposing the fault details to the user without needing to
expose the traceback (like the server fault "details" traceback).

Co-Authored-By: Brin Zhang &lt;zhangbailin@inspur.com&gt;

Part of blueprint action-event-fault-details

Change-Id: Ie3e11b38aac251c3f8911ed57dc5e7503aa91301
</pre>
</div>
</content>
</entry>
<entry>
<title>Make serialize_args handle exception messages safely</title>
<updated>2020-03-21T06:08:11+00:00</updated>
<author>
<name>Dan Smith</name>
<email>dansmith@redhat.com</email>
</author>
<published>2020-03-12T14:33:24+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=a9346e60333856ceb96acdcdd15a482b6255bb2d'/>
<id>a9346e60333856ceb96acdcdd15a482b6255bb2d</id>
<content type='text'>
We have recently move towards handling exceptions that may be viewed
by API users in a way that results in either the exc.format_message()
text, or just the exception class name (without details) in order to
avoid leaking sensitive information out of the API. This makes the
serialize_args decorator behave that way. Note that because for a
remotable method, serialize_args gets called twice (once on the remote
side before the call and again on the local side at replay), which
means we need to gate that message-or-class-name behavior on whether
or not we are seeing a true Exception object.

Change-Id: I22fb253616443766ef21692735b80faa284fa26d
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We have recently move towards handling exceptions that may be viewed
by API users in a way that results in either the exc.format_message()
text, or just the exception class name (without details) in order to
avoid leaking sensitive information out of the API. This makes the
serialize_args decorator behave that way. Note that because for a
remotable method, serialize_args gets called twice (once on the remote
side before the call and again on the local side at replay), which
means we need to gate that message-or-class-name behavior on whether
or not we are seeing a true Exception object.

Change-Id: I22fb253616443766ef21692735b80faa284fa26d
</pre>
</div>
</content>
</entry>
<entry>
<title>Add InstanceAction/Event create() method</title>
<updated>2019-08-07T21:56:01+00:00</updated>
<author>
<name>Matt Riedemann</name>
<email>mriedem.os@gmail.com</email>
</author>
<published>2018-10-29T20:51:09+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=b92276d4ed68a8da96702dcea059af87e56b5f8c'/>
<id>b92276d4ed68a8da96702dcea059af87e56b5f8c</id>
<content type='text'>
During a cross-cell resize, the instance and its
related records are created in the target cell. Since
the resize is initiated in the source cell, instance
actions and associated events will be created in the
source cell and need to be re-created in the target cell
where the resize completes. Not only that, but we want
to also make sure the history of actions performed on
an instance are copied into the target cell database
in case the resize is confirmed there.

This adds a create() method for the InstanceAction
and InstanceActionEvent objects to allow directly
re-creating those resources from the source cell into
the target cell.

The existing action_start() and event_start() methods
will not work for this scenario since those depend on the
current context but we need to clone actions/events created
with an older/different context.

Part of blueprint cross-cell-resize

Change-Id: I43db251f708c18eb35efe1fdbcdada35ae7e792c
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
During a cross-cell resize, the instance and its
related records are created in the target cell. Since
the resize is initiated in the source cell, instance
actions and associated events will be created in the
source cell and need to be re-created in the target cell
where the resize completes. Not only that, but we want
to also make sure the history of actions performed on
an instance are copied into the target cell database
in case the resize is confirmed there.

This adds a create() method for the InstanceAction
and InstanceActionEvent objects to allow directly
re-creating those resources from the source cell into
the target cell.

The existing action_start() and event_start() methods
will not work for this scenario since those depend on the
current context but we need to clone actions/events created
with an older/different context.

Part of blueprint cross-cell-resize

Change-Id: I43db251f708c18eb35efe1fdbcdada35ae7e792c
</pre>
</div>
</content>
</entry>
<entry>
<title>Use uuidsentinel from oslo.utils</title>
<updated>2018-09-05T14:08:54+00:00</updated>
<author>
<name>Eric Fried</name>
<email>efried@us.ibm.com</email>
</author>
<published>2018-09-05T14:08:54+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=8e1ca5bf34f924b9a23ddbcf31ae727a7dcacb20'/>
<id>8e1ca5bf34f924b9a23ddbcf31ae727a7dcacb20</id>
<content type='text'>
oslo.utils release 3.37.0 [1] introduced uuidsentinel [2]. This change
rips out nova's uuidsentinel and replaces it with the one from
oslo.utils.

[1] https://review.openstack.org/#/c/599754/
[2] https://review.openstack.org/#/c/594179/

Change-Id: I7f5f08691ca3f73073c66c29dddb996fb2c2b266
Depends-On: https://review.openstack.org/600041
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
oslo.utils release 3.37.0 [1] introduced uuidsentinel [2]. This change
rips out nova's uuidsentinel and replaces it with the one from
oslo.utils.

[1] https://review.openstack.org/#/c/599754/
[2] https://review.openstack.org/#/c/594179/

Change-Id: I7f5f08691ca3f73073c66c29dddb996fb2c2b266
Depends-On: https://review.openstack.org/600041
</pre>
</div>
</content>
</entry>
<entry>
<title>Use nova.db.api directly</title>
<updated>2018-07-10T14:56:27+00:00</updated>
<author>
<name>Chris Dent</name>
<email>cdent@anticdent.org</email>
</author>
<published>2018-02-11T21:58:04+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=def4b17934a3b2cf783d0177d6a9632916dfd10f'/>
<id>def4b17934a3b2cf783d0177d6a9632916dfd10f</id>
<content type='text'>
nova/db/__init__.py was importing * from nova.db.api. This meant that
any time any code anywhere within the nova.db package was imported
then nova.db.api was too, leading to a cascade of imports that may
not have been desired. Also, in general, code in __init__.py is a pain.

Therefore, this change adjusts code that so that either:

* nova.db.api is used directly
* nova.db.api is imported as 'db'

In either case, the functionality remains the same.

The primary goal of this change was to make it possible to import the
model files without having to import the db api. Moving the model files
to a different place in the directory hierarchy was considered, but
given that "code in __init__.py is a pain" this mode was chosen.

This looks like a very large change, but it is essentially adjusting
package names, many in mocks.

Change-Id: Ic1fd7c87ceda05eeb96735da2a415ef37060bb1a
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
nova/db/__init__.py was importing * from nova.db.api. This meant that
any time any code anywhere within the nova.db package was imported
then nova.db.api was too, leading to a cascade of imports that may
not have been desired. Also, in general, code in __init__.py is a pain.

Therefore, this change adjusts code that so that either:

* nova.db.api is used directly
* nova.db.api is imported as 'db'

In either case, the functionality remains the same.

The primary goal of this change was to make it possible to import the
model files without having to import the db api. Moving the model files
to a different place in the directory hierarchy was considered, but
given that "code in __init__.py is a pain" this mode was chosen.

This looks like a very large change, but it is essentially adjusting
package names, many in mocks.

Change-Id: Ic1fd7c87ceda05eeb96735da2a415ef37060bb1a
</pre>
</div>
</content>
</entry>
<entry>
<title>Add host field to InstanceActionEvent</title>
<updated>2018-03-23T07:12:37+00:00</updated>
<author>
<name>Yikun Jiang</name>
<email>yikunkero@gmail.com</email>
</author>
<published>2018-03-22T04:11:01+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=32d5a2acc8d1be77779d3f2e19d763f46013ff36'/>
<id>32d5a2acc8d1be77779d3f2e19d763f46013ff36</id>
<content type='text'>
This patch adds the host field and obj_make_compatible with
InstanceActionEvent 1.2 version.

We record the event host info in event start method, and do
NOT record the host again in event finish method, because
it's the same event db record which is looked up by the
existing action(via request id) and event name from the
start event, the host of starting and ending is also same.

This would be used by instance action API to show the
``host`` information of the action event occurs.

Part of blueprint: add-host-to-instance-action-events

Change-Id: I356e7eb6b18837cf868bade7babaed96e5828688
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch adds the host field and obj_make_compatible with
InstanceActionEvent 1.2 version.

We record the event host info in event start method, and do
NOT record the host again in event finish method, because
it's the same event db record which is looked up by the
existing action(via request id) and event name from the
start event, the host of starting and ending is also same.

This would be used by instance action API to show the
``host`` information of the action event occurs.

Part of blueprint: add-host-to-instance-action-events

Change-Id: I356e7eb6b18837cf868bade7babaed96e5828688
</pre>
</div>
</content>
</entry>
<entry>
<title>Add instance action db and obj pagination support.</title>
<updated>2017-12-11T16:01:42+00:00</updated>
<author>
<name>Yikun Jiang</name>
<email>yikunkero@gmail.com</email>
</author>
<published>2017-12-07T14:33:04+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/openstack/nova.git/commit/?id=1950537a53c8dcb4d98cf71708c071eda1d954c2'/>
<id>1950537a53c8dcb4d98cf71708c071eda1d954c2</id>
<content type='text'>
This will be used by instance action pagination API.

Add limit/marker/filters support to get_by_instance_uuid of
InstanceActionList object, also add limit/marker/filters support to
actions_get method of db.

Part of blueprint pagination-add-changes-since-for-instance-action-list

Change-Id: Ic7dd6480a4b250ae6529d94ee0386b5e95b0ca04
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This will be used by instance action pagination API.

Add limit/marker/filters support to get_by_instance_uuid of
InstanceActionList object, also add limit/marker/filters support to
actions_get method of db.

Part of blueprint pagination-add-changes-since-for-instance-action-list

Change-Id: Ic7dd6480a4b250ae6529d94ee0386b5e95b0ca04
</pre>
</div>
</content>
</entry>
</feed>
