Skip to content

Commit acdcfc6

Browse files
authored
Gather some error messages from the kube-controller-manager containers (#596)
1 parent 9f502e2 commit acdcfc6

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

docs/gathered-data.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,22 @@ installed in the cluster
383383
* 4.10+
384384

385385

386+
## KubeControllerManagerLogs
387+
388+
collects logs from kube-controller-manager pods in the openshift-kube-controller-manager namespace with following substrings:
389+
- "Internal error occurred: error resolving resource",
390+
- "syncing garbage collector with updated resources from discovery",
391+
392+
The Kubernetes API:
393+
https://github.com/kubernetes/client-go/blob/master/kubernetes/typed/core/v1/pod_expansion.go#L48
394+
Response see:
395+
https://docs.openshift.com/container-platform/4.10/rest_api/workloads_apis/pod-v1.html#apiv1namespacesnamespacepodsnamelog
396+
397+
* Location in archive: config/pod/openshift-kube-controller-manager/logs/{pod-name}/errors.log
398+
* Since versions:
399+
* 4.11+
400+
401+
386402
## LogsOfNamespace
387403

388404
creates a gathering closure which collects logs from pods in the provided namespace
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2022-03-16T13:32:39.044141390Z I0316 13:32:39.044104 1 garbagecollector.go:210] syncing garbage collector with updated resources from discovery (attempt 1): added: [], removed: [apps.openshift.io/v1, Resource=deploymentconfigs authorization.openshift.io/v1, Resource=rolebindingrestrictions build.openshift.io/v1, Resource=buildconfigs build.openshift.io/v1, Resource=builds image.openshift.io/v1, Resource=images image.openshift.io/v1, Resource=imagestreams project.openshift.io/v1, Resource=projects quota.openshift.io/v1, Resource=clusterresourcequotas route.openshift.io/v1, Resource=routes security.openshift.io/v1, Resource=rangeallocations security.openshift.io/v1, Resource=securitycontextconstraints template.openshift.io/v1, Resource=brokertemplateinstances template.openshift.io/v1, Resource=templateinstances template.openshift.io/v1, Resource=templates]
2+
2022-03-16T13:38:09.379847879Z I0316 13:38:09.379813 1 garbagecollector.go:210] syncing garbage collector with updated resources from discovery (attempt 1): added: [apps.openshift.io/v1, Resource=deploymentconfigs authorization.openshift.io/v1, Resource=rolebindingrestrictions build.openshift.io/v1, Resource=buildconfigs build.openshift.io/v1, Resource=builds image.openshift.io/v1, Resource=images image.openshift.io/v1, Resource=imagestreams project.openshift.io/v1, Resource=projects quota.openshift.io/v1, Resource=clusterresourcequotas route.openshift.io/v1, Resource=routes security.openshift.io/v1, Resource=rangeallocations security.openshift.io/v1, Resource=securitycontextconstraints template.openshift.io/v1, Resource=brokertemplateinstances template.openshift.io/v1, Resource=templateinstances template.openshift.io/v1, Resource=templates], removed: []

pkg/gatherers/clusterconfig/clusterconfig_gatherer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ var gatheringFunctions = map[string]gathererFuncPtr{
7777
"scheduler_logs": (*Gatherer).GatherSchedulerLogs,
7878
"silenced_alerts": (*Gatherer).GatherSilencedAlerts,
7979
"image": (*Gatherer).GatherClusterImage,
80+
"kube_controller_manager_logs": (*Gatherer).GatherKubeControllerManagerLogs,
8081
}
8182

8283
func New(
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//nolint: dupl
2+
package clusterconfig
3+
4+
import (
5+
"context"
6+
7+
"k8s.io/client-go/kubernetes"
8+
9+
"github.com/openshift/insights-operator/pkg/gatherers/common"
10+
"github.com/openshift/insights-operator/pkg/record"
11+
)
12+
13+
// GatherKubeControllerManagerLogs collects logs from kube-controller-manager pods in the openshift-kube-controller-manager namespace with following substrings:
14+
// - "Internal error occurred: error resolving resource",
15+
// - "syncing garbage collector with updated resources from discovery",
16+
//
17+
// The Kubernetes API:
18+
// https://github.com/kubernetes/client-go/blob/master/kubernetes/typed/core/v1/pod_expansion.go#L48
19+
// Response see:
20+
// https://docs.openshift.com/container-platform/4.10/rest_api/workloads_apis/pod-v1.html#apiv1namespacesnamespacepodsnamelog
21+
//
22+
// * Location in archive: config/pod/openshift-kube-controller-manager/logs/{pod-name}/errors.log
23+
// * Since versions:
24+
// * 4.11+
25+
func (g *Gatherer) GatherKubeControllerManagerLogs(ctx context.Context) ([]record.Record, []error) {
26+
containersFilter := common.LogContainersFilter{
27+
Namespace: "openshift-kube-controller-manager",
28+
LabelSelector: "app=kube-controller-manager",
29+
ContainerNameRegexFilter: "kube-controller-manager",
30+
}
31+
messagesFilter := common.LogMessagesFilter{
32+
MessagesToSearch: []string{
33+
"Internal error occurred: error resolving resource",
34+
"syncing garbage collector with updated resources from discovery",
35+
},
36+
IsRegexSearch: true,
37+
SinceSeconds: logDefaultSinceSeconds,
38+
LimitBytes: 0,
39+
}
40+
41+
gatherKubeClient, err := kubernetes.NewForConfig(g.gatherProtoKubeConfig)
42+
if err != nil {
43+
return nil, []error{err}
44+
}
45+
46+
coreClient := gatherKubeClient.CoreV1()
47+
48+
records, err := common.CollectLogsFromContainers(
49+
ctx,
50+
coreClient,
51+
containersFilter,
52+
messagesFilter,
53+
nil,
54+
)
55+
if err != nil {
56+
return nil, []error{err}
57+
}
58+
59+
return records, nil
60+
}

0 commit comments

Comments
 (0)