From e7f8d9e0aeebefe2538f61bac1adfa96ff7aaf69 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Tue, 27 Aug 2019 12:37:45 -0400 Subject: [PATCH] stx-monitor Application Flexible Config and Upgrade Add enhancements to the stx-monitor infrastructure and monitoring application to expand flexible configuration and upgrade capabilities. Story: 2005733 Task: 36387 Change-Id: I11cef36f416a1a1b1fd813c0c06f6c7a20a19a2a Signed-off-by: Kevin Smith --- .../manifests/monitor_manifest.yaml | 13 +++- sysinv/sysinv/sysinv/setup.cfg | 2 + sysinv/sysinv/sysinv/sysinv/common/utils.py | 9 +++ .../sysinv/sysinv/sysinv/conductor/manager.py | 32 ++++++++++ sysinv/sysinv/sysinv/sysinv/helm/elastic.py | 23 +++++++ sysinv/sysinv/sysinv/sysinv/helm/logstash.py | 2 + .../sysinv/sysinv/helm/manifest_monitor.py | 61 +++++++++++++++++++ sysinv/sysinv/sysinv/sysinv/puppet/monitor.py | 33 ++++++++++ 8 files changed, 173 insertions(+), 2 deletions(-) create mode 100644 sysinv/sysinv/sysinv/sysinv/helm/manifest_monitor.py create mode 100644 sysinv/sysinv/sysinv/sysinv/puppet/monitor.py diff --git a/kubernetes/applications/stx-monitor/stx-monitor-helm/stx-monitor-helm/manifests/monitor_manifest.yaml b/kubernetes/applications/stx-monitor/stx-monitor-helm/stx-monitor-helm/manifests/monitor_manifest.yaml index 70596ad330..fbcbe056ea 100644 --- a/kubernetes/applications/stx-monitor/stx-monitor-helm/stx-monitor-helm/manifests/monitor_manifest.yaml +++ b/kubernetes/applications/stx-monitor/stx-monitor-helm/stx-monitor-helm/manifests/monitor_manifest.yaml @@ -107,6 +107,13 @@ data: path: /stx-elasticsearch-client(/|$)(.*) hosts: - "" + master: + updateStrategy: + type: "RollingUpdate" + data: + terminationGracePeriodSeconds: 240 + updateStrategy: + type: "RollingUpdate" source: type: tar location: http://172.17.0.1:8080/helm_charts/starlingx/elasticsearch-1.24.0.tgz @@ -407,6 +414,8 @@ data: elastic-controller: "enabled" elasticsearch: host: stx-elasticsearch-client + config: + elasticsearch.path: "" outputs: main: |- output { @@ -414,14 +423,14 @@ data: #stdout { codec => rubydebug } if [type] == "collectd" { elasticsearch { - hosts => ["${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}"] + hosts => ["${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}${ELASTICSEARCH_PATH}"] manage_template => false index => "collectd" } } if [type] == "beats" { elasticsearch { - hosts => ["${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}"] + hosts => ["${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}${ELASTICSEARCH_PATH}"] manage_template => false index => "%{[@metadata][beat]}-%{[@metadata][version]}" } diff --git a/sysinv/sysinv/sysinv/setup.cfg b/sysinv/sysinv/sysinv/setup.cfg index ccc3c764f8..418744f63a 100644 --- a/sysinv/sysinv/sysinv/setup.cfg +++ b/sysinv/sysinv/sysinv/setup.cfg @@ -61,6 +61,7 @@ systemconfig.puppet_plugins = 034_barbican = sysinv.puppet.barbican:BarbicanPuppet 035_dockerdistribution = sysinv.puppet.dockerdistribution:DockerDistributionPuppet 036_pciirqaffinity = sysinv.puppet.pci_irq_affinity:PciIrqAffinityPuppet + 037_monitor = sysinv.puppet.monitor:MonitorPuppet 099_service_parameter = sysinv.puppet.service_parameter:ServiceParamPuppet systemconfig.helm_applications = @@ -116,6 +117,7 @@ systemconfig.armada.manifest_ops = generic = sysinv.helm.manifest_generic:GenericArmadaManifestOperator stx-openstack = sysinv.helm.manifest_openstack:OpenstackArmadaManifestOperator platform-integ-apps = sysinv.helm.manifest_platform:PlatformArmadaManifestOperator + stx-monitor = sysinv.helm.manifest_monitor:MonitorArmadaManifestOperator sysinv.agent.lldp.drivers = lldpd = sysinv.agent.lldp.drivers.lldpd.driver:SysinvLldpdAgentDriver diff --git a/sysinv/sysinv/sysinv/sysinv/common/utils.py b/sysinv/sysinv/sysinv/sysinv/common/utils.py index a5ec6ed891..bb4fb5fce7 100644 --- a/sysinv/sysinv/sysinv/sysinv/common/utils.py +++ b/sysinv/sysinv/sysinv/sysinv/common/utils.py @@ -1821,6 +1821,15 @@ def is_openstack_applied(dbapi): return False +def is_monitor_applied(dbapi): + """ Checks whether the Monitor application is applied successfully. """ + try: + monitor_app = dbapi.kube_app_get(constants.HELM_APP_MONITOR) + return monitor_app.active + except exception.KubeAppNotFound: + return False + + def is_url(url_str): try: URLValidator()(url_str) diff --git a/sysinv/sysinv/sysinv/sysinv/conductor/manager.py b/sysinv/sysinv/sysinv/sysinv/conductor/manager.py index d6b119df49..895434d304 100644 --- a/sysinv/sysinv/sysinv/sysinv/conductor/manager.py +++ b/sysinv/sysinv/sysinv/sysinv/conductor/manager.py @@ -99,6 +99,7 @@ from sysinv.openstack.common import uuidutils from sysinv.openstack.common.gettextutils import _ from sysinv.puppet import common as puppet_common from sysinv.puppet import puppet +from sysinv.helm import common as helm_common from sysinv.helm import helm from sysinv.helm import utils as helm_utils @@ -6216,6 +6217,20 @@ class ConductorManager(service.PeriodicService): LOG.error("PART Unexpected Error.") self.dbapi.partition_update(partition_data['uuid'], part_updates) + def _update_config_for_stx_monitor(self, context): + """ Update config applicable to stx-monitor app. """ + personalities = [constants.CONTROLLER, constants.WORKER] + + config_uuid = self._config_update_hosts(context, personalities) + config_dict = { + "personalities": personalities, + "classes": ['platform::collectd::restart'] + } + + self._config_apply_runtime_manifest(context, + config_uuid, + config_dict) + def _update_vim_config(self, context): """ Update the VIM's configuration. """ personalities = [constants.CONTROLLER] @@ -10228,6 +10243,14 @@ class ConductorManager(service.PeriodicService): # the prior apply state, update the ceph config self._update_radosgw_config(context) + if constants.HELM_APP_MONITOR == appname and app_applied: + logstash_active = cutils.is_chart_enabled(self.dbapi, constants.HELM_APP_MONITOR, + helm_common.HELM_CHART_LOGSTASH, + helm_common.HELM_NS_MONITOR) + + if logstash_active: + self._update_config_for_stx_monitor(context) + return app_applied def perform_app_update(self, context, from_rpc_app, to_rpc_app, tarfile, operation): @@ -10266,6 +10289,15 @@ class ConductorManager(service.PeriodicService): self._update_vim_config(context) self._update_pciirqaffinity_config(context) self._update_radosgw_config(context) + + if constants.HELM_APP_MONITOR == appname and app_removed: + logstash_active = cutils.is_chart_enabled(self.dbapi, constants.HELM_APP_MONITOR, + helm_common.HELM_CHART_LOGSTASH, + helm_common.HELM_NS_MONITOR) + + if logstash_active: + self._update_config_for_stx_monitor(context) + return app_removed def perform_app_abort(self, context, rpc_app): diff --git a/sysinv/sysinv/sysinv/sysinv/helm/elastic.py b/sysinv/sysinv/sysinv/sysinv/helm/elastic.py index 37d11395af..2da79edfd8 100644 --- a/sysinv/sysinv/sysinv/sysinv/helm/elastic.py +++ b/sysinv/sysinv/sysinv/sysinv/helm/elastic.py @@ -23,3 +23,26 @@ class ElasticBaseHelm(base.BaseHelm): def get_namespaces(self): return self.SUPPORTED_NAMESPACES + + def _is_enabled(self, app_name, chart_name, namespace): + """ + Check if the chart is enable at a system level + + :param app_name: Application name + :param chart_name: Chart supplied with the application + :param namespace: Namespace where the chart will be executed + + Returns true by default if an exception occurs as most charts are + enabled. + """ + return super(ElasticBaseHelm, self)._is_enabled( + app_name, chart_name, namespace) + + def execute_manifest_updates(self, operator): + # On application load this chart is enabled. Only disable if specified + # by the user + if not self._is_enabled(operator.APP, self.CHART, + common.HELM_NS_MONITOR): + operator.chart_group_chart_delete( + operator.CHART_GROUPS_LUT[self.CHART], + operator.CHARTS_LUT[self.CHART]) diff --git a/sysinv/sysinv/sysinv/sysinv/helm/logstash.py b/sysinv/sysinv/sysinv/sysinv/helm/logstash.py index 942d4ecc2a..59a087ff46 100644 --- a/sysinv/sysinv/sysinv/sysinv/helm/logstash.py +++ b/sysinv/sysinv/sysinv/sysinv/helm/logstash.py @@ -25,6 +25,8 @@ class LogstashHelm(elastic.ElasticBaseHelm): 'persistence': { 'storageClass': 'general', 'size': "20Gi"}, + 'config': { + 'elasticsearch.path': ""}, } } diff --git a/sysinv/sysinv/sysinv/sysinv/helm/manifest_monitor.py b/sysinv/sysinv/sysinv/sysinv/helm/manifest_monitor.py new file mode 100644 index 0000000000..1479060344 --- /dev/null +++ b/sysinv/sysinv/sysinv/sysinv/helm/manifest_monitor.py @@ -0,0 +1,61 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# +# Copyright (c) 2019 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +# All Rights Reserved. +# + +""" System inventory Armada monitor manifest operator.""" + +from sysinv.common import constants +from sysinv.helm import manifest_base as base +from sysinv.helm.logstash import LogstashHelm +from sysinv.helm.kibana import KibanaHelm +from sysinv.helm.elasticsearch import ElasticsearchHelm +from sysinv.helm.filebeat import FilebeatHelm +from sysinv.helm.metricbeat import MetricbeatHelm +from sysinv.helm.nginx_ingress import NginxIngressHelm +from sysinv.helm.kube_state_metrics import KubeStateMetricsHelm + + +class MonitorArmadaManifestOperator(base.ArmadaManifestOperator): + + APP = constants.HELM_APP_MONITOR + ARMADA_MANIFEST = 'monitor-armada-manifest' + + CHART_GROUP_NGINX = 'nginx-ingress' + CHART_GROUP_KIBANA = 'kibana' + CHART_GROUP_ELASTICSEARCH = 'elasticsearch' + CHART_GROUP_LOGSTASH = 'logstash' + CHART_GROUP_FILEBEAT = 'filebeat' + CHART_GROUP_METRICBEAT = 'metricbeat' + CHART_GROUP_KUBESTATEMETRICS = 'kube-state-metrics' + CHART_GROUPS_LUT = { + NginxIngressHelm.CHART: CHART_GROUP_NGINX, + KibanaHelm.CHART: CHART_GROUP_KIBANA, + ElasticsearchHelm.CHART: CHART_GROUP_ELASTICSEARCH, + LogstashHelm.CHART: CHART_GROUP_LOGSTASH, + FilebeatHelm.CHART: CHART_GROUP_FILEBEAT, + MetricbeatHelm.CHART: CHART_GROUP_METRICBEAT, + KubeStateMetricsHelm.CHART: CHART_GROUP_KUBESTATEMETRICS + } + + CHARTS_LUT = { + NginxIngressHelm.CHART: 'nginx-ingress', + KibanaHelm.CHART: 'kibana', + ElasticsearchHelm.CHART: 'elasticsearch', + LogstashHelm.CHART: 'logstash', + FilebeatHelm.CHART: 'filebeat', + MetricbeatHelm.CHART: 'metricbeat', + KubeStateMetricsHelm.CHART: 'kube-state-metrics' + } + + def platform_mode_manifest_updates(self, dbapi, mode): + """ Update the application manifest based on the platform + + :param dbapi: DB api object + :param mode: mode to control how to apply the application manifest + """ + pass diff --git a/sysinv/sysinv/sysinv/sysinv/puppet/monitor.py b/sysinv/sysinv/sysinv/sysinv/puppet/monitor.py new file mode 100644 index 0000000000..77876b47e5 --- /dev/null +++ b/sysinv/sysinv/sysinv/sysinv/puppet/monitor.py @@ -0,0 +1,33 @@ +# +# Copyright (c) 2019 Wind River Systems, Inc. +# +# SPDX-License-Identifier: Apache-2.0 +# +from sysinv.common import constants +from sysinv.common import utils +from sysinv.helm import common as helm_common +from sysinv.puppet import base + + +class MonitorPuppet(base.BasePuppet): + """Class to encapsulate elastic monitor configuration""" + + LOGSTASH_COLLECTD_PORT = "31005" + + def get_system_config(self): + + config = {} + if utils.is_monitor_applied(self.dbapi): + + logstash_active = utils.is_chart_enabled( + self.dbapi, constants.HELM_APP_MONITOR, + helm_common.HELM_CHART_LOGSTASH, + helm_common.HELM_NS_MONITOR) + + if logstash_active: + config = { + 'platform::collectd::params::server_port': + self.LOGSTASH_COLLECTD_PORT, + } + + return config