Update pre-commit hooks to latest versions and fix linting errors
This change also removes some redundant checks since ruff will handle tabs. Change-Id: Ie077c89a7efb5f479172b1c1bc8f05ed8139bcfb Signed-off-by: Sean Mooney <work@seanmooney.info>
This commit is contained in:
+17
-19
@@ -1,64 +1,62 @@
|
||||
---
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v5.0.0
|
||||
rev: v6.0.0
|
||||
hooks:
|
||||
# whitespace
|
||||
- id: trailing-whitespace
|
||||
- id: mixed-line-ending
|
||||
args: ['--fix', 'lf']
|
||||
exclude: '.*\.(svg)$'
|
||||
- id: check-byte-order-marker
|
||||
- id: fix-byte-order-marker
|
||||
# file format and permissions
|
||||
- id: check-ast
|
||||
- id: debug-statements
|
||||
- id: check-json
|
||||
files: .*\.json$
|
||||
- id: check-yaml
|
||||
files: .*\.(yaml|yml)$
|
||||
- id: check-executables-have-shebangs
|
||||
- id: check-shebang-scripts-are-executable
|
||||
- id: check-yaml
|
||||
files: .*\.(yaml|yml)$
|
||||
- id: check-json
|
||||
files: .*\.json$
|
||||
exclude: .*-curl.*\.json$
|
||||
- id: check-ast
|
||||
# git
|
||||
- id: check-added-large-files
|
||||
- id: check-case-conflict
|
||||
- id: detect-private-key
|
||||
- id: check-merge-conflict
|
||||
exclude: '.*\.(rst|inc)$'
|
||||
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
||||
rev: v1.5.5
|
||||
hooks:
|
||||
- id: remove-tabs
|
||||
exclude: '.*\.(svg)$'
|
||||
# python
|
||||
- id: debug-statements
|
||||
- id: check-docstring-first
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.12.1
|
||||
rev: v0.15.7
|
||||
hooks:
|
||||
- id: ruff-check
|
||||
args: ['--fix', '--unsafe-fixes']
|
||||
- id: ruff-format
|
||||
- repo: https://opendev.org/openstack/hacking
|
||||
rev: 7.0.0
|
||||
rev: 8.0.0
|
||||
hooks:
|
||||
- id: hacking
|
||||
additional_dependencies: []
|
||||
exclude: '^(doc|releasenotes|tools)/.*$'
|
||||
- repo: https://github.com/PyCQA/bandit
|
||||
rev: 1.8.3
|
||||
rev: 1.9.4
|
||||
hooks:
|
||||
- id: bandit
|
||||
args: ['-c', 'pyproject.toml']
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
rev: v2.4.1
|
||||
rev: v2.4.2
|
||||
hooks:
|
||||
- id: codespell
|
||||
args: ['--ignore-words=doc/dictionary.txt']
|
||||
- repo: https://github.com/sphinx-contrib/sphinx-lint
|
||||
rev: v1.0.0
|
||||
rev: v1.0.2
|
||||
hooks:
|
||||
- id: sphinx-lint
|
||||
args: [--enable=default-role]
|
||||
files: ^doc/|^releasenotes/|^api-guide/
|
||||
types: [rst]
|
||||
- repo: https://github.com/PyCQA/doc8
|
||||
rev: v1.1.2
|
||||
rev: v2.0.0
|
||||
hooks:
|
||||
- id: doc8
|
||||
|
||||
@@ -187,7 +187,7 @@ class NovaModelBuilder(base.BaseModelBuilder):
|
||||
|
||||
NOTE(v-francoise): This model builder is meant to be extended in the future
|
||||
to also include both storage and network information respectively coming
|
||||
from Cinder and Neutron. Some prelimary work has been done in this
|
||||
from Cinder and Neutron. Some preliminary work has been done in this
|
||||
direction in https://review.opendev.org/#/c/362730 but since we cannot
|
||||
guarantee a sufficient level of consistency for neither the storage nor the
|
||||
network part before the end of the Ocata cycle, this work has been
|
||||
|
||||
@@ -115,7 +115,7 @@ class WorkloadStabilizationPlanner(base.BasePlanner):
|
||||
|
||||
# scheduling
|
||||
scheduled = sorted(
|
||||
to_schedule, key=lambda weight: (weight[0]), reverse=True
|
||||
to_schedule, key=lambda weight: weight[0], reverse=True
|
||||
)
|
||||
if len(scheduled) == 0:
|
||||
LOG.warning("The action plan is empty")
|
||||
|
||||
@@ -450,7 +450,7 @@ class BasicConsolidation(base.ServerConsolidationBaseStrategy):
|
||||
|
||||
scores = self.compute_score_of_nodes()
|
||||
# Sort compute nodes by Score decreasing
|
||||
sorted_scores = sorted(scores, reverse=True, key=lambda x: (x[1]))
|
||||
sorted_scores = sorted(scores, reverse=True, key=lambda x: x[1])
|
||||
LOG.debug("Compute node(s) BFD %s", sorted_scores)
|
||||
# Get Node to be released
|
||||
if len(scores) == 0:
|
||||
@@ -469,7 +469,7 @@ class BasicConsolidation(base.ServerConsolidationBaseStrategy):
|
||||
|
||||
# Sort instances by Score
|
||||
sorted_instances = sorted(
|
||||
instance_score, reverse=True, key=lambda x: (x[1])
|
||||
instance_score, reverse=True, key=lambda x: x[1]
|
||||
)
|
||||
# BFD: Best Fit Decrease
|
||||
LOG.debug("Instance(s) BFD %s", sorted_instances)
|
||||
|
||||
@@ -246,7 +246,7 @@ class OutletTempControl(base.ThermalOptimizationBaseStrategy):
|
||||
|
||||
# choose the server with highest outlet t
|
||||
hosts_need_release = sorted(
|
||||
hosts_need_release, reverse=True, key=lambda x: (x["outlet_temp"])
|
||||
hosts_need_release, reverse=True, key=lambda x: x["outlet_temp"]
|
||||
)
|
||||
|
||||
instance_to_migrate = self.choose_instance_to_migrate(
|
||||
@@ -266,7 +266,7 @@ class OutletTempControl(base.ThermalOptimizationBaseStrategy):
|
||||
LOG.info("No proper target host could be found")
|
||||
return self.solution
|
||||
|
||||
dest_servers = sorted(dest_servers, key=lambda x: (x["outlet_temp"]))
|
||||
dest_servers = sorted(dest_servers, key=lambda x: x["outlet_temp"])
|
||||
# always use the host with lowerest outlet temperature
|
||||
mig_destination_node = dest_servers[0]['compute_node']
|
||||
# generate solution to migrate the instance to the dest server,
|
||||
|
||||
@@ -156,18 +156,20 @@ class StorageCapacityBalance(base.WorkloadStabilizationBaseStrategy):
|
||||
"""
|
||||
under_pools = list(
|
||||
filter(
|
||||
lambda p: float(p.total_capacity_gb)
|
||||
- float(p.free_capacity_gb)
|
||||
< float(p.total_capacity_gb) * threshold,
|
||||
lambda p: (
|
||||
float(p.total_capacity_gb) - float(p.free_capacity_gb)
|
||||
< float(p.total_capacity_gb) * threshold
|
||||
),
|
||||
pools,
|
||||
)
|
||||
)
|
||||
|
||||
over_pools = list(
|
||||
filter(
|
||||
lambda p: float(p.total_capacity_gb)
|
||||
- float(p.free_capacity_gb)
|
||||
>= float(p.total_capacity_gb) * threshold,
|
||||
lambda p: (
|
||||
float(p.total_capacity_gb) - float(p.free_capacity_gb)
|
||||
>= float(p.total_capacity_gb) * threshold
|
||||
),
|
||||
pools,
|
||||
)
|
||||
)
|
||||
@@ -182,10 +184,10 @@ class StorageCapacityBalance(base.WorkloadStabilizationBaseStrategy):
|
||||
volume_type_list = cinder.get_volume_type_list()
|
||||
volume_type = list(
|
||||
filter(
|
||||
lambda volume_type: volume_type.extra_specs.get(
|
||||
'volume_backend_name'
|
||||
)
|
||||
== backendname,
|
||||
lambda volume_type: (
|
||||
volume_type.extra_specs.get('volume_backend_name')
|
||||
== backendname
|
||||
),
|
||||
volume_type_list,
|
||||
)
|
||||
)
|
||||
@@ -201,8 +203,9 @@ class StorageCapacityBalance(base.WorkloadStabilizationBaseStrategy):
|
||||
LOG.info("volume %s type %s", volume.id, volume.volume_type)
|
||||
return target_pool_name
|
||||
self.dest_pools.sort(
|
||||
key=lambda p: float(p.free_capacity_gb)
|
||||
/ float(p.total_capacity_gb)
|
||||
key=lambda p: (
|
||||
float(p.free_capacity_gb) / float(p.total_capacity_gb)
|
||||
)
|
||||
)
|
||||
for pool in reversed(self.dest_pools):
|
||||
total_cap = float(pool.total_capacity_gb)
|
||||
@@ -263,8 +266,9 @@ class StorageCapacityBalance(base.WorkloadStabilizationBaseStrategy):
|
||||
def retype_fit(self, volume, threshold):
|
||||
target_type = None
|
||||
self.dest_pools.sort(
|
||||
key=lambda p: float(p.free_capacity_gb)
|
||||
/ float(p.total_capacity_gb)
|
||||
key=lambda p: (
|
||||
float(p.free_capacity_gb) / float(p.total_capacity_gb)
|
||||
)
|
||||
)
|
||||
for pool in reversed(self.dest_pools):
|
||||
backendname = getattr(pool, 'volume_backend_name')
|
||||
@@ -337,8 +341,9 @@ class StorageCapacityBalance(base.WorkloadStabilizationBaseStrategy):
|
||||
if seek_flag:
|
||||
noboot_volumes = list(
|
||||
filter(
|
||||
lambda v: v.bootable.lower() == 'false'
|
||||
and v.status == 'in-use',
|
||||
lambda v: (
|
||||
v.bootable.lower() == 'false' and v.status == 'in-use'
|
||||
),
|
||||
volumes_in_pool,
|
||||
)
|
||||
)
|
||||
@@ -364,8 +369,9 @@ class StorageCapacityBalance(base.WorkloadStabilizationBaseStrategy):
|
||||
if seek_flag:
|
||||
boot_volumes = list(
|
||||
filter(
|
||||
lambda v: v.bootable.lower() == 'true'
|
||||
and v.status == 'in-use',
|
||||
lambda v: (
|
||||
v.bootable.lower() == 'true' and v.status == 'in-use'
|
||||
),
|
||||
volumes_in_pool,
|
||||
)
|
||||
)
|
||||
|
||||
@@ -206,7 +206,7 @@ class UniformAirflow(base.BaseStrategy):
|
||||
"""Find instance and host with sufficient available resources"""
|
||||
# large instances go first
|
||||
instances_to_migrate = sorted(
|
||||
instances_to_migrate, reverse=True, key=lambda x: (x.vcpus)
|
||||
instances_to_migrate, reverse=True, key=lambda x: x.vcpus
|
||||
)
|
||||
# find hosts for instances
|
||||
destination_hosts = []
|
||||
@@ -310,14 +310,14 @@ class UniformAirflow(base.BaseStrategy):
|
||||
|
||||
# migrate the instance from server with largest airflow first
|
||||
source_nodes = sorted(
|
||||
source_nodes, reverse=True, key=lambda x: (x["airflow"])
|
||||
source_nodes, reverse=True, key=lambda x: x["airflow"]
|
||||
)
|
||||
instances_to_migrate = self.choose_instance_to_migrate(source_nodes)
|
||||
if not instances_to_migrate:
|
||||
return self.solution
|
||||
source_node, instances_src = instances_to_migrate
|
||||
# sort host with airflow
|
||||
target_nodes = sorted(target_nodes, key=lambda x: (x["airflow"]))
|
||||
target_nodes = sorted(target_nodes, key=lambda x: x["airflow"])
|
||||
# find the hosts that have enough resource
|
||||
# for the instance to be migrated
|
||||
destination_hosts = self.filter_destination_hosts(
|
||||
|
||||
@@ -360,7 +360,7 @@ class WorkloadBalance(base.WorkloadStabilizationBaseStrategy):
|
||||
|
||||
# choose the server with largest cpu usage
|
||||
source_nodes = sorted(
|
||||
source_nodes, reverse=True, key=lambda x: (x[self._meter])
|
||||
source_nodes, reverse=True, key=lambda x: x[self._meter]
|
||||
)
|
||||
|
||||
instance_to_migrate = self.choose_instance_to_migrate(
|
||||
@@ -383,7 +383,7 @@ class WorkloadBalance(base.WorkloadStabilizationBaseStrategy):
|
||||
)
|
||||
return self.solution
|
||||
destination_hosts = sorted(
|
||||
destination_hosts, key=lambda x: (x[self._meter])
|
||||
destination_hosts, key=lambda x: x[self._meter]
|
||||
)
|
||||
# always use the host with lowerest CPU utilization
|
||||
mig_destination_node = destination_hosts[0]['compute_node']
|
||||
|
||||
Reference in New Issue
Block a user