Skip to content

Commit

Permalink
Fix elasticsearch-operator deprecated in stable-5.9 (#142)
Browse files Browse the repository at this point in the history
* Fix elasticsearch-operator deprecated in stable-5.9

* Fix elasticsearch-operator deprecated in Logging 5.9

There is no 5.9 channel of Elasticsearch operator.
  • Loading branch information
DebakelOrakel authored Jul 22, 2024
1 parent c259a8d commit 701e7e5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
13 changes: 3 additions & 10 deletions component/alertrules.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 +
Expand All @@ -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, ''),
}
6 changes: 5 additions & 1 deletion component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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+: {
Expand Down
26 changes: 26 additions & 0 deletions component/utils.libsonnet
Original file line number Diff line number Diff line change
@@ -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,
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ metadata:
name: elasticsearch-operator
namespace: openshift-operators-redhat
spec:
channel: stable-5.9
channel: stable-5.8
config:
resources:
limits:
Expand Down

0 comments on commit 701e7e5

Please sign in to comment.