Fix helm overrides merge issues

This commit addresses the issues related to merging system and user
overrides. It removes the user overrides restriction (to openstack)
as well as the need to scope the overrides in values yaml file and/or
set strings.

Tests conducted:
Stx-openstack application overrides regeneration verified with the
following user overrides:
  system helm-override-update ingress kube-system \
    --set endpoints.ingress.port.http.default=8008 \
    --set pod.replicas.error_page=2
  system helm-override-update ingress openstack \
    --set pod.replicas.ingress=2
  system helm-override-update keystone openstack \
    --set conf.keystone.DEFAULT.debug=True

Story: 2003909
Task: 28246
Task: 28248

Change-Id: Ie2ada9e84721b23c8394c6e472560696a4c72fc7
Signed-off-by: Tee Ngo <Tee.Ngo@windriver.com>
This commit is contained in:
Tee Ngo 2018-12-04 15:23:22 -05:00
parent 83c2f56bdd
commit 025a8cc03c
1 changed files with 29 additions and 14 deletions

View File

@ -8,7 +8,6 @@
from __future__ import absolute_import
import copy
import eventlet
import os
import subprocess
@ -366,19 +365,35 @@ class HelmOperator(object):
cnamespace)
for (chart_name, overrides) in iteritems(app_overrides):
if combined:
try:
db_chart = self.dbapi.helm_override_get(
chart_name, 'openstack')
user_overrides = db_chart.user_overrides
if user_overrides:
system_overrides = yaml.dump(overrides)
file_overrides = [system_overrides, user_overrides]
combined_overrides = self.merge_overrides(
file_overrides=file_overrides)
combined_overrides = yaml.load(combined_overrides)
overrides = copy.deepcopy(combined_overrides)
except exception.HelmOverrideNotFound:
pass
# The overrides at this point is the system overrides. For charts
# with multiple namespaces, the overrides would contain multiple keys,
# one for each namespace.
#
# Retrieve the user overrides of each namespace from the database
# and merge this list of user overrides if exists with the
# system overrides. Both system and user overrides contents
# are then merged based on the namespace, prepended with required
# header and written to corresponding files (<namespace>-<chart>.yaml).
file_overrides = []
for chart_namespace in overrides.keys():
try:
db_chart = self.dbapi.helm_override_get(
chart_name, chart_namespace)
db_user_overrides = db_chart.user_overrides
if db_user_overrides:
file_overrides.append(yaml.dump(
{chart_namespace: yaml.load(db_user_overrides)}))
except exception.HelmOverrideNotFound:
pass
if file_overrides:
# Use dump() instead of safe_dump() as the latter is
# not agreeable with password regex in some overrides
system_overrides = yaml.dump(overrides)
file_overrides.insert(0, system_overrides)
combined_overrides = self.merge_overrides(
file_overrides=file_overrides)
overrides = yaml.load(combined_overrides)
# If armada formatting is wanted, we need to change the
# structure of the yaml file somewhat