<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/openstack/nova.git/nova/hacking, branch master</title>
<subtitle>opendev.org: openstack/nova.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/'/>
<entry>
<title>Add a hacking rule for the setDaemon method</title>
<updated>2022-11-14T13:04:05+00:00</updated>
<author>
<name>Takashi Natsume</name>
<email>takanattie@gmail.com</email>
</author>
<published>2022-08-25T15:53:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=628e1c152cc7c5e89d5261fc6f25ec72ac24c1df'/>
<id>628e1c152cc7c5e89d5261fc6f25ec72ac24c1df</id>
<content type='text'>
Add the following hacking rule.

* N372: Don't use the setDaemon method.
        Use the daemon attribute instead.

Change-Id: Idb45421205f76d2d3b0576bd0504d261ed249edd
Related-Bug: 1987191
Signed-off-by: Takashi Natsume &lt;takanattie@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add the following hacking rule.

* N372: Don't use the setDaemon method.
        Use the daemon attribute instead.

Change-Id: Idb45421205f76d2d3b0576bd0504d261ed249edd
Related-Bug: 1987191
Signed-off-by: Takashi Natsume &lt;takanattie@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>hacking: force explicit import of python's mock</title>
<updated>2022-08-02T13:31:19+00:00</updated>
<author>
<name>Eric Fried</name>
<email>openstack@fried.cc</email>
</author>
<published>2020-02-20T00:07:23+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=c36782a96a96ecfc35f8af750c29741c769ed515'/>
<id>c36782a96a96ecfc35f8af750c29741c769ed515</id>
<content type='text'>
Since we dropped support for python 2 [1], we no longer need to use the
mock library, which existed to backport py3 functionality into py2.
Change Ib44b5bff657c8e76c4f701e14d51a4efda3f6d32 cut over to importing
the stock mock, which must be done by saying::

    from unittest import mock

...because if you say::

    import mock

...you will be using the third party mock library instead, which may or
may not be installed.

This commit adds hacking check N371 to enforce the former.

[1] https://review.opendev.org/#/c/687954/

Change-Id: I71439580e80d33cff62aba807df2b35164a47cbe
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since we dropped support for python 2 [1], we no longer need to use the
mock library, which existed to backport py3 functionality into py2.
Change Ib44b5bff657c8e76c4f701e14d51a4efda3f6d32 cut over to importing
the stock mock, which must be done by saying::

    from unittest import mock

...because if you say::

    import mock

...you will be using the third party mock library instead, which may or
may not be installed.

This commit adds hacking check N371 to enforce the former.

[1] https://review.opendev.org/#/c/687954/

Change-Id: I71439580e80d33cff62aba807df2b35164a47cbe
</pre>
</div>
</content>
</entry>
<entry>
<title>hacking: Prevent use of six</title>
<updated>2022-04-05T11:59:12+00:00</updated>
<author>
<name>Stephen Finucane</name>
<email>stephenfin@redhat.com</email>
</author>
<published>2022-04-05T10:24:49+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=b082d06cbccd06bd49d9aa2a35ea922190e42cc5'/>
<id>b082d06cbccd06bd49d9aa2a35ea922190e42cc5</id>
<content type='text'>
Spotted this in a review recently. We don't want people using six
anymore.

Change-Id: Ie107a95bc06390ab519d3b3af9b07103a9a14316
Signed-off-by: Stephen Finucane &lt;stephenfin@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Spotted this in a review recently. We don't want people using six
anymore.

Change-Id: Ie107a95bc06390ab519d3b3af9b07103a9a14316
Signed-off-by: Stephen Finucane &lt;stephenfin@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Add wrapper for oslo.concurrency lockutils.ReaderWriterLock()</title>
<updated>2022-01-12T04:15:26+00:00</updated>
<author>
<name>melanie witt</name>
<email>melwittt@gmail.com</email>
</author>
<published>2022-01-12T04:09:29+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=887c445a7a6a17b92a37b6ed1dcdcc7dd009f65d'/>
<id>887c445a7a6a17b92a37b6ed1dcdcc7dd009f65d</id>
<content type='text'>
This is a follow up change to I168fffac8002f274a905cfd53ac4f6c9abe18803
which added a hackaround to enable our tests to pass with
fasteners&gt;=0.15 which was upgraded recently as part of a
openstack/requirements update.

The ReaderWriterLock from fasteners (and thus lockutils) cannot work
correctly with eventlet patched code, so this adds a wrapper containing
the aforementioned hackaround along with a hacking check to do our best
to ensure that future use of ReaderWriterLock will be through the
wrapper.

Change-Id: Ia7bcb40a21a804c7bc6b74f501d95ce2a88b09b5
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is a follow up change to I168fffac8002f274a905cfd53ac4f6c9abe18803
which added a hackaround to enable our tests to pass with
fasteners&gt;=0.15 which was upgraded recently as part of a
openstack/requirements update.

The ReaderWriterLock from fasteners (and thus lockutils) cannot work
correctly with eventlet patched code, so this adds a wrapper containing
the aforementioned hackaround along with a hacking check to do our best
to ensure that future use of ReaderWriterLock will be through the
wrapper.

Change-Id: Ia7bcb40a21a804c7bc6b74f501d95ce2a88b09b5
</pre>
</div>
</content>
</entry>
<entry>
<title>Add two new hacking rules</title>
<updated>2021-09-01T11:26:52+00:00</updated>
<author>
<name>Balazs Gibizer</name>
<email>balazs.gibizer@est.tech</email>
</author>
<published>2021-08-23T17:23:31+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=9f8cc2f03827c10f89ee652bc73790b3c58111d3'/>
<id>9f8cc2f03827c10f89ee652bc73790b3c58111d3</id>
<content type='text'>
As the bug and fix If71620e808744736cb4fe3abda76d81a6335311b showed
it is dangerous to forget instantiating the Mock class before it is
used in the test as changes on the class directly leaks out from the
test. In almost all the cases using Mock class directly is a bug and the
author original intention is to use an instance instead, just forgot
about the parents. So this patch adds two new hacking rules:

N367: catches the case when Mock class is aliased in the test:
    self.mock_mystuff = mock.Mock

N368: catches when mock.patch instructed to use the Mock class as
replacement value during patching:
    mock.patch('Bar.foo', new=mock.Mock)

For N367 the previous patch removed the last hit. For N368 this patch
removes the two hits exists.

Change-Id: Id42ca571b1569886ef47aa350369e9d2068e77bc
Related-Bug: #1936849
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As the bug and fix If71620e808744736cb4fe3abda76d81a6335311b showed
it is dangerous to forget instantiating the Mock class before it is
used in the test as changes on the class directly leaks out from the
test. In almost all the cases using Mock class directly is a bug and the
author original intention is to use an instance instead, just forgot
about the parents. So this patch adds two new hacking rules:

N367: catches the case when Mock class is aliased in the test:
    self.mock_mystuff = mock.Mock

N368: catches when mock.patch instructed to use the Mock class as
replacement value during patching:
    mock.patch('Bar.foo', new=mock.Mock)

For N367 the previous patch removed the last hit. For N368 this patch
removes the two hits exists.

Change-Id: Id42ca571b1569886ef47aa350369e9d2068e77bc
Related-Bug: #1936849
</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://git.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>Add a hacking rule for assert_has_calls</title>
<updated>2020-09-28T14:08:15+00:00</updated>
<author>
<name>Takashi Natsume</name>
<email>takanattie@gmail.com</email>
</author>
<published>2020-09-28T13:35:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=8d3c2ce92bcaf8cf777bf29fd46275572da61547'/>
<id>8d3c2ce92bcaf8cf777bf29fd46275572da61547</id>
<content type='text'>
Add the following hacking rule.

* N366: The assert_has_calls is a method rather than a variable.

  Not correct: mock_method.assert_has_calls = [mock.call(0)]
  Correct:     mock_method.assert_has_calls([mock.call(0)])

This patch is a follow-up patch for
Id094dd90efde09b9a835d4492f4a92b8f8ad296e.

Change-Id: I892f8c23ee44f2b3518776a9705e3543f3115cae
Signed-off-by: Takashi Natsume &lt;takanattie@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add the following hacking rule.

* N366: The assert_has_calls is a method rather than a variable.

  Not correct: mock_method.assert_has_calls = [mock.call(0)]
  Correct:     mock_method.assert_has_calls([mock.call(0)])

This patch is a follow-up patch for
Id094dd90efde09b9a835d4492f4a92b8f8ad296e.

Change-Id: I892f8c23ee44f2b3518776a9705e3543f3115cae
Signed-off-by: Takashi Natsume &lt;takanattie@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>hacking: Stop special casing 'plugins.xenserver'</title>
<updated>2020-08-31T14:51:29+00:00</updated>
<author>
<name>Stephen Finucane</name>
<email>stephenfin@redhat.com</email>
</author>
<published>2020-08-31T14:48:54+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=31b2fd114c741b241a4f567d0962e82c5034d7e4'/>
<id>31b2fd114c741b241a4f567d0962e82c5034d7e4</id>
<content type='text'>
This module was removed in I1b64ea1f5906b0c4dd1d5e311095cfe41e884ff7 and
no longer needs to be worried about.

Change-Id: I6cb74210934f71bb77ad775ea6671b4e2792f8c0
Signed-off-by: Stephen Finucane &lt;stephenfin@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This module was removed in I1b64ea1f5906b0c4dd1d5e311095cfe41e884ff7 and
no longer needs to be worried about.

Change-Id: I6cb74210934f71bb77ad775ea6671b4e2792f8c0
Signed-off-by: Stephen Finucane &lt;stephenfin@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove hacking rules for python 2/3 compatibility</title>
<updated>2020-06-17T08:19:13+00:00</updated>
<author>
<name>Takashi Natsume</name>
<email>takanattie@gmail.com</email>
</author>
<published>2020-06-07T11:59:30+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=9dca0d186f834c38d0d06e226b18ab3ae717c140'/>
<id>9dca0d186f834c38d0d06e226b18ab3ae717c140</id>
<content type='text'>
The Python 2.7 Support has been dropped since Ussuri.
So remove hacking rules for compatibility between python 2 and 3.

- [N325] str() and unicode() cannot be used on an exception.
         Remove or use six.text_type()
- [N327] Do not use xrange(). xrange() is not compatible with Python 3.
         Use range() or six.moves.range() instead.
- [N344] Python 3: do not use dict.iteritems.
- [N345] Python 3: do not use dict.iterkeys.
- [N346] Python 3: do not use dict.itervalues.

See also line 414 in https://etherpad.opendev.org/p/nova-victoria-ptg

Change-Id: If4335b2e8ef5bbabba37598110c1aa8269635c2f
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>
The Python 2.7 Support has been dropped since Ussuri.
So remove hacking rules for compatibility between python 2 and 3.

- [N325] str() and unicode() cannot be used on an exception.
         Remove or use six.text_type()
- [N327] Do not use xrange(). xrange() is not compatible with Python 3.
         Use range() or six.moves.range() instead.
- [N344] Python 3: do not use dict.iteritems.
- [N345] Python 3: do not use dict.iterkeys.
- [N346] Python 3: do not use dict.itervalues.

See also line 414 in https://etherpad.opendev.org/p/nova-victoria-ptg

Change-Id: If4335b2e8ef5bbabba37598110c1aa8269635c2f
Implements: blueprint six-removal
Signed-off-by: Takashi Natsume &lt;takanattie@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>hacking: Modify checks for translated logs</title>
<updated>2020-05-27T09:41:30+00:00</updated>
<author>
<name>Stephen Finucane</name>
<email>stephenfin@redhat.com</email>
</author>
<published>2020-05-18T16:09:25+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/openstack/nova.git/commit/?id=45a88f08b4e881f0fc0039dc56c0223139850c64'/>
<id>45a88f08b4e881f0fc0039dc56c0223139850c64</id>
<content type='text'>
The N319 check previously asserted that debug-level logs were not
translated. Now that we've removed all log translations, we can
generalize this to all logs. We reuse the same number since these
numbers are really just metadata and not public contracts.

This also allows us to update the N323 and N326 checks, which ensure we
import the translation function, '_', wherever it's used and don't
concatenate translated and non-translated strings. Since we're no longer
translating logs and the '_LE', '_LW' and '_LI' symbols are no longer
provided, we don't need to consider logs in either of these cases.

Change-Id: I64d139ad660bc382e8b9d7c8cd03352b26aadafd
Signed-off-by: Stephen Finucane &lt;stephenfin@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The N319 check previously asserted that debug-level logs were not
translated. Now that we've removed all log translations, we can
generalize this to all logs. We reuse the same number since these
numbers are really just metadata and not public contracts.

This also allows us to update the N323 and N326 checks, which ensure we
import the translation function, '_', wherever it's used and don't
concatenate translated and non-translated strings. Since we're no longer
translating logs and the '_LE', '_LW' and '_LI' symbols are no longer
provided, we don't need to consider logs in either of these cases.

Change-Id: I64d139ad660bc382e8b9d7c8cd03352b26aadafd
Signed-off-by: Stephen Finucane &lt;stephenfin@redhat.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
