Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix elasticsearch-operator deprecated in stable-5.9 #142

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
DebakelOrakel marked this conversation as resolved.
Show resolved Hide resolved
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
Loading