Merge "Fix delete process to apps that have charts disabled"
This commit is contained in:
commit
c24d0950bc
@ -1829,6 +1829,7 @@ APP_FLUXCD_MANIFEST_DIR = 'fluxcd-manifests'
|
|||||||
APP_FLUXCD_BASE_PATH = os.path.join(tsc.PLATFORM_PATH, 'fluxcd')
|
APP_FLUXCD_BASE_PATH = os.path.join(tsc.PLATFORM_PATH, 'fluxcd')
|
||||||
APP_FLUXCD_DATA_PATH = os.path.join(APP_FLUXCD_BASE_PATH, tsc.SW_VERSION)
|
APP_FLUXCD_DATA_PATH = os.path.join(APP_FLUXCD_BASE_PATH, tsc.SW_VERSION)
|
||||||
APP_ROOT_KUSTOMIZE_FILE = 'kustomization.yaml'
|
APP_ROOT_KUSTOMIZE_FILE = 'kustomization.yaml'
|
||||||
|
APP_ROOT_KUSTOMIZE_ORIG_FILE = 'kustomization-orig.yaml'
|
||||||
APP_HELMREPOSITORY_FILE = "helmrepository.yaml"
|
APP_HELMREPOSITORY_FILE = "helmrepository.yaml"
|
||||||
APP_BASE_HELMREPOSITORY_FILE = os.path.join("base", APP_HELMREPOSITORY_FILE)
|
APP_BASE_HELMREPOSITORY_FILE = os.path.join("base", APP_HELMREPOSITORY_FILE)
|
||||||
APP_RELEASE_CLEANUP_FILE = 'helmrelease_cleanup.yaml'
|
APP_RELEASE_CLEANUP_FILE = 'helmrelease_cleanup.yaml'
|
||||||
|
@ -1189,10 +1189,7 @@ class AppOperator(object):
|
|||||||
LOG.error(e)
|
LOG.error(e)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def _get_list_of_charts(self, app):
|
def _get_list_of_charts(self, app, include_disabled=False):
|
||||||
return self._get_list_of_charts_fluxcd(app.sync_fluxcd_manifest)
|
|
||||||
|
|
||||||
def _get_list_of_charts_fluxcd(self, manifest):
|
|
||||||
"""Get the charts information from the manifest directory
|
"""Get the charts information from the manifest directory
|
||||||
|
|
||||||
The following chart data for each chart in the manifest file
|
The following chart data for each chart in the manifest file
|
||||||
@ -1202,11 +1199,23 @@ class AppOperator(object):
|
|||||||
- namespace
|
- namespace
|
||||||
- location
|
- location
|
||||||
- release
|
- release
|
||||||
|
|
||||||
|
:param app: application
|
||||||
|
:param include_disabled: boolean value to add disabled charts on function return
|
||||||
|
|
||||||
|
:return: Array with chart object for each chart present in the application
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
manifest = app.sync_fluxcd_manifest
|
||||||
helmrepo_path = os.path.join(manifest, "base", "helmrepository.yaml")
|
helmrepo_path = os.path.join(manifest, "base", "helmrepository.yaml")
|
||||||
|
|
||||||
|
if include_disabled:
|
||||||
|
app_root_kustomize_file = constants.APP_ROOT_KUSTOMIZE_ORIG_FILE
|
||||||
|
else:
|
||||||
|
app_root_kustomize_file = constants.APP_ROOT_KUSTOMIZE_FILE
|
||||||
|
|
||||||
root_kustomization_path = os.path.join(
|
root_kustomization_path = os.path.join(
|
||||||
manifest, constants.APP_ROOT_KUSTOMIZE_FILE)
|
manifest, app_root_kustomize_file)
|
||||||
for f in (helmrepo_path, root_kustomization_path):
|
for f in (helmrepo_path, root_kustomization_path):
|
||||||
if not os.path.isfile(f):
|
if not os.path.isfile(f):
|
||||||
raise exception.SysinvException(_(
|
raise exception.SysinvException(_(
|
||||||
@ -3205,7 +3214,7 @@ class AppOperator(object):
|
|||||||
self._plugins.deactivate_plugins(app)
|
self._plugins.deactivate_plugins(app)
|
||||||
|
|
||||||
self._dbapi.kube_app_destroy(app.name)
|
self._dbapi.kube_app_destroy(app.name)
|
||||||
app.charts = self._get_list_of_charts(app)
|
app.charts = self._get_list_of_charts(app, include_disabled=True)
|
||||||
self._cleanup(app)
|
self._cleanup(app)
|
||||||
self._utils._patch_report_app_dependencies(app.name + '-' + app.version)
|
self._utils._patch_report_app_dependencies(app.name + '-' + app.version)
|
||||||
# One last check of app alarm, should be no-op unless the
|
# One last check of app alarm, should be no-op unless the
|
||||||
|
@ -297,19 +297,23 @@ def get_chart_tarball_path(repo_path, chart_name, chart_version):
|
|||||||
:param repo_path: Filesystem path to the Helm repository
|
:param repo_path: Filesystem path to the Helm repository
|
||||||
:param chart_name: Name of the Helm chart
|
:param chart_name: Name of the Helm chart
|
||||||
:param chart_version: Version of the Helm chart
|
:param chart_version: Version of the Helm chart
|
||||||
:return: string
|
:return: String with full path of the chart tarball in the repository if a
|
||||||
Full path of the chart tarball in the repository if a
|
|
||||||
matching chart/version is found. Otherwise returns None.
|
matching chart/version is found. Otherwise returns None.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
repo_index_file = os.path.join(repo_path, "index.yaml")
|
repo_index_file = os.path.join(repo_path, "index.yaml")
|
||||||
with io.open(repo_index_file, "r", encoding="utf-8") as f:
|
with io.open(repo_index_file, "r", encoding="utf-8") as f:
|
||||||
root_index_yaml = next(yaml.safe_load_all(f))
|
root_index_yaml = next(yaml.safe_load_all(f))
|
||||||
chart_versions = root_index_yaml["entries"][chart_name]
|
if chart_name in root_index_yaml["entries"]:
|
||||||
|
chart_versions = root_index_yaml["entries"][chart_name]
|
||||||
|
|
||||||
for chart in chart_versions:
|
for chart in chart_versions:
|
||||||
if chart["version"] == chart_version and len(chart["urls"]) > 0:
|
if chart["version"] == chart_version and len(chart["urls"]) > 0:
|
||||||
return os.path.join(repo_path, chart["urls"][0])
|
return os.path.join(repo_path, chart["urls"][0])
|
||||||
|
else:
|
||||||
|
LOG.warning("Chart {} not found in {}."
|
||||||
|
.format(chart_name, repo_index_file))
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def index_repo(repo_path):
|
def index_repo(repo_path):
|
||||||
|
Loading…
Reference in New Issue
Block a user