diff --git a/.zuul.yaml b/.zuul.yaml index 06c9ec4..aec6c33 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -3,13 +3,68 @@ check: jobs: - openstack-tox-linters + - k8sapp-metrics-server-tox-py39 + - k8sapp-metrics-server-tox-flake8 + - k8sapp-metrics-server-tox-pylint gate: jobs: - openstack-tox-linters + - k8sapp-metrics-server-tox-py39 + - k8sapp-metrics-server-tox-flake8 + - k8sapp-metrics-server-tox-pylint + post: jobs: - stx-metrics-server-armada-app-upload-git-mirror +- job: + name: k8sapp-metrics-server-tox-py39 + parent: tox-py39 + description: | + Run py39 test for metrics_server + nodeset: debian-bullseye + required-projects: + - starlingx/config + - starlingx/fault + - starlingx/update + - starlingx/utilities + files: + - python3-k8sapp-metrics-server/* + vars: + tox_envlist: py39 + python_version: 3.9 + tox_extra_args: -c python3-k8sapp-metrics-server/k8sapp_metrics_server/tox.ini + +- job: + name: k8sapp-metrics-server-tox-pylint + parent: tox + description: | + Run pylint test for k8sapp_metrics_server + nodeset: debian-bullseye + required-projects: + - starlingx/config + - starlingx/fault + - starlingx/update + - starlingx/utilities + files: + - python3-k8sapp-metrics-server/* + vars: + tox_envlist: pylint + tox_extra_args: -c python3-k8sapp-metrics-server/k8sapp_metrics_server/tox.ini + +- job: + name: k8sapp-metrics-server-tox-flake8 + parent: tox + description: | + Run flake8 for metrics-server + nodeset: debian-bullseye + files: + - python3-k8sapp-metrics-server/* + vars: + tox_envlist: flake8 + tox_extra_args: -c python3-k8sapp-metrics-server/k8sapp_metrics_server/tox.ini + + - job: name: stx-metrics-server-armada-app-upload-git-mirror parent: upload-git-mirror diff --git a/bindep.txt b/bindep.txt new file mode 100644 index 0000000..3ffe69f --- /dev/null +++ b/bindep.txt @@ -0,0 +1,10 @@ +# This is a cross-platform list tracking distribution packages needed for install and tests; +# see https://docs.openstack.org/infra/bindep/ for additional information. + +libffi-dev [platform:dpkg] +libldap2-dev [platform:dpkg] +libxml2-dev [platform:dpkg] +libxslt1-dev [platform:dpkg] +libsasl2-dev [platform:dpkg] +libffi-devel [platform:rpm] +python3-all-dev [platform:dpkg] diff --git a/debian_pkg_dirs b/debian_pkg_dirs index 517578d..1dd2b58 100644 --- a/debian_pkg_dirs +++ b/debian_pkg_dirs @@ -1,2 +1,3 @@ +python3-k8sapp-metrics-server metrics-server-helm stx-metrics-server-helm diff --git a/metrics-server-helm/debian/deb_folder/control b/metrics-server-helm/debian/deb_folder/control index 2191aa7..b9f6ab7 100644 --- a/metrics-server-helm/debian/deb_folder/control +++ b/metrics-server-helm/debian/deb_folder/control @@ -3,7 +3,6 @@ Section: libs Priority: optional Maintainer: StarlingX Developers Build-Depends: debhelper-compat (= 13), - chartmuseum, helm, procps Standards-Version: 4.5.1 diff --git a/metrics-server-helm/debian/deb_folder/copyright b/metrics-server-helm/debian/deb_folder/copyright index c43933f..7479f57 100644 --- a/metrics-server-helm/debian/deb_folder/copyright +++ b/metrics-server-helm/debian/deb_folder/copyright @@ -1,6 +1,6 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: metrics-server-helm -Source: https://opendev.org/starlingx/cert-manager-armada-app/ +Source: https://opendev.org/starlingx/metrics-server-armada-app Files: * Copyright: (c) 2013-2023 Wind River Systems, Inc diff --git a/python3-k8sapp-metrics-server/debian/deb_folder/changelog b/python3-k8sapp-metrics-server/debian/deb_folder/changelog new file mode 100644 index 0000000..1374f32 --- /dev/null +++ b/python3-k8sapp-metrics-server/debian/deb_folder/changelog @@ -0,0 +1,5 @@ +python3-k8sapp-metrics-server (1.0-1) unstable; urgency=medium + + * Initial release. + + -- David Bastos Fri, 27 Oct 2023 08:00:42 +0000 \ No newline at end of file diff --git a/python3-k8sapp-metrics-server/debian/deb_folder/control b/python3-k8sapp-metrics-server/debian/deb_folder/control new file mode 100644 index 0000000..1059bb8 --- /dev/null +++ b/python3-k8sapp-metrics-server/debian/deb_folder/control @@ -0,0 +1,26 @@ +Source: python3-k8sapp-metrics-server +Section: libs +Priority: optional +Maintainer: StarlingX Developers +Build-Depends: debhelper-compat (= 13), + dh-python, + python3-all, + python3-pbr, + python3-setuptools, + python3-wheel +Standards-Version: 4.5.1 +Homepage: https://www.starlingx.io + +Package: python3-k8sapp-metrics-server +Section: libs +Architecture: any +Depends: ${misc:Depends}, ${python3:Depends} +Description: StarlingX Sysinv metrics-server Extensions + This package contains sysinv plugins for the metrics-server K8S app. + +Package: python3-k8sapp-metrics-server-wheels +Section: libs +Architecture: any +Depends: ${misc:Depends}, ${python3:Depends}, python3-wheel +Description: StarlingX Sysinv metrics-server Extension Wheels + This package contains python wheels for the metrics-server K8S app plugins. diff --git a/python3-k8sapp-metrics-server/debian/deb_folder/copyright b/python3-k8sapp-metrics-server/debian/deb_folder/copyright new file mode 100644 index 0000000..dab5191 --- /dev/null +++ b/python3-k8sapp-metrics-server/debian/deb_folder/copyright @@ -0,0 +1,41 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: python3-k8sapp-metrics-server +Source: https://opendev.org/starlingx/metrics-server-armada-app/ + +Files: * +Copyright: (c) 2013-2023 Wind River Systems, Inc +License: Apache-2 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + https://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + On Debian-based systems the full text of the Apache version 2.0 license + can be found in `/usr/share/common-licenses/Apache-2.0'. + +# If you want to use GPL v2 or later for the /debian/* files use +# the following clauses, or change it to suit. Delete these two lines +Files: debian/* +Copyright: 2023 Wind River Systems, Inc +License: Apache-2 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + https://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + On Debian-based systems the full text of the Apache version 2.0 license + can be found in `/usr/share/common-licenses/Apache-2.0'. diff --git a/python3-k8sapp-metrics-server/debian/deb_folder/python3-k8sapp-metrics-server-wheels.install b/python3-k8sapp-metrics-server/debian/deb_folder/python3-k8sapp-metrics-server-wheels.install new file mode 100644 index 0000000..19a9e4c --- /dev/null +++ b/python3-k8sapp-metrics-server/debian/deb_folder/python3-k8sapp-metrics-server-wheels.install @@ -0,0 +1 @@ +plugins/*.whl diff --git a/python3-k8sapp-metrics-server/debian/deb_folder/python3-k8sapp-metrics-server.install b/python3-k8sapp-metrics-server/debian/deb_folder/python3-k8sapp-metrics-server.install new file mode 100644 index 0000000..91d1d9d --- /dev/null +++ b/python3-k8sapp-metrics-server/debian/deb_folder/python3-k8sapp-metrics-server.install @@ -0,0 +1 @@ +usr/lib/python3/dist-packages/k8sapp_* diff --git a/python3-k8sapp-metrics-server/debian/deb_folder/rules b/python3-k8sapp-metrics-server/debian/deb_folder/rules new file mode 100644 index 0000000..527858d --- /dev/null +++ b/python3-k8sapp-metrics-server/debian/deb_folder/rules @@ -0,0 +1,33 @@ +#!/usr/bin/make -f +# export DH_VERBOSE = 1 + +export APP_NAME = metrics-server +export PYBUILD_NAME = k8sapp_metrics_server + +export DEB_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ') +export MAJOR = $(shell echo $(DEB_VERSION) | cut -f 1 -d '-') +export MINOR_PATCH = $(shell echo $(DEB_VERSION) | cut -f 4 -d '.') +export PBR_VERSION = $(MAJOR).$(MINOR_PATCH) + +export ROOT = $(CURDIR)/debian/tmp +export SKIP_PIP_INSTALL = 1 + +%: + dh $@ --with=python3 --buildsystem=pybuild + +override_dh_auto_install: + env | sort + + python3 setup.py install \ + --install-layout=deb \ + --root $(ROOT) + + python3 setup.py bdist_wheel \ + --universal \ + -d $(ROOT)/plugins + +override_dh_python3: + dh_python3 --shebang=/usr/bin/python3 + +override_dh_auto_test: + PYTHONDIR=$(CURDIR) stestr run diff --git a/python3-k8sapp-metrics-server/debian/deb_folder/source/format b/python3-k8sapp-metrics-server/debian/deb_folder/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/python3-k8sapp-metrics-server/debian/deb_folder/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/python3-k8sapp-metrics-server/debian/meta_data.yaml b/python3-k8sapp-metrics-server/debian/meta_data.yaml new file mode 100644 index 0000000..9702c2c --- /dev/null +++ b/python3-k8sapp-metrics-server/debian/meta_data.yaml @@ -0,0 +1,9 @@ +--- +debname: python3-k8sapp-metrics-server +debver: 1.0-1 +src_path: k8sapp_metrics_server +revision: + dist: $STX_DIST + GITREVCOUNT: + SRC_DIR: ${MY_REPO}/stx/metrics-server-armada-app + BASE_SRCREV: 9fa1ccbdbae09c9726642bfbb5b20e27cd729f2c diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/.gitignore b/python3-k8sapp-metrics-server/k8sapp_metrics_server/.gitignore new file mode 100644 index 0000000..a4798c6 --- /dev/null +++ b/python3-k8sapp-metrics-server/k8sapp_metrics_server/.gitignore @@ -0,0 +1,36 @@ +# Compiled files +*.py[co] +*.a +*.o +*.so + +# Sphinx +_build +doc/source/api/ + +# Packages/installer info +*.egg +*.egg-info +.eggs +dist +build +eggs +parts +var +sdist +develop-eggs +.installed.cfg + +# Other +*.DS_Store +.stestr +.testrepository +.tox +.venv +.*.swp +.coverage +bandit.xml +cover +AUTHORS +ChangeLog +*.sqlite diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/.stestr.conf b/python3-k8sapp-metrics-server/k8sapp_metrics_server/.stestr.conf new file mode 100644 index 0000000..a68fccd --- /dev/null +++ b/python3-k8sapp-metrics-server/k8sapp_metrics_server/.stestr.conf @@ -0,0 +1,3 @@ +[DEFAULT] +test_path=./k8sapp_metrics_server/tests +top_dir=./k8sapp_metrics_server \ No newline at end of file diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/__init__.py b/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/common/__init__.py b/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/common/constants.py b/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/common/constants.py new file mode 100644 index 0000000..f215ccd --- /dev/null +++ b/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/common/constants.py @@ -0,0 +1,10 @@ +# +# Copyright (c) 2023 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +HELM_NS_METRICS_SERVER = "metrics-server" +HELM_APP_METRICS_SERVER = "metrics-server" +HELM_CHART_METRICS_SERVER = "metrics-server" +FLUXCD_HELMRELEASE_METRICS_SERVER = "metrics-server" diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/helm/__init__.py b/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/helm/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/helm/metrics_server.py b/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/helm/metrics_server.py new file mode 100644 index 0000000..77ba59c --- /dev/null +++ b/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/helm/metrics_server.py @@ -0,0 +1,40 @@ +# +# Copyright (c) 2023 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +from sysinv.common import exception +from sysinv.helm import base + +from k8sapp_metrics_server.common import constants as app_constants + + +class MetricsServerHelm(base.FluxCDBaseHelm): + """Class to encapsulate helm operations for the app chart""" + + SUPPORTED_NAMESPACES = base.BaseHelm.SUPPORTED_NAMESPACES + \ + [app_constants.HELM_NS_METRICS_SERVER] + SUPPORTED_APP_NAMESPACES = { + app_constants.HELM_APP_METRICS_SERVER: SUPPORTED_NAMESPACES + } + + CHART = app_constants.HELM_CHART_METRICS_SERVER + HELM_RELEASE = app_constants.FLUXCD_HELMRELEASE_METRICS_SERVER + + def get_namespaces(self): + return self.SUPPORTED_NAMESPACES + + def get_overrides(self, namespace=None): + + overrides = { + app_constants.HELM_NS_METRICS_SERVER: {} + } + + if namespace in self.SUPPORTED_NAMESPACES: + return overrides[namespace] + elif namespace: + raise exception.InvalidHelmNamespace(chart=self.CHART, + namespace=namespace) + else: + return overrides diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/lifecycle/__init__.py b/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/lifecycle/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/lifecycle/lifecycle_metrics_server.py b/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/lifecycle/lifecycle_metrics_server.py new file mode 100644 index 0000000..cec1ecc --- /dev/null +++ b/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/lifecycle/lifecycle_metrics_server.py @@ -0,0 +1,27 @@ +# +# Copyright (c) 2023 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +""" System inventory App lifecycle operator.""" + +from sysinv.helm import lifecycle_base as base + + +class MetricsServerAppLifecycleOperator(base.AppLifecycleOperator): + """Class to encapsulate lifecycle operations for the Metrics Server""" + + def app_lifecycle_actions(self, + context, + conductor_obj, + app_op, app, + hook_info): + """Perform lifecycle actions for an operation + + :param context: request context + :param conductor_obj: conductor object + :param app_op: AppOperator object + :param app: AppOperator.Application object + :param hook_info: LifecycleHookInfo object + """ diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/tests/__init__.py b/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/tests/test_plugins.py b/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/tests/test_plugins.py new file mode 100644 index 0000000..9a57a19 --- /dev/null +++ b/python3-k8sapp-metrics-server/k8sapp_metrics_server/k8sapp_metrics_server/tests/test_plugins.py @@ -0,0 +1,43 @@ +# +# Copyright (c) 2023 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# + +from k8sapp_metrics_server.common import constants as app_constants +from sysinv.tests.db import base as dbbase + + +class K8SAppMetricsServerAppMixin(object): + app_name = app_constants.HELM_APP_METRICS_SERVER + path_name = app_name + '.tgz' + + def setUp(self): # pylint: disable=useless-parent-delegation + super(K8SAppMetricsServerAppMixin, self).setUp() + + def test_stub(self): + # Replace this with a real unit test. + pass + + +# Test Configuration: +# - Controller +# - IPv6 +# - Ceph Storage +# - metrics-server app +class K8sAppMetricsServerControllerTestCase(K8SAppMetricsServerAppMixin, + dbbase.BaseIPv6Mixin, + dbbase.BaseCephStorageBackendMixin, + dbbase.ControllerHostTestCase): + pass + + +# Test Configuration: +# - AIO +# - IPv4 +# - Ceph Storage +# - metrics-server app +class K8SAppMetricsServerAIOTestCase(K8SAppMetricsServerAppMixin, + dbbase.BaseCephStorageBackendMixin, + dbbase.AIOSimplexHostTestCase): + pass diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/pylint.rc b/python3-k8sapp-metrics-server/k8sapp_metrics_server/pylint.rc new file mode 100644 index 0000000..4cf02c0 --- /dev/null +++ b/python3-k8sapp-metrics-server/k8sapp_metrics_server/pylint.rc @@ -0,0 +1,231 @@ +[MASTER] +# Specify a configuration file. +rcfile=pylint.rc + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Add files or directories to the blacklist. Should be base names, not paths. +ignore= + +# Pickle collected data for later comparisons. +persistent=yes + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + +# Use multiple processes to speed up Pylint. +jobs=4 + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code +extension-pkg-whitelist=lxml.etree,greenlet + + + +[MESSAGES CONTROL] +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time. + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). +# See "Messages Control" section of +# https://pylint.readthedocs.io/en/latest/user_guide +# We are disabling (C)onvention +# We are disabling (R)efactor +# W0212: protected-access +# W1618: no-absolute-import +disable=C, R, W0212, W1618 + +[REPORTS] +# Set the output format. Available formats are text, parseable, colorized, msvs +# (visual studio) and html +output-format=text + +# Tells whether to display a full report or only the messages +reports=yes + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + + +[SIMILARITIES] +# Minimum lines number of a similarity. +min-similarity-lines=4 + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + + +[FORMAT] +# Maximum number of characters on a single line. +max-line-length=85 + +# Maximum number of lines in a module +max-module-lines=1000 + +# String used as indentation unit. This is usually 4 spaces or "\t" (1 tab). +indent-string=' ' + + +[TYPECHECK] +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis +ignored-modules=distutils,eventlet.green.subprocess,six,six.moves + +# List of classes names for which member attributes should not be checked +# (useful for classes with attributes dynamically set). +# pylint is confused by sqlalchemy Table, as well as sqlalchemy Enum types +# ie: (unprovisioned, identity) +# LookupDict in requests library confuses pylint +ignored-classes=SQLObject, optparse.Values, thread._local, _thread._local, + Table, unprovisioned, identity, LookupDict + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E0201 when accessed. Python regular +# expressions are accepted. +generated-members=REQUEST,acl_users,aq_parent + + +[BASIC] +# Regular expression which should only match correct module names +module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ + +# Regular expression which should only match correct module level names +const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ + +# Regular expression which should only match correct class names +class-rgx=[A-Z_][a-zA-Z0-9]+$ + +# Regular expression which should only match correct function names +function-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct method names +method-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct instance attribute names +attr-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct argument names +argument-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct variable names +variable-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct list comprehension / +# generator expression variable names +inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ + +# Good variable names which should always be accepted, separated by a comma +good-names=i,j,k,ex,Run,_ + +# Bad variable names which should always be refused, separated by a comma +bad-names=foo,bar,baz,toto,tutu,tata + +# Regular expression which should only match functions or classes name which do +# not require a docstring +no-docstring-rgx=__.*__ + + +[MISCELLANEOUS] +# List of note tags to take in consideration, separated by a comma. +notes=FIXME,XXX,TODO + + +[VARIABLES] +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# A regular expression matching the beginning of the name of dummy variables +# (i.e. not used). +dummy-variables-rgx=_|dummy + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= + + +[IMPORTS] +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=regsub,string,TERMIOS,Bastion,rexec + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled) +import-graph= + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled) +ext-import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled) +int-import-graph= + + +[DESIGN] +# Maximum number of arguments for function / method +max-args=5 + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore +ignored-argument-names=_.* + +# Maximum number of locals for function / method body +max-locals=15 + +# Maximum number of return / yield for function / method body +max-returns=6 + +# Maximum number of branch for function / method body +max-branches=12 + +# Maximum number of statements in function / method body +max-statements=50 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + + +[CLASSES] +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__,__new__,setUp + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + + +[EXCEPTIONS] +# Exceptions that will emit a warning when being caught. Defaults to +# "Exception" +overgeneral-exceptions=builtins.Exception diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/requirements.txt b/python3-k8sapp-metrics-server/k8sapp_metrics_server/requirements.txt new file mode 100644 index 0000000..7b79eda --- /dev/null +++ b/python3-k8sapp-metrics-server/k8sapp_metrics_server/requirements.txt @@ -0,0 +1,2 @@ +pbr>=2.0.0 +PyYAML>=3.10 \ No newline at end of file diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/setup.cfg b/python3-k8sapp-metrics-server/k8sapp_metrics_server/setup.cfg new file mode 100644 index 0000000..6dea713 --- /dev/null +++ b/python3-k8sapp-metrics-server/k8sapp_metrics_server/setup.cfg @@ -0,0 +1,35 @@ +[metadata] +name = k8sapp-metrics-server +summary = StarlingX sysinv extensions for metrics-server +author = StarlingX +author-email = starlingx-discuss@lists.starlingx.io +home-page = https://www.starlingx.io/ +classifier = + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.6 + +[files] +packages = + k8sapp_metrics_server + +[global] +setup-hooks = + pbr.hooks.setup_hook + +[entry_points] +systemconfig.helm_applications = + metrics-server = systemconfig.helm_plugins.metrics_server + +systemconfig.helm_plugins.metrics_server = + 001_metrics-server = k8sapp_metrics_server.helm.metrics_server:MetricsServerHelm + +systemconfig.app_lifecycle = + metrics-server = k8sapp_metrics_server.lifecycle.lifecycle_metrics_server:MetricsServerAppLifecycleOperator + +[bdist_wheel] +universal = 1 diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/setup.py b/python3-k8sapp-metrics-server/k8sapp_metrics_server/setup.py new file mode 100644 index 0000000..79806f9 --- /dev/null +++ b/python3-k8sapp-metrics-server/k8sapp_metrics_server/setup.py @@ -0,0 +1,9 @@ +# +# copyright (c) 2023 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +import setuptools +setuptools.setup( + setup_requires=['pbr>=2.0.0'], + pbr=True) diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/test-requirements.txt b/python3-k8sapp-metrics-server/k8sapp_metrics_server/test-requirements.txt new file mode 100644 index 0000000..f75389a --- /dev/null +++ b/python3-k8sapp-metrics-server/k8sapp_metrics_server/test-requirements.txt @@ -0,0 +1,22 @@ +# The order of packages is significant, because pip processes them in the order +# of appearance. Changing the order has an impact on the overall integration +# process, which may cause wedges in the gate later. +hacking>=1.1.0,<=2.0.0 # Apache-2.0 +coverage>=3.6 +discover +mock>=2.0.0 # BSD +passlib>=1.7.0 +psycopg2-binary +python-subunit>=0.0.18 +requests-mock>=0.6.0 # Apache-2.0 +oslotest>=3.2.0 # Apache-2.0 +stestr>=1.0.0 # Apache-2.0 +testtools!=1.2.0,>=0.9.36 +ipaddr +pytest +pyudev +migrate +markupsafe +bandit +flake8-bugbear +pylint \ No newline at end of file diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/tox.ini b/python3-k8sapp-metrics-server/k8sapp_metrics_server/tox.ini new file mode 100644 index 0000000..e31fbaa --- /dev/null +++ b/python3-k8sapp-metrics-server/k8sapp_metrics_server/tox.ini @@ -0,0 +1,106 @@ +[tox] +envlist = flake8,py39,pylint,bandit,cover +minversion = 2.3 + +# tox does not work if the path to the workdir is too long, so move it to /tmp +toxworkdir = /tmp/{env:USER}_k8smstox +stxdir = {toxinidir}/../../.. +distshare={toxworkdir}/.tox/distshare + +[testenv] +allowlist_externals = bash + find +basepython = python3 +sitepackages = False + +install_command = pip install -v -v -v \ + -c{toxinidir}/upper-constraints.txt \ + -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} \ + {opts} {packages} + +# Note the hash seed is set to 0 until can be tested with a +# random hash seed successfully. +setenv = VIRTUAL_ENV={envdir} + PYTHONHASHSEED=0 + PYTHONDONTWRITEBYTECODE=1 + OS_TEST_PATH=./k8sapp_metrics_server/tests + LANG=en_US.UTF-8 + LANGUAGE=en_US:en + LC_ALL=C + EVENTS_YAML=./k8sapp_metrics_server/tests/events_for_testing.yaml + SYSINV_TEST_ENV=True + TOX_WORK_DIR={toxworkdir} + PYLINTHOME={toxworkdir} + +# the path to cgcs-patch needs to be updated to sw-patch +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + -e{[tox]stxdir}/config/sysinv/sysinv/sysinv + -e{[tox]stxdir}/config/tsconfig/tsconfig + -e{[tox]stxdir}/fault/fm-api/source + -e{[tox]stxdir}/fault/python-fmclient/fmclient + -e{[tox]stxdir}/utilities/ceph/python-cephclient/python-cephclient + -e{[tox]stxdir}/update/sw-patch/cgcs-patch + + +commands = + find . -type f -name "*.pyc" -delete + +[flake8] +exclude = build,dist,tools,.eggs +max-line-length=120 + +[testenv:flake8] +basepython = python3 +deps = -r{toxinidir}/test-requirements.txt +commands = + flake8 {posargs} . + +[testenv:py39] +basepython = python3.9 +commands = + {[testenv]commands} + stestr run {posargs} + stestr slowest + +[testenv:pep8] +deps = {[testenv:flake8]deps} +commands = {[testenv:flake8]commands} + +[testenv:venv] +commands = {posargs} + +[bandit] +# Add bandit configuration here + +[testenv:bandit] +deps = -r{toxinidir}/test-requirements.txt +commands = bandit --ini tox.ini -n 5 -r k8sapp_metrics_server + +[testenv:pylint] +deps = {[testenv]deps} +commands = + pylint {posargs} k8sapp_metrics_server --rcfile=./pylint.rc + +[testenv:cover] +deps = {[testenv]deps} +setenv = {[testenv]setenv} + PYTHON=coverage run --parallel-mode + +commands = + {[testenv]commands} + coverage erase + stestr run {posargs} + coverage combine + coverage html -d cover + coverage xml -o cover/coverage.xml + coverage report + +[testenv:pip-missing-reqs] +# do not install test-requirements as that will pollute the virtualenv for +# determining missing packages +# this also means that pip-missing-reqs must be installed separately, outside +# of the requirements.txt files +deps = pip_missing_reqs + -rrequirements.txt +commands=pip-missing-reqs -d --ignore-file=/k8sapp_metrics_server/tests k8sapp_metrics_server diff --git a/python3-k8sapp-metrics-server/k8sapp_metrics_server/upper-constraints.txt b/python3-k8sapp-metrics-server/k8sapp_metrics_server/upper-constraints.txt new file mode 100644 index 0000000..9c30188 --- /dev/null +++ b/python3-k8sapp-metrics-server/k8sapp_metrics_server/upper-constraints.txt @@ -0,0 +1 @@ +# Override upstream constraints based on StarlingX load diff --git a/stx-metrics-server-helm/debian/deb_folder/control b/stx-metrics-server-helm/debian/deb_folder/control index 9cfca9c..a1ce557 100644 --- a/stx-metrics-server-helm/debian/deb_folder/control +++ b/stx-metrics-server-helm/debian/deb_folder/control @@ -3,10 +3,10 @@ Section: libs Priority: optional Maintainer: StarlingX Developers Build-Depends: debhelper-compat (= 13), - chartmuseum, helm, - procps, - metrics-server-helm + metrics-server-helm, + python3-k8sapp-metrics-server, + python3-k8sapp-metrics-server-wheels Standards-Version: 4.5.1 Homepage: https://www.starlingx.io diff --git a/stx-metrics-server-helm/debian/deb_folder/rules b/stx-metrics-server-helm/debian/deb_folder/rules index 66235d8..729957e 100644 --- a/stx-metrics-server-helm/debian/deb_folder/rules +++ b/stx-metrics-server-helm/debian/deb_folder/rules @@ -41,6 +41,10 @@ override_dh_auto_build: sed -i 's/@APP_VERSION@/$(APP_VERSION)/g' $(STAGING_FLUXCD)/metadata.yaml sed -i 's/@HELM_REPO@/$(HELM_REPO)/g' $(STAGING_FLUXCD)/metadata.yaml + # Copy the plugins: installed in the buildroot + mkdir -p $(STAGING_FLUXCD)/plugins + cp /plugins/*.whl $(STAGING_FLUXCD)/plugins + # Package fluxcd cp -R fluxcd-manifests $(STAGING_FLUXCD)/ @@ -59,4 +63,3 @@ override_dh_auto_install: override_dh_auto_test: override_dh_usrlocal: - diff --git a/tox.ini b/tox.ini index e3cda87..44d9d4a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,14 @@ [tox] envlist = linters -minversion = 2.3 +minversion = 2.9 skipsdist = True sitepackages=False [testenv] -install_command = pip install -U {opts} {packages} +basepython = python3 +install_command = pip install -U \ + {opts} {packages} \ + -c{env:TOX_CONSTRAINTS_FILE:https://opendev.org/starlingx/root/raw/branch/master/build-tools/requirements/debian/upper-constraints.txt} setenv = VIRTUAL_ENV={envdir} OS_STDOUT_CAPTURE=1 @@ -33,3 +36,11 @@ commands = [testenv:linters] commands = {[testenv:bashate]commands} + +[testenv:flake8] +basepython = python3 +description = Dummy environment to allow flake8 to be run in subdir tox + +[testenv:pylint] +basepython = python3 +description = Dummy environment to allow pylint to be run in subdir tox