-
Notifications
You must be signed in to change notification settings - Fork 90
/
gather_openshift_sdn_logs.go
79 lines (70 loc) · 2.13 KB
/
gather_openshift_sdn_logs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// nolint: dupl
package clusterconfig
import (
"context"
"k8s.io/client-go/kubernetes"
"github.com/openshift/insights-operator/pkg/gatherers/common"
"github.com/openshift/insights-operator/pkg/record"
)
// GatherOpenshiftSDNLogs Collects logs from pods in `openshift-sdn` namespace with following substrings:
// - "Got OnEndpointsUpdate for unknown Endpoints",
// - "Got OnEndpointsDelete for unknown Endpoints",
// - "Unable to update proxy firewall for policy",
// - "Failed to update proxy firewall for policy",
//
// ### API Reference
// - https://github.com/kubernetes/client-go/blob/master/kubernetes/typed/core/v1/pod_expansion.go#L48
// - https://docs.openshift.com/container-platform/4.6/rest_api/workloads_apis/pod-core-v1.html#apiv1namespacesnamespacepodsnamelog
//
// ### Sample data
// - docs/insights-archive-sample/config/pod/openshift-sdn/logs/sdn-f2694/errors.log
//
// ### Location in archive
// - `config/pod/openshift-sdn/logs/{name}/errors.log`
//
// ### Config ID
// `clusterconfig/openshift_sdn_logs`
//
// ### Released version
// - 4.7.0
//
// ### Backported versions
// - 4.6.19+
//
// ### Changes
// None
func (g *Gatherer) GatherOpenshiftSDNLogs(ctx context.Context) ([]record.Record, []error) {
containersFilter := common.LogContainersFilter{
Namespace: "openshift-sdn",
LabelSelector: "app=sdn",
}
gatherKubeClient, err := kubernetes.NewForConfig(g.gatherProtoKubeConfig)
if err != nil {
return nil, []error{err}
}
coreClient := gatherKubeClient.CoreV1()
records, err := common.CollectLogsFromContainers(
ctx,
coreClient,
containersFilter,
getGatherOpenshiftSDNLogsMessageFilter(),
nil,
)
if err != nil {
return nil, []error{err}
}
return records, nil
}
func getGatherOpenshiftSDNLogsMessageFilter() common.LogMessagesFilter {
return common.LogMessagesFilter{
MessagesToSearch: []string{
"Got OnEndpointsUpdate for unknown Endpoints",
"Got OnEndpointsDelete for unknown Endpoints",
"Unable to update proxy firewall for policy",
"Failed to update proxy firewall for policy",
},
IsRegexSearch: false,
SinceSeconds: logDefaultSinceSeconds,
LimitBytes: logDefaultLimitBytes,
}
}