Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable pylint too-many-ancestors check #964

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hotsos/core/plugins/openstack/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,14 @@ def apache2_allow_encoded_slashes_on(self):
return False


class OpenStackChecks(OpenstackBase, plugintools.PluginPartBase):
class OpenStackChecks(plugintools.PluginPartBase):
""" OpenStack checks. """
plugin_name = "openstack"
plugin_root_index = 4

@property
@cached_property
def plugin_runnable(self):
return self.openstack_installed
return OpenstackBase().openstack_installed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess in a perfect world this would just be a function and not have to instantiate the class

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed this is not optimal, i will followup with a patch to improve it



class OpenstackEventCallbackBase(OpenstackBase, EventCallbackBase):
Expand Down
85 changes: 44 additions & 41 deletions hotsos/core/plugintools.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(cls, _name, _mro, members):
'runner': subcls})


class HOTSOSDumper(yaml.Dumper):
class HOTSOSDumper(yaml.Dumper): # pylint: disable=too-many-ancestors
""" Custom yaml dumper that preserves order. """
def increase_indent(self, flow=False, indentless=False):
return super().increase_indent(flow, False)
Expand Down Expand Up @@ -212,41 +212,6 @@ def dump(self, data):
return markdown.rstrip('\n')


class ApplicationBase(metaclass=PluginRegistryMeta):
"""
Base class for all plugins representing an application.
"""
def __init__(self, *args, **kwargs):
self.apt = None # APTPackageHelper
self.snaps = None # SnapPackageHelper
self.docker = None # DockerImageHelper
self.pebble = None # PebbleHelper
self.systemd = None # SystemdHelper
super().__init__(*args, **kwargs)

@property
def version(self):
""" Optional application version. """
return None

@property
def release_name(self):
""" Optional application release_name. """
return None

@property
def days_to_eol(self):
""" Optional application days_to_eol. """
return None

@property
def bind_interfaces(self):
"""
Optionally implement this method to return a dictionary of network
interfaces used by this application.
"""


@dataclass
class SummaryEntry:
""" SummaryEntry data type. """
Expand Down Expand Up @@ -287,15 +252,53 @@ class DefaultSummaryEntryIndexes(IntEnum):
AVAILABLE = auto()


class SummaryBase(ApplicationBase):
""" Common structure for application summary output.
class ApplicationSummaryBase(metaclass=PluginRegistryMeta):
""" Common structure for application plugin and summary output.

Individual application plugins should implement this class and extend to
include information specific to their application.
include information specific to their application and the summary output
they would like to display.

A common set of summary entries are provided. These can be overriden with
a different entry key by clobbering the entry index. A corresponding set of
default attributes is also provided to support these entries and these
default to None so produce no output by default.
"""

def __init__(self, *args, **kwargs):
self.apt = None # APTPackageHelper
self.snaps = None # SnapPackageHelper
self.docker = None # DockerImageHelper
self.pebble = None # PebbleHelper
self.systemd = None # SystemdHelper
super().__init__(*args, **kwargs)

@property
def version(self):
""" Optional application version. """
return None

@property
def release_name(self):
""" Optional application release_name. """
return None

@property
def days_to_eol(self):
""" Optional application days_to_eol. """
return None

@property
def bind_interfaces(self):
"""
Optionally implement this method to return a dictionary of network
interfaces used by this application.
"""

@classmethod
def default_summary_entries(cls):
return [e for e in dir(SummaryBase) if str(e).startswith('summary_')]
return [e for e in dir(ApplicationSummaryBase)
if str(e).startswith('summary_')]

@summary_entry('version', DefaultSummaryEntryIndexes.VERSION)
def summary_version(self):
Expand Down Expand Up @@ -443,7 +446,7 @@ def all(self):
return {HotSOSConfig.plugin_name: parts}


class PluginPartBase(SummaryBase):
class PluginPartBase(ApplicationSummaryBase):
""" This is the base class used for all plugins.

Provides a standard set of methods that plugins will need as well as the
Expand Down
4 changes: 2 additions & 2 deletions hotsos/defs/scenarios/openstack/eol.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
checks:
is_eol:
property:
path: hotsos.core.plugins.openstack.OpenStackChecks.days_to_eol
path: hotsos.core.plugins.openstack.OpenstackBase.days_to_eol
ops: [[le, 0]]
conclusions:
is-eol:
Expand All @@ -14,4 +14,4 @@ conclusions:
limited support and is likely not receiving updates
anymore. Please consider upgrading to a newer release.
format-dict:
release: hotsos.core.plugins.openstack.OpenStackChecks.release_name
release: hotsos.core.plugins.openstack.OpenstackBase.release_name
2 changes: 1 addition & 1 deletion hotsos/defs/scenarios/openstack/nova/cpu_pinning.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
vars:
isolcpus_enabled: '@hotsos.core.plugins.kernel.KernelBase.isolcpus_enabled'
cpuaffinity_enabled: '@hotsos.core.plugins.kernel.SystemdConfig.cpuaffinity_enabled'
openstack_release: '@hotsos.core.plugins.openstack.OpenStackChecks.release_name'
openstack_release: '@hotsos.core.plugins.openstack.OpenstackBase.release_name'
vcpu_pinset: '@hotsos.core.plugins.openstack.nova.CPUPinning.vcpu_pin_set'
cpu_dedicated_set: '@hotsos.core.plugins.openstack.nova.CPUPinning.cpu_dedicated_set'
cpu_dedicated_set_name: '@hotsos.core.plugins.openstack.nova.CPUPinning.cpu_dedicated_set_name'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
checks:
has_mixed_pkg_releases:
property:
path: hotsos.core.plugins.openstack.OpenStackChecks.installed_pkg_release_names
path: hotsos.core.plugins.openstack.OpenstackBase.installed_pkg_release_names
ops: [[length_hint], [gt, 1]]
conclusions:
mixed-pkg-releases:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
checks:
has_unexpected_masked:
property:
path: hotsos.core.plugins.openstack.OpenStackChecks.unexpected_masked_services
path: hotsos.core.plugins.openstack.OpenstackBase.unexpected_masked_services
ops: [[ne, []]]
conclusions:
has-unexpected-masked:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mock:
hotsos.core.plugins.system.system.NUMAInfo.nodes:
kwargs:
new: {0: [1, 3, 5], 1: [0, 2, 4]}
hotsos.core.plugins.openstack.OpenStackChecks.release_name:
hotsos.core.plugins.openstack.OpenstackBase.release_name:
kwargs:
new: train
hotsos.core.plugins.system.SystemBase.num_cpus:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mock:
hotsos.core.plugins.system.system.NUMAInfo.nodes:
kwargs:
new: {0: [1, 3, 5], 1: [0, 2, 4]}
hotsos.core.plugins.openstack.OpenStackChecks.release_name:
hotsos.core.plugins.openstack.OpenstackBase.release_name:
kwargs:
new: train
hotsos.core.plugins.system.SystemBase.num_cpus:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mock:
hotsos.core.plugins.system.system.NUMAInfo.nodes:
kwargs:
new: {0: [1, 3, 5], 1: [0, 2, 4]}
hotsos.core.plugins.openstack.OpenStackChecks.release_name:
hotsos.core.plugins.openstack.OpenstackBase.release_name:
kwargs:
new: train
hotsos.core.plugins.system.SystemBase.num_cpus:
Expand Down
4 changes: 2 additions & 2 deletions hotsos/plugin_extensions/openstack/agent/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from hotsos.core.config import HotSOSConfig
from hotsos.core.log import log
from hotsos.core.plugins.openstack.common import OpenStackChecks
from hotsos.core.plugins.openstack.common import OpenstackBase, OpenStackChecks
from hotsos.core.search import (
FileSearcher,
SearchDef,
Expand Down Expand Up @@ -107,7 +107,7 @@ def files_w_exceptions(self):
return files


class AgentExceptionChecks(OpenStackChecks):
class AgentExceptionChecks(OpenstackBase, OpenStackChecks):
"""
Openstack services/agents will log exceptions using ERROR and
WARNING log levels depending on who raised them and their
Expand Down
4 changes: 2 additions & 2 deletions hotsos/plugin_extensions/openstack/service_features.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from hotsos.core.log import log
from hotsos.core.plugins.openstack.common import OpenStackChecks
from hotsos.core.plugins.openstack.common import OpenstackBase, OpenStackChecks
from hotsos.core.plugintools import (
summary_entry,
get_min_available_entry_index,
Expand Down Expand Up @@ -42,7 +42,7 @@
'live_migration_permit_post_copy': False}}}


class ServiceFeatureChecks(OpenStackChecks):
class ServiceFeatureChecks(OpenstackBase, OpenStackChecks):
""" Implements Openstack service feature checks. """
summary_part_index = 5

Expand Down
4 changes: 2 additions & 2 deletions hotsos/plugin_extensions/openstack/service_network_checks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re

from hotsos.core.host_helpers import CLIHelper, HostNetworkingHelper
from hotsos.core.plugins.openstack.common import OpenStackChecks
from hotsos.core.plugins.openstack.common import OpenstackBase, OpenStackChecks
from hotsos.core.plugins.openstack.neutron import (
IP_HEADER_BYTES,
GRE_HEADER_BYTES,
Expand All @@ -18,7 +18,7 @@
)


class OpenstackNetworkChecks(OpenStackChecks):
class OpenstackNetworkChecks(OpenstackBase, OpenStackChecks):
""" Implements OpenStack network checks. """
summary_part_index = 4

Expand Down
4 changes: 2 additions & 2 deletions hotsos/plugin_extensions/openstack/summary.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from hotsos.core.plugins.openstack.common import OpenStackChecks
from hotsos.core.plugins.openstack.common import OpenstackBase, OpenStackChecks
from hotsos.core.plugins.openstack.neutron import NeutronHAInfo
from hotsos.core.plugintools import (
summary_entry,
get_min_available_entry_index,
)


class OpenStackSummary(OpenStackChecks):
class OpenStackSummary(OpenstackBase, OpenStackChecks):
""" Implementation of OpenStack summary. """
summary_part_index = 0

Expand Down
3 changes: 2 additions & 1 deletion hotsos/plugin_extensions/openstack/vm_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from hotsos.core.analytics import LogEventStats
from hotsos.core.plugins.openstack.common import (
OpenstackBase,
OpenStackChecks,
OpenstackEventHandlerBase,
OpenstackEventCallbackBase,
Expand All @@ -14,7 +15,7 @@
)


class OpenstackInstanceChecks(OpenStackChecks):
class OpenstackInstanceChecks(OpenstackBase, OpenStackChecks):
""" Implements Openstack Nova instance checks. """
summary_part_index = 2

Expand Down
3 changes: 1 addition & 2 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ score=yes
disable=
missing-function-docstring,
missing-module-docstring,
too-many-ancestors,
too-many-branches,
too-many-instance-attributes,
too-many-locals,

[DESIGN]
min-public-methods=1
min-public-methods=1
14 changes: 7 additions & 7 deletions tests/unit/test_openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@ def setUp(self, *args, **kwargs):
class TestOpenstackPluginCore(TestOpenstackBase):
""" Unit tests for OpenStack plugin core. """
def test_release_name(self):
base = openstack_core.OpenStackChecks()
base = openstack_core.OpenstackBase()
self.assertEqual(base.release_name, 'ussuri')

@utils.create_data_root({'etc/openstack-release':
'OPENSTACK_CODENAME=yoga'})
def test_release_name_from_file(self):
base = openstack_core.OpenStackChecks()
base = openstack_core.OpenstackBase()
with mock.patch.object(base, 'installed_pkg_release_names', None):
self.assertEqual(base.release_name, 'yoga')

Expand All @@ -274,7 +274,7 @@ def test_get_release_eol(self, mock_date):
# 2030-04-30
mock_date.return_value = host_helpers.cli.CmdOutput('1903748400')

inst = openstack_core.OpenStackChecks()
inst = openstack_core.OpenstackBase()
self.assertEqual(inst.release_name, 'ussuri')

self.assertLessEqual(inst.days_to_eol, 0)
Expand All @@ -284,7 +284,7 @@ def test_get_release_not_eol(self, mock_date):
# 2030-01-01
mock_date.return_value = host_helpers.cli.CmdOutput('1893466800')

inst = openstack_core.OpenStackChecks()
inst = openstack_core.OpenstackBase()
self.assertEqual(inst.release_name, 'ussuri')

self.assertGreater(inst.days_to_eol, 0)
Expand Down Expand Up @@ -347,7 +347,7 @@ def test_project_catalog_package_exprs(self):
self.assertEqual(sorted(c.packages_dep_exprs), sorted(deps))

def test_project_catalog_packages(self):
ost_base = openstack_core.OpenStackChecks()
ost_base = openstack_core.OpenstackBase()
core = {'keystone-common': '2:17.0.1-0ubuntu1',
'neutron-common': '2:16.4.1-0ubuntu2',
'neutron-dhcp-agent': '2:16.4.1-0ubuntu2',
Expand Down Expand Up @@ -472,7 +472,7 @@ def test_get_summary(self):

@mock.patch('hotsos.core.plugins.openstack.openstack.OSTProject.installed',
True)
@mock.patch('hotsos.core.plugins.openstack.OpenStackChecks.'
@mock.patch('hotsos.core.plugins.openstack.OpenstackBase.'
'openstack_installed', True)
@mock.patch('hotsos.core.host_helpers.systemd.CLIHelper')
def test_get_summary_apache_service(self, mock_helper):
Expand All @@ -491,7 +491,7 @@ def test_get_summary_apache_service(self, mock_helper):
actual = self.part_output_to_actual(inst.output)
self.assertEqual(actual['services']['systemd'], expected)

@mock.patch('hotsos.core.plugins.openstack.common.OpenStackChecks.'
@mock.patch('hotsos.core.plugins.openstack.common.OpenstackBase.'
'days_to_eol', 3000)
@utils.create_data_root({os.path.join(APT_SOURCE_PATH.format(r)):
APT_UCA.format(r) for r in
Expand Down
Loading