Standardize app configs

Fixed versioning and adjusted some build files
to bring them as close to a standard as possible.

- Removed centos files
- Added version tracking via GITREVCOUNT
- Fixed mismatch in plugin name, set to python3-k8sapp-<app>
- Standardized plugin debian files (rules, *.install)
- Plugin wheels saved to /plugin instead of /plugin/<app>

Test Plan:
PASS - Build-pkgs -a
PASS - Build-image
PASS - Install, bootstrap, unlock
PASS - app tarball contains wheel file
PASS - wheel versioning updated properly

Story: 2010542
Task: 47186

Signed-off-by: Leonardo Fagundes Luz Serrano <Leonardo.FagundesLuzSerrano@windriver.com>
Change-Id: I0e8e26d3baf364a8bd6b2e7b9e23c7dd3d91634b
This commit is contained in:
Leonardo Fagundes Luz Serrano 2022-12-21 06:46:35 -03:00
parent 75b8c3d8e4
commit f8984796e3
51 changed files with 53 additions and 291 deletions

View File

@ -52,10 +52,10 @@
- starlingx/update - starlingx/update
- starlingx/utilities - starlingx/utilities
files: files:
- python-k8sapp-ptp-notification/* - python3-k8sapp-ptp-notification/*
vars: vars:
tox_envlist: pylint tox_envlist: pylint
tox_extra_args: -c python-k8sapp-ptp-notification/k8sapp_ptp_notification/tox.ini tox_extra_args: -c python3-k8sapp-ptp-notification/k8sapp_ptp_notification/tox.ini
- secret: - secret:
name: stx-ptp-notification-armada-app-github-secret name: stx-ptp-notification-armada-app-github-secret

View File

@ -1 +0,0 @@
flock

View File

@ -1 +0,0 @@
stx-ptp-notification-helm

View File

@ -1,2 +0,0 @@
stx-ptp-notification-helm
python-k8sapp-ptp-notification

View File

@ -1,2 +0,0 @@
stx-ptp-notification-helm
python-k8sapp-ptp-notification

View File

@ -1,2 +1,2 @@
python-k8sapp-ptp-notification python3-k8sapp-ptp-notification
stx-ptp-notification-helm stx-ptp-notification-helm

View File

@ -1,23 +0,0 @@
ARG BASE
FROM ${BASE}
ARG STX_REPO_FILE=/etc/yum.repos.d/stx.repo
ENV KUBE_LATEST_VERSION="v1.23.1"
RUN set -ex ;\
yum install --disablerepo=* \
$(grep '^name=' ${STX_REPO_FILE} | awk -F '=' '{printf "--enablerepo=" $2 " "}') \
-y \
gcc python3-devel python3-pip \
&& pip3 install --upgrade pip \
&& pip3 install --user pecan \
&& pip3 install oslo-config \
&& pip3 install oslo-messaging \
&& pip3 install WSME
WORKDIR /opt/
COPY ./locationservice /opt/locationservice
RUN cd /opt/locationservice && python3 setup.py develop
CMD ["bash"]

View File

@ -1,4 +0,0 @@
BUILDER=docker
LABEL=locationservice-base
DOCKER_CONTEXT=../docker
DOCKER_FILE=./Dockerfile

View File

@ -1,24 +0,0 @@
ARG BASE
FROM ${BASE}
ARG STX_REPO_FILE=/etc/yum.repos.d/stx.repo
ENV KUBE_LATEST_VERSION="v1.23.1"
RUN set -ex ;\
yum install --disablerepo=* \
$(grep '^name=' ${STX_REPO_FILE} | awk -F '=' '{printf "--enablerepo=" $2 " "}') \
-y \
gcc python3-devel python3-pip \
&& pip3 install --upgrade pip \
&& pip3 install --user pecan \
&& pip3 install oslo-config \
&& pip3 install oslo-messaging \
&& pip3 install WSME \
&& pip3 install sqlalchemy
WORKDIR /opt/
COPY ./notificationclient-sidecar /opt/notificationclient
RUN cd /opt/notificationclient && python3 setup.py develop
CMD ["bash"]

View File

@ -1,4 +0,0 @@
BUILDER=docker
LABEL=notificationclient-base
DOCKER_CONTEXT=../docker
DOCKER_FILE=./Dockerfile

View File

@ -1,23 +0,0 @@
ARG BASE
FROM ${BASE}
ARG STX_REPO_FILE=/etc/yum.repos.d/stx.repo
ENV KUBE_LATEST_VERSION="v1.23.1"
RUN set -ex ;\
yum install --disablerepo=* \
$(grep '^name=' ${STX_REPO_FILE} | awk -F '=' '{printf "--enablerepo=" $2 " "}') \
-y \
gcc python3-devel python3-pip \
&& pip3 install --upgrade pip \
&& pip3 install --user pecan \
&& pip3 install oslo-config \
&& pip3 install oslo-messaging \
&& pip3 install WSME
WORKDIR /opt/
COPY ./ptptrackingfunction /opt/ptptrackingfunction
RUN cd /opt/ptptrackingfunction && python3 setup.py develop
CMD ["bash"]

View File

@ -1,9 +0,0 @@
SRC_DIR="k8sapp_ptp_notification"
OPT_DEP_LIST="$STX_BASE/ptp-notification-armada-app/stx-ptp-notification-helm"
# Keep the SRCREV in sync with stx-vault-helm so the app version is the
# same as the plugin version
TIS_BASE_SRCREV=c525a7fe479103bc316792c11b5289ebcca8a2a7
TIS_PATCH_VER=GITREVCOUNT

View File

@ -1,52 +0,0 @@
%global app_name ptp-notification
%global pypi_name k8sapp-ptp-notification
%global sname k8sapp_ptp_notification
Name: python-%{pypi_name}
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
Summary: StarlingX sysinv extensions: ptp-notification
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python-setuptools
BuildRequires: python-pbr
BuildRequires: python2-pip
BuildRequires: python2-wheel
%description
StarlingX sysinv extensions: PTP Notification K8S app
%prep
%setup
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
%build
export PBR_VERSION=%{version}
%{__python2} setup.py build
%py2_build_wheel
%install
export PBR_VERSION=%{version}.%{tis_patch_ver}
export SKIP_PIP_INSTALL=1
%{__python2} setup.py install --skip-build --root %{buildroot}
mkdir -p ${RPM_BUILD_ROOT}/plugins/%{app_name}
install -m 644 dist/*.whl ${RPM_BUILD_ROOT}/plugins/%{app_name}/
%files
%{python2_sitelib}/%{sname}
%{python2_sitelib}/%{sname}-*.egg-info
%package wheels
Summary: %{name} wheels
%description wheels
Contains python wheels for %{name}
%files wheels
/plugins/*

View File

@ -1,2 +0,0 @@
usr/lib/python3/dist-packages/k8sapp_ptp_notification-1.0.0.egg-info/*
usr/lib/python3/dist-packages/k8sapp_ptp_notification/*

View File

@ -1,26 +0,0 @@
#!/usr/bin/make -f
# export DH_VERBOSE = 1
export APP_NAME=ptp-notification
export PBR_VERSION=1.0.0
export PYBUILD_NAME=k8sapp-ptp-notification
export ROOT=$(CURDIR)/debian/tmp
export SKIP_PIP_INSTALL=1
%:
dh $@ --with=python3 --buildsystem=pybuild
override_dh_auto_build:
python3 setup.py build
override_dh_auto_install:
python3 setup.py install --install-layout=deb --skip-build --root $(ROOT)
python3 setup.py bdist_wheel \
--universal \
-d $(ROOT)/plugins/$(APP_NAME)
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
# (tbogue) FIXME
PYTHONDIR=$(CURDIR) stestr run || true
endif

View File

@ -1,7 +0,0 @@
---
debname: python3-k8sapp-ptp-notification
debver: 1.0-1
src_path: k8sapp_ptp_notification
revision:
dist: $STX_DIST
PKG_GITREVCOUNT: true

View File

@ -0,0 +1 @@
usr/lib/python3/dist-packages/k8sapp_*

View File

@ -0,0 +1,33 @@
#!/usr/bin/make -f
# export DH_VERBOSE = 1
export APP_NAME = ptp-notification
export PYBUILD_NAME = k8sapp-ptp-notification
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

View File

@ -0,0 +1,9 @@
---
debname: python3-k8sapp-ptp-notification
debver: 1.0-1
src_path: k8sapp_ptp_notification
revision:
dist: $STX_DIST
GITREVCOUNT:
SRC_DIR: ${MY_REPO}/stx/ptp-notification-armada-app
BASE_SRCREV: 0d723d79e5075ff6d7630240303c994278814064

View File

@ -35,5 +35,6 @@ systemconfig.helm_applications =
systemconfig.helm_plugins.ptp_notification = systemconfig.helm_plugins.ptp_notification =
001_ptp_notification = k8sapp_ptp_notification.helm.ptp_notification:PTPNotificationHelm 001_ptp_notification = k8sapp_ptp_notification.helm.ptp_notification:PTPNotificationHelm
002_ptp_notification-psp-rolebinding = k8sapp_ptp_notification.helm.psp_rolebinding:PSPRolebindingHelm 002_ptp_notification-psp-rolebinding = k8sapp_ptp_notification.helm.psp_rolebinding:PSPRolebindingHelm
[wheel]
[bdist_wheel]
universal = 1 universal = 1

View File

@ -1,11 +0,0 @@
SRC_DIR="stx-ptp-notification-helm"
OPT_DEP_LIST="$STX_BASE/ptp-notification-armada-app/python-k8sapp-ptp-notification"
COPY_LIST_TO_TAR="\
$STX_BASE/helm-charts/psp-rolebinding/psp-rolebinding/helm-charts \
"
# Keep the SRCREV in sync with python-k8sapp-ptp-notification so the app version is
# the same as the plugin version
TIS_BASE_SRCREV=c525a7fe479103bc316792c11b5289ebcca8a2a7
TIS_PATCH_VER=GITREVCOUNT

View File

@ -1,93 +0,0 @@
#
# Copyright (c) 2021-2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# Application tunables (maps to metadata)
%global app_name ptp-notification
%global helm_repo stx-platform
# Install location
%global app_folder /usr/local/share/applications/helm
# Build variables
%global helm_folder /usr/lib/helm
Summary: StarlingX PTP Notification FluxCD Helm Charts
Name: stx-ptp-notification-helm
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
Group: base
Packager: Wind River <info@windriver.com>
URL: unknown
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: helm
BuildRequires: chartmuseum
BuildRequires: python-k8sapp-ptp-notification
BuildRequires: python-k8sapp-ptp-notification-wheels
%description
StarlingX PTP Notification FluxCD Helm Charts
%prep
%setup -n %{name}-%{version}
%build
chartmuseum --debug --port=8879 --context-path='/charts' --storage="local" --storage-local-rootdir="." &
sleep 2
helm repo add local http://localhost:8879/charts
cd helm-charts
make ptp-notification
make psp-rolebinding
cd -
# Terminate helm server (the last backgrounded task)
kill %1
# Create a chart tarball compliant with sysinv kube-app.py
%define app_staging %{_builddir}/staging
%define app_tarball_fluxcd %{app_name}-%{version}-%{tis_patch_ver}.tgz
%define fluxcd_app_path %{_builddir}/%{app_tarball_fluxcd}
# Setup staging
mkdir -p %{app_staging}
cp files/metadata.yaml %{app_staging}
mkdir -p %{app_staging}/charts
cp helm-charts/*.tgz %{app_staging}/charts
# Populate metadata
sed -i 's/@APP_NAME@/%{app_name}/g' %{app_staging}/metadata.yaml
sed -i 's/@APP_VERSION@/%{version}-%{tis_patch_ver}/g' %{app_staging}/metadata.yaml
sed -i 's/@HELM_REPO@/%{helm_repo}/g' %{app_staging}/metadata.yaml
# Copy the plugins: installed in the buildroot
mkdir -p %{app_staging}/plugins
cp /plugins/%{app_name}/*.whl %{app_staging}/plugins
# package fluxcd
cp -R fluxcd-manifests %{app_staging}/
# calculate checksum of all files in app_staging
cd %{app_staging}
find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5
tar -zcf %fluxcd_app_path -C %{app_staging}/ .
cd -
# Cleanup staging
rm -fr %{app_staging}
%install
install -d -m 755 %{buildroot}/%{app_folder}
install -p -D -m 755 %fluxcd_app_path %{buildroot}/%{app_folder}
%files
%defattr(-,root,root,-)
%{app_folder}/%{app_tarball_fluxcd}

View File

@ -45,7 +45,7 @@ override_dh_auto_build:
# Copy the plugins: installed in the buildroot # Copy the plugins: installed in the buildroot
mkdir -p $(STAGING)/plugins mkdir -p $(STAGING)/plugins
cp /plugins/$(APP_NAME)/*.whl $(STAGING)/plugins cp /plugins/*.whl $(STAGING)/plugins
# Prepare staging for fluxcd package # Prepare staging for fluxcd package
cp -R fluxcd-manifests $(STAGING)/ cp -R fluxcd-manifests $(STAGING)/

View File

@ -6,4 +6,6 @@ src_files:
- ${MY_REPO}/stx/helm-charts/psp-rolebinding/psp-rolebinding - ${MY_REPO}/stx/helm-charts/psp-rolebinding/psp-rolebinding
revision: revision:
dist: $STX_DIST dist: $STX_DIST
PKG_GITREVCOUNT: true GITREVCOUNT:
SRC_DIR: ${MY_REPO}/stx/ptp-notification-armada-app
BASE_SRCREV: 0d723d79e5075ff6d7630240303c994278814064