Skip to content

Commit d5d0030

Browse files
author
Serhii Zakharov
authored
Cluster version condition (openshift#524)
* added the package github.com/blang/semver/[email protected] * implemented the condition to check cluster's version * json schema * fixed a bug * rebased * fix the schema * changed logic creating conditional gathering functions * added archive sample file
1 parent 0dcd7f1 commit d5d0030

File tree

17 files changed

+1315
-113
lines changed

17 files changed

+1315
-113
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,106 @@
11
[
22
{
3-
"conditions": [
4-
{
5-
"type": "alert_is_firing",
6-
"params": {
7-
"name": "SamplesImagestreamImportFailing"
3+
"rule": {
4+
"conditions": [
5+
{
6+
"type": "alert_is_firing",
7+
"alert": {
8+
"name": "SamplesImagestreamImportFailing"
9+
}
10+
}
11+
],
12+
"gathering_functions": {
13+
"image_streams_of_namespace": {
14+
"namespace": "openshift-cluster-samples-operator"
15+
},
16+
"logs_of_namespace": {
17+
"namespace": "openshift-cluster-samples-operator",
18+
"tail_lines": 100
819
}
920
}
10-
],
11-
"gathering_functions": {
12-
"image_streams_of_namespace": {
13-
"namespace": "openshift-cluster-samples-operator"
14-
},
15-
"logs_of_namespace": {
16-
"namespace": "openshift-cluster-samples-operator",
17-
"tail_lines": 100
18-
}
19-
}
21+
},
22+
"errors": null,
23+
"was_triggered": true
2024
},
2125
{
22-
"conditions": [
23-
{
24-
"type": "alert_is_firing",
25-
"params": {
26-
"name": "APIRemovedInNextEUSReleaseInUse"
26+
"rule": {
27+
"conditions": [
28+
{
29+
"type": "alert_is_firing",
30+
"alert": {
31+
"name": "APIRemovedInNextEUSReleaseInUse"
32+
}
33+
}
34+
],
35+
"gathering_functions": {
36+
"api_request_counts_of_resource_from_alert": {
37+
"alert_name": "APIRemovedInNextEUSReleaseInUse"
2738
}
2839
}
29-
],
30-
"gathering_functions": {
31-
"api_request_counts_of_resource_from_alert": {
32-
"alert_name": "APIRemovedInNextEUSReleaseInUse"
33-
}
34-
}
40+
},
41+
"errors": null,
42+
"was_triggered": false
3543
},
3644
{
37-
"conditions": [
38-
{
39-
"type": "alert_is_firing",
40-
"params": {
41-
"name": "KubePodCrashLooping"
45+
"rule": {
46+
"conditions": [
47+
{
48+
"type": "alert_is_firing",
49+
"alert": {
50+
"name": "KubePodCrashLooping"
51+
}
52+
}
53+
],
54+
"gathering_functions": {
55+
"logs_of_unhealthy_pods": {
56+
"alert_name": "KubePodCrashLooping",
57+
"tail_lines": 20,
58+
"previous": true
4259
}
4360
}
44-
],
45-
"gathering_functions": {
46-
"logs_of_unhealthy_pods": {
47-
"alert_name": "KubePodCrashLooping",
48-
"tail_lines": 20,
49-
"previous": true
50-
}
51-
}
61+
},
62+
"errors": null,
63+
"was_triggered": false
5264
},
5365
{
54-
"conditions": [
55-
{
56-
"type": "alert_is_firing",
57-
"params": {
58-
"name": "KubePodNotReady"
66+
"rule": {
67+
"conditions": [
68+
{
69+
"type": "alert_is_firing",
70+
"alert": {
71+
"name": "KubePodNotReady"
72+
}
73+
}
74+
],
75+
"gathering_functions": {
76+
"logs_of_unhealthy_pods": {
77+
"alert_name": "KubePodNotReady",
78+
"tail_lines": 100,
79+
"previous": false
5980
}
6081
}
61-
],
62-
"gathering_functions": {
63-
"logs_of_unhealthy_pods": {
64-
"alert_name": "KubePodNotReady",
65-
"tail_lines": 100,
66-
"previous": false
82+
},
83+
"errors": null,
84+
"was_triggered": false
85+
},
86+
{
87+
"rule": {
88+
"conditions": [
89+
{
90+
"type": "alert_is_firing",
91+
"alert": {
92+
"name": "AlertmanagerFailedToSendAlerts"
93+
}
94+
}
95+
],
96+
"gathering_functions": {
97+
"alertmanager_logs": {
98+
"alert_name": "AlertmanagerFailedToSendAlerts",
99+
"tail_lines": 50
100+
}
67101
}
68-
}
102+
},
103+
"errors": null,
104+
"was_triggered": false
69105
}
70106
]

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/openshift/insights-operator
33
go 1.16
44

55
require (
6+
github.com/blang/semver/v4 v4.0.0
67
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da
78
github.com/google/gofuzz v1.2.0 // indirect
89
github.com/openshift/api v0.0.0-20210901140736-d8ed1449662d

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJm
7272
github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
7373
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
7474
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
75+
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
76+
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
7577
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
7678
github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
7779
github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=

pkg/gather/gather.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func CreateAllGatherers(
6060
gatherKubeConfig, gatherProtoKubeConfig, metricsGatherKubeConfig, anonymizer, controller.Interval,
6161
)
6262
workloadsGatherer := workloads.New(gatherProtoKubeConfig)
63-
conditionalGatherer := conditional.New(gatherProtoKubeConfig, metricsGatherKubeConfig)
63+
conditionalGatherer := conditional.New(gatherProtoKubeConfig, metricsGatherKubeConfig, gatherKubeConfig)
6464

6565
return []gatherers.Interface{clusterConfigGatherer, workloadsGatherer, conditionalGatherer}
6666
}

0 commit comments

Comments
 (0)