The previous attempt did not update the version in pre commit config
so the old version is still used by pep8 target.
Change-Id: I62048df659f4bc35f714de824aadfe9306e81c71
Change the assertion kind to support all versions of cliff.
The previous related fix 78098e6b18
was only compatible with cliff>3.4.0.
Change-Id: I7ac27919b0d58929b4c975ebb308f33124a6060f
The `test_conf_file_permission_denied` is designed to test
if a config file can't be read due to missing file permissions.
However if we run unit tests with the root user we will beneficiat
from the root privileges and so this test will fails. This can
be reproduced by running `tox` with `sudo`.
These changes propose to skip this test if root privileges are
detected.
Closes-bug: #1983358
Change-Id: Idd124082265032c30f83242b612d002d7093aa61
Since cliff > 3.4.0 we can see mismatch errors with unit tests, this
patch fix this error.
Also this patch fix some issues with deprecation messages.
All these issues needs to be fixed together to unlock our gates.
Closes-bug: #1908934
Change-Id: I8396b4f3ba74a9ea023bff2e3027710f16a74af4
This is because there's no yaml representer for i18n Messages object.
This patch aims to add this representer and allow the generation of
configurations using oslo.i18n strings.
One example of this is cinder.
Closes-bug: #1928582
Change-Id: I70ab87c9bed093cad883b6301b8a09753fc470d9
The ``HostDomain`` config type have been added few months ago [1]
however the config option have been forgotten and this new type
isn't importable.
When we try to import this type without defining a new related cfg
option we get the following issue:
```
AttributeError: module 'oslo_config.cfg' has no attribute 'HostDomain'
```
These changes allow us to import this new type and allow us to use
it in our configs:
```
>>> from oslo_config import cfg
>>> foo = cfg.HostDomain('foo')
>>> foo.type.__call__("1")
...
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "~/oslo.config/oslo_config/types.py", line 893, in __call__
raise ValueError(
ValueError: 1 is not a valid host address
>>> foo.type.__call__("host_name")
'host_name'
```
Also properly initialize HostDomain because The HostDomain class wasn't
calling super in it's __init__() method, which resulted in the type_name not
being set properly for instances of that class.
[1] 6480356928
Change-Id: Ie947803f61ba0ef080018e0447de894a400d7975
Closes-Bug: 1924283
This was documented in the docstring but we had nothing to assert it in
tests. Correct that gap.
Change-Id: I4002e7fe18c43eb5f9ba2eae16022d7da87f790d
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
When troubleshooting, it's often interesting to see the deltas between
the default or sample configs and the running configuration. The
oslo_config.validator is a great tool to integrate this feature across
all projects. It can also be easily captured by data collection tools
like sosreports with the current deployment packages.
Change-Id: I172d82f19a81282093b0d5f7ae4c1817801cd887
Signed-off-by: David Vallee Delisle <dvd@redhat.com>
HostDomain is like HostAddress with the support of
_ character - RFC1033
openstack services are failing to start when a hostname with underscore
_ is provided.
Example:
```
overcloud-novacompute_edge1-0.internalapi.localdomain
overcloud-novacompute_edge1-0.internalapi
```
Nova use `HostAddressOpt` to define `live_migration_inbound_addr`,
and if a hostname with underscore is present in the config file
then the service fail to start.
Example:
```
/etc/nova/nova.conf
live_migration_inbound_addr =
overcloud-novacompute_edge1-0.internalapi.localdomain
```
FQDN is a domain name that specifies its exact
location in the tree hierarchy of the Domain Name System (DNS).
Underscore are allowed by RFC1033 [1][2][3]. Indeed, while a hostname may not
contain other characters, such as the underscore character (_), other
DNS names may contain the underscore.[1][2].
Systems such as DomainKeys and service records use the underscore.
These changes allow us to use underscore with the `HostDomain`.
[1] https://www.ietf.org/rfc/rfc1912.txt
[2] https://www.ietf.org/rfc/rfc1033.txt
[3] http://domainkeys.sourceforge.net/underscore.html
Co-authored-by: Daniel Bengtsson <dbengt@redhat.com>
Change-Id: I0a0670207f96a987996d329e5efa9a5eb2ce000c
Closes-Bug: #1892044
Introduced changes:
- pre-commit config and rules
- Add pre-commit to pep8 gate, Flake8 is covered in the pre-commit hooks.
- Applying fixes for pre-commit compliance in all code.
Also commit hash will be used instead of version tags in pre-commit to
prevend arbitrary code from running in developer's machines.
pre-commit will be used to:
- trailing whitespace;
- Replaces or checks mixed line ending (mixed-line-ending);
- Forbid files which have a UTF-8 byte-order marker (check-byte-order-marker);
- Checks that non-binary executables have a proper
shebang (check-executables-have-shebangs);
- Check for files that contain merge conflict strings (check-merge-conflict);
- Check for debugger imports and py37+ breakpoint()
calls in python source (debug-statements);
- Attempts to load all yaml files to verify syntax (check-yaml);
- Run flake8 checks (flake8) (local)
For further details about tests please refer to:
https://github.com/pre-commit/pre-commit-hooks
Change-Id: I65a40bbff17d92b959764846801d5e0ddd3b97ce
Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
This is necessary to enable parallel builds. As noted in the Sphinx docs
[1], this method has the following function:
Merge in data regarding docnames from a different domaindata inventory
(coming from a subprocess in parallel builds).
Given how simple the datatypes we're storing are, this is pretty easy to
implement.
[1] https://www.sphinx-doc.org/en/master/extdev/domainapi.html#sphinx.domains.Domain.merge_domaindata
Change-Id: I46c7903b159f99c68896a4c3c4d20daef848f9c2
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Closes-Bug: #1895162
This lets us use powerful rST roles and directives in our help text
without these being emitted to the configuration file, where they don't
read quite as well. It also fixes our formatting somewhat, which is
nice.
Note that we're doing something funky where we disable line wrapping. We
can't totally disable this due to how rst2txt works, so instead we set
the line length to an arbitrarily long line length, which is taken from
RFC5322 (Internet Message Format) for want of something better. I
personally question whether anyone is configuring this, but that's a
fight for another day.
Also note that this might caught issues for people who are using invalid
rST in their docstrings or use roles/directives in their config options
that aren't part of the standard Sphinx set or oslo.config set. They
will already be seeing the former issues if they are using the
'sphinxext' extension though, and the latter sounds like it would be
fairly rare.
Change-Id: I6c7208f0facfb4f334d7440cb6a9562901543dd3
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
stevedore has switched to importlib_metadata[1] and
this breaked unit test as the test relied on internal
implementation of it.
Instead we should switch to mock NamedExtensionManager
that's what called by oslo_config.
[1] https://review.opendev.org/#/c/739306/
Closes-Bug: #1888208
Change-Id: Ic4b990a387d875a351c9f8e7eaaef726734ff305
Importing pkg_resources scans all of the installed modules for data
that won't be used. Switch to using importlib.metdata, which more
efficiently loads the metadata for a package.
Change-Id: Idd2a0d0026fef9296172c9995b428ea43a746483
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
These are used when declaring an option with a custom type. There's no
reason they shouldn't be handled and indeed they are albeit with an ugly
warning. Resolve this by making this handling explicit.
Change-Id: Ib7a6f26496cf19777b020c12998e953e9aae4601
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Closes-bug: #1880852
This raises hacking to a newer version, fixes a few issues the newer
version uncovered, and removes the cap for flake8 to allow that version
to be controlled by the hacking constraints.
Change-Id: Ie550119322bca3c217e4a74eca789f156cfa7e2c
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
As discussed in bug 1841038, configuring a StrOpt with a regex parameter
and providing an invalid environment variable will result in an ugly
stacktrace due to an undefined 'alt_loc' variable. Resolve this by
creating said variable.
Change-Id: Id0fb6efdc435a2bd88d5dfea2b4720df453fbfec
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Closes-Bug: #1841038
This adds the return of some metadata to our sphinx extension setup to
indicate they are thread safe. This is needed to allow consuming
projects to do multithreaded docs builds. In some cases, this can save a
noticeable amount of time in job execution.
Change-Id: I53a580b336a49372e27b69d009da555c03f03e35
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This now fails with the newest Sphinx due to multiple entries between
the added reference to the class's docstrings, and the docstrings
themselves. This fixes the warnings by just removing the duplication.
Change-Id: I284a49a5df9506f936ebf1846688339c94d9a6b8
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.
Change-Id: I2f8067eeb2aec62f098bfbb3770a67f1876ce7a2
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This bumps the version of flake8 and pycodestyle to something much
newer, which resolves a long-standing warning about nested sets and
allows us to use new fangled features like f-strings if we so choose.
Note that this requires some minor modifications to keep the 'pep8' task
passing.
Change-Id: I3af8eb490345a6152372730ca3e0a6702bf482ea
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
We don't need this in a Python 3-only world. We can't remove mock yet
since there's an issue with the stdlib variant in python3.6, but that is
called out.
Change-Id: I9657b1fd4409be90d645175a6e177d7e1d2ebac2
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
oslo.config allows us to configure groups and options dynamically. This
can cause a race with our logging as we attempt to iterate through
option groups that are changing under our feet. This wouldn't be a huge
issue, since these are just logs are we can always log again, if needed,
but we store groups in a dictionary and Python doesn't like us changing
the size of a dict it's iterating through:
RuntimeError: dictionary changed size during iteration
Given that we're only reading through this option group and don't need
to worry about a group _disappearing_, the solution is pretty simple:
create a copy of our option group names ahead of time so we don't need
to worry about new ones coming and messing things up.
No tests are included since this is a race and the only way I see to
reproduce this would involve lots of ugly threading.
Change-Id: Id3b28465d645a24f0fcebff2dd68a9bd30e21594
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Closes-Bug: #1856312
"%d" will truncate float and generates wrong format message,
use "format" to handle floats correctly.
Closes-Bug: 1850879
Change-Id: If0dd3933695ac84f0e9cacefd28a9d7a60dd88d7