Commit Graph

22 Commits

Author SHA1 Message Date
Sean Mooney f3d48000b1 Add autopep8 to tox and pre-commit
autopep8 is a code formating tool that makes python code pep8
compliant without changing everything. Unlike black it will
not radically change all code and the primary change to the
existing codebase is adding a new line after class level doc strings.

This change adds a new tox autopep8 env to manually run it on your
code before you submit a patch, it also adds autopep8 to pre-commit
so if you use pre-commit it will do it for you automatically.

This change runs autopep8 in diff mode with --exit-code in the pep8
tox env so it will fail if autopep8 would modify your code if run
in in-place mode. This allows use to gate on autopep8 not modifying
patches that are submited. This will ensure authorship of patches is
maintianed.

The intent of this change is to save the large amount of time we spend
on ensuring style guidlines are followed automatically to make it
simpler for both new and old contibutors to work on nova and save
time and effort for all involved.

Change-Id: Idd618d634cc70ae8d58fab32f322e75bfabefb9d
2021-11-08 12:37:27 +00:00
Stephen Finucane d565e7a092 trivial: Remove remaining '_LI' instances
Once again, do what we did for '_LE' and '_LW' and remove the final
remnants of the log translation effort.

Change-Id: Id6cf7a9bfbe69d6d3e65303e62403d1db9188a84
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2020-05-18 17:00:57 +01:00
Stephen Finucane 43dd054685 filters: Stop handling cells v1
Part of blueprint remove-cells-v1

Change-Id: Ie8c934b131df75ad275226d357b8ce5cb9453738
2019-06-12 16:09:46 +01:00
Sylvain Bauza aeae7040c7 Prepare filters for using RequestSpec object
Now that the FilterScheduler is using a RequestSpec object,
we need to change the filters for backporting the object
into the legacy dicts before changing each of them.

Release Notes will be updated to mention that custom filters
need to be modified to either use a RequestSpec object or
primitive them into a dict.

Partially-Implements: blueprint request-spec-object-mitaka

UpgradeImpact - see the reno file attached.

Change-Id: I14f18c4507498b1d24a9318fafc97193861ca0b6
2015-11-16 22:41:02 +01:00
Sylvain Bauza 09673a0377 Remove reservation_id from the logs when a schedule fails
As discussed, reservation_id is a compatible layer for EC2 and thus is persisted,
but there are no filters which are using it. Since there are very little benefits
of giving it to the operator (because the operator can find a request by other ways)
and since it would mean we should persist that too in the RequestSpec object,
we prefer to remove that from the log information exposed to the operator.

Change-Id: Ie8f050a1b3653fe1a6d901b3e4020158d63b9b8a
Partially-Implements: blueprint request-spec-object-mitaka
2015-10-30 17:45:42 -07:00
EdLeafe 0f67836de2 Add logging when filtering returns nothing.
When hosts are filtered for a request, and no host passes all the
filters, operators can only see the last filter run; they have no
visibility into which filter removed which host. This attempts to
improve this situation by tracking the hosts remaining after each
filter is run and the number of hosts removed. If no host is left, to
log that information along with the reservation ID and instance UUID
of the request. Since that can be a lot of information, it will call
LOG.info with just the counts for all but the final filter, which
will contain the last deleted host names; LOG.debug will output the
full record of each filter and the hosts remaining after each step.
This will better enable operators to determine why a particular host
was not selected.

Change-Id: I6173274a03bd8712eb4d63c7a998bb02abdecf4b
Blueprint: no-valid-host-reporting
2015-08-17 16:16:00 +00:00
EdLeafe 7fb641c831 Remove use of builtin name
Change the use of the name 'filter' to 'filter_' so that it doesn't
conflict with the builtin function 'filter'.

Change-Id: Iaa18aa54fbd8578c3b0d3313540393541c002720
Closes-Bug:  #1459826
2015-05-28 16:23:49 -05:00
Davanum Srinivas 97d63d8745 Use oslo.log
Convert the use of the incubated version of the log module
to the new oslo.log library.

Sync oslo-incubator modules to update their imports as well.

Co-Authored-By: Doug Hellmann <doug@doughellmann.com>
Change-Id: Ic4932e3f58191869c30bd07a010a6e9fdcb2a12c
2015-02-22 07:56:40 -05:00
Hans Lindgren c126d36640 Make scheduler filters/weighers only load once
Right now, filters/weighers are instantiated on every invocation of the
scheduler. This is both time consuming and unnecessary. In cases where
a filter/weigher tries to be smart and store/cache something in between
invocations this actually prohibits that.

This change make base filter/weigher functions take objects instead of
classes and then let schedulers create objects only once and then reuse
them.

This fixes a known bug in trusted_filter that tries to cache things.

Related to blueprint scheduler-optimization

Change-Id: I3174ab7968b51c43c0711033bac5d4bc30938b95
Closes-Bug: #1223450
2014-12-09 18:58:49 +01:00
Mike Durnosvistov 5ec332c197 Replacement `_` on `_LI` in all LOG.info - part 2
oslo.i18n uses different marker functions to separate the
translatable messages into different catalogs, which the translation
teams can prioritize translating. For details, please refer to:
http://docs.openstack.org/developer/oslo.i18n/guidelines.html#guidelines-for-use-in-openstack

There were not marker fuctions some places in directory network.
This commit makes changes:
* Add missing marker functions
* Use ',' instead of '%' while adding variables to log messages

Change-Id: Iaebb239ef20a0da3df1e3552baf26f412d0fcdc0
2014-11-20 10:28:46 +02:00
Davanum Srinivas 826aed0ec7 Use oslo.i18n
oslo.i18n provides the i18n functions that were provided by
oslo-incubator's gettextutils module. Some tests that were
using internal details of the library were removed.

Change-Id: I44cfd5552e0dd86af21073419d31622f5fdb28e0
2014-07-18 14:28:09 -04:00
Gary Kotton 4dcf093236 Don't translate debug level logs in nova
Our translation policy
(https://wiki.openstack.org/wiki/LoggingStandards#Log_Translation) calls
for not translating debug level logs. This is to help prioritize log
translation. Furthermore translation has a performance overhead, even if
the log isn't used (since nova doesn't support lazy translation yet).

This is the final patch ensuring that all fines in the nova directory
no longer have translations for debug messages.

Change-Id: Ib10f5826e2238cbb2d4315c48be570eb31b2ea55
2014-06-13 01:07:48 -07:00
Jenkins e85a00f2a4 Merge "Fixes typos in the files in the nova folder" 2013-10-14 09:34:14 +00:00
Shuangtai Tian b1099b5b07 Log which filter failed when on log level INFO
If log level is set to INFO,only see a log message about nova-schedule
attempting to build n instances then a log message about setting the
state to error when the scheduler fails to schedule an instance due to
a filter returning 0 hosts.It may be useful to see which filterreturns 0
host for operator.

Close-bug: #1226334

Change-Id: I7564a8ab093895d1f9db357009aac294783a808b
2013-10-10 11:27:04 +08:00
Alex Glikson f16f41b1f2 Fixes typos in the files in the nova folder
blueprint fix-nova-typos

Change-Id: I0971b98999381183c0c77fff1d569180606e338b
2013-10-07 23:40:01 +02:00
Alex Gaynor cd9d8e45c6 Remove the monkey patching of _ into the builtins
Previous _ was monkey patched into builtins whenever
certain modules were imported. This removes that and
simply imports it when it is needed.

Change-Id: I0af2c6d8a230e94440d655d13cab9107ac20d13c
2013-07-26 07:31:17 -07:00
Phil Day 4a03071db2 Allow filters to only run once per request if their data is static
Currently the filter_all() method of each scheduler filter is run
once for each instance in a request, but for many filters the data
doesn't change during a request.

For example the data used by the AZ filter is pretty static, and
doesn't filter any more hosts on successive runs.  However it is
fairly expensive to run on a large system.

Similarly the ServiceGroup information used by the compute filter
is cached as part of the host status, and doesn't need to be
evaluated more than once per request.

Only filters that are based on data that may change within a
request, for example resource consumption, need to be evaluated
for each instance.

This blueprint introduces a new attribute that allows filters to
declare that they only need to be run once per request. The default
behaviour is left so that a filter is evaluated once for each
instance in a request.

The following existing filters are changed to only evaluate once
per request:

  AggregateInstanceExtraSpecsFilter
  AggregateMultiTenancyIsolation
  AggregateTypeAffinityFilter
  AllHostsFilter
  AvailabilityZoneFilter
  ComputeCapabilitiesFilter
  ComputeFilter
  DifferentHostFilter
  GroupAntiAffinityFilter
  ImagePropertiesFilter
  IsolatedHostsFilter
  SameHostFilter
  SimpleCIDRAffinityFilter

In addition the function that does the check is defined in the
filter base class in a way that a filter that wants to run
(for example) once for every 10 instances in a request could
overload the function and implement its own behaviour.

Implements: bp once-per-request-filters
Fixes: bug 1189557

Change-Id: Ia668f16414da86441323c58b1bbef5f88c81b90c
2013-07-08 13:04:48 +00:00
Yang Yu d6d8ba7bc9 Avoiding multiple code loops in filter scheduler
The code snippet can not provide the original target. In the
filters module, there is one line code will never be invoked
because of the code logic, so I modified it.

Fixes: bug 1186945
Change-Id: I3f2a662c28ab466b178268cae3502c40a1d22657
2013-06-04 13:29:16 +08:00
Chris Behrens 7a5ed3e767 Cells: Add filtering and weight support
This adds filtering and weighing support to the cells scheduler.

Adds the following config options to the 'cells' group:

scheduler_filter_classes -- list of filter classes
scheduler_weight_classes -- list of weight classes

Adds a couple of weighing modules as defaults (which removes the random
cell selection):

ram_by_instance_type: Select cells with the most capacity for the
instance type being requested.
weight_offset: Allows modifying the DB to weight a particular cell
(useful for disabling a cell)

Adds a filter class (TargetCellFilter) that allows specifying a scheduler
hint to direct a build to a particular cell if you're an admin.

DocImpact

Implements blueprint cells-filter-scheduler

Change-Id: I027c5734e3d6134127fcd4dd28b8ff39047416dc
2013-05-27 18:28:02 +00:00
Phil Day 76f24ac1c7 Adds useful debug logging to filter_scheduler
On a large system (>500 hosts) the amount of logging
information if everything is at DEBUG is vasts, due to
the number of hosts checked for each filter

However at the moment some useful information is only
available within the filter's debug entrys (such as
parts of the request_spec).   Also instance uuids are
not logged making it hard to search for instance entries.

This set of changes allows it to be used in a very
large install with debug turned off for everything
except nova.filters

Specifically:
 - Log.Info the instance_uuids at the start of schedule
 - Log.debug the request_spec at the start of schedule
 - Log.debug hosts in weighted order
 - Log.info which host has been allocated to a specific
   instance_uuid
 - Log.debug how many hosts are returned by each filter

To get a count from each filter nova.filters had to be
changed to generate a list after each filter rather than
building a recursive generator object.   Although this
new approach is less elegant it does provide simple and
useful insight into the behaviour of the filters, and s
the impact on execution time on a system with several
hundred hosts and 10 filters was negligible

Change-Id: Ibbdd14f87b1dfd3cee8bf3cf6388e40b474e530a
2013-05-10 16:49:06 +01:00
Kurt Taylor d17f9ab13d Update OpenStack LLC to Foundation
Update all references of "LLC" to "Foundation".

Change-Id: I009e86784ef4dcf38882d64b0eff484576e04efe
2013-02-26 19:15:29 -05:00
Chris Behrens 0d9ce8319d Refactor scheduling filters
This changes the scheduling filters to use the code in nova/loadables.py
to locate filtering classes.  This also creates some base functionality
in nova/filters.py to be used by both the host scheduler and the cells
scheduler.

The scheduler_available_filters default has changed to
'nova.scheduler.filters.all_filters' which is better named compared to
the old setting of 'standard_filters'.  The old method is still
supported for those that have put it explicitly in their configs, but
it's marked as deprecated.

DocImpact

Change-Id: I84fdeafdba0275ab4b25f8857563bd7b1494bb69
2012-11-14 19:04:12 +00:00