diff --git a/component/alertrules.libsonnet b/component/alertrules.libsonnet index a843b9c..6a6843d 100644 --- a/component/alertrules.libsonnet +++ b/component/alertrules.libsonnet @@ -2,6 +2,7 @@ local alertpatching = import 'lib/alert-patching.libsonnet'; local com = import 'lib/commodore.libjsonnet'; local kap = import 'lib/kapitan.libjsonnet'; local kube = import 'lib/kube.libjsonnet'; +local utils = import 'utils.libsonnet'; local inv = kap.inventory(); local params = inv.parameters.openshift4_logging; @@ -125,19 +126,11 @@ local prometheus_rules(name, groups, baseURL) = kube._Object('monitoring.coreos. // Elasticstack alerts -local isVersion58 = - local major = std.split(params.version, '.')[0]; - local minor = std.split(params.version, '.')[1]; - if major == 'master' then true - else if std.parseInt(major) >= 6 then true - else if std.parseInt(major) == 5 && std.parseInt(minor) >= 8 then true - else false; - local esStorageGroup = { name: 'elasticsearch_node_storage.alerts', rules: [ predictESStorage ], }; -local fluentdGroup = if !isVersion58 then loadFile('fluentd_prometheus_alerts.yaml')[0].groups else []; +local fluentdGroup = if !utils.isVersion58 then loadFile('fluentd_prometheus_alerts.yaml')[0].groups else []; local esGroups = loadFile('elasticsearch_operator_prometheus_alerts.yaml')[0].groups + @@ -159,5 +152,5 @@ local collectorGroups = loadFile('collector_prometheus_alerts.yaml')[0].spec.gro { [if elasticsearch.enabled then '60_elasticsearch_alerts']: prometheus_rules('syn-elasticsearch-logging-rules', esGroups, esBaseURL), [if loki.enabled then '60_lokistack_alerts']: prometheus_rules('syn-loki-logging-rules', lokiGroups, lokiBaseURL), - [if isVersion58 then '60_collector_alerts']: prometheus_rules('syn-collector-rules', collectorGroups, ''), + [if utils.isVersion58 then '60_collector_alerts']: prometheus_rules('syn-collector-rules', collectorGroups, ''), } diff --git a/component/main.jsonnet b/component/main.jsonnet index 843e178..0e3a526 100644 --- a/component/main.jsonnet +++ b/component/main.jsonnet @@ -2,6 +2,7 @@ local com = import 'lib/commodore.libjsonnet'; local kap = import 'lib/kapitan.libjsonnet'; local kube = import 'lib/kube.libjsonnet'; local operatorlib = import 'lib/openshift4-operators.libsonnet'; +local utils = import 'utils.libsonnet'; local inv = kap.inventory(); local params = inv.parameters.openshift4_logging; @@ -62,10 +63,13 @@ local lokistack = if deployLokistack then operatorlib.managedSubscription( }, }; +// With version 5.9 of the logging stack, elasticsearch is deprecated, +// this will clamp elasticsearch-operator subscription to stable-5.8. +local esChannel = if utils.isVersion59 then 'stable-5.8' else params.channel; local elasticsearch = if deployElasticsearch then operatorlib.managedSubscription( 'openshift-operators-redhat', 'elasticsearch-operator', - params.channel + esChannel ) { spec+: { config+: { diff --git a/component/utils.libsonnet b/component/utils.libsonnet new file mode 100644 index 0000000..3475786 --- /dev/null +++ b/component/utils.libsonnet @@ -0,0 +1,26 @@ +local kap = import 'lib/kapitan.libjsonnet'; +local kube = import 'lib/kube.libjsonnet'; + +local inv = kap.inventory(); +local params = inv.parameters.openshift4_logging; + +local isVersion58 = + local major = std.split(params.version, '.')[0]; + local minor = std.split(params.version, '.')[1]; + if major == 'master' then true + else if std.parseInt(major) >= 6 then true + else if std.parseInt(major) == 5 && std.parseInt(minor) >= 8 then true + else false; + +local isVersion59 = + local major = std.split(params.version, '.')[0]; + local minor = std.split(params.version, '.')[1]; + if major == 'master' then true + else if std.parseInt(major) >= 6 then true + else if std.parseInt(major) == 5 && std.parseInt(minor) >= 9 then true + else false; + +{ + isVersion58: isVersion58, + isVersion59: isVersion59, +} diff --git a/tests/golden/elasticsearch/openshift4-logging/openshift4-logging/20_subscriptions.yaml b/tests/golden/elasticsearch/openshift4-logging/openshift4-logging/20_subscriptions.yaml index 8622bd6..f78b501 100644 --- a/tests/golden/elasticsearch/openshift4-logging/openshift4-logging/20_subscriptions.yaml +++ b/tests/golden/elasticsearch/openshift4-logging/openshift4-logging/20_subscriptions.yaml @@ -29,7 +29,7 @@ metadata: name: elasticsearch-operator namespace: openshift-operators-redhat spec: - channel: stable-5.9 + channel: stable-5.8 config: resources: limits: