diff --git a/pkg/gatherers/clusterconfig/gather_kube_controller_manager_logs.go b/pkg/gatherers/clusterconfig/gather_kube_controller_manager_logs.go index 58ab88f7b5..d2057e5841 100644 --- a/pkg/gatherers/clusterconfig/gather_kube_controller_manager_logs.go +++ b/pkg/gatherers/clusterconfig/gather_kube_controller_manager_logs.go @@ -38,7 +38,7 @@ import ( // ### Changes // None func (g *Gatherer) GatherKubeControllerManagerLogs(ctx context.Context) ([]record.Record, []error) { - containersFilter := common.LogResourceFilter{ + containersFilter := &common.LogResourceFilter{ Namespace: "openshift-kube-controller-manager", LabelSelector: "app=kube-controller-manager", ContainerNameRegexFilter: "kube-controller-manager", @@ -65,8 +65,8 @@ func (g *Gatherer) GatherKubeControllerManagerLogs(ctx context.Context) ([]recor return records, nil } -func getKubeControllerManagerLogsMessagesFilter() common.LogMessagesFilter { - return common.LogMessagesFilter{ +func getKubeControllerManagerLogsMessagesFilter() *common.LogMessagesFilter { + return &common.LogMessagesFilter{ MessagesToSearch: []string{ "Internal error occurred: error resolving resource", "syncing garbage collector with updated resources from discovery", diff --git a/pkg/gatherers/clusterconfig/gather_openshift_apiserver_operator_logs.go b/pkg/gatherers/clusterconfig/gather_openshift_apiserver_operator_logs.go index 2e4b50b511..6d09dc815b 100644 --- a/pkg/gatherers/clusterconfig/gather_openshift_apiserver_operator_logs.go +++ b/pkg/gatherers/clusterconfig/gather_openshift_apiserver_operator_logs.go @@ -35,7 +35,7 @@ import ( // ### Changes // None func (g *Gatherer) GatherOpenShiftAPIServerOperatorLogs(ctx context.Context) ([]record.Record, []error) { - containersFilter := common.LogResourceFilter{ + containersFilter := &common.LogResourceFilter{ Namespace: "openshift-apiserver-operator", LabelSelector: "app=openshift-apiserver-operator", } @@ -61,8 +61,8 @@ func (g *Gatherer) GatherOpenShiftAPIServerOperatorLogs(ctx context.Context) ([] return records, nil } -func getAPIServerOperatorLogsMessagesFilter() common.LogMessagesFilter { - return common.LogMessagesFilter{ +func getAPIServerOperatorLogsMessagesFilter() *common.LogMessagesFilter { + return &common.LogMessagesFilter{ MessagesToSearch: []string{ "the server has received too many requests and has asked us", "because serving request timed out and response had been started", diff --git a/pkg/gatherers/clusterconfig/gather_openshift_authentication_logs.go b/pkg/gatherers/clusterconfig/gather_openshift_authentication_logs.go index ab0f5d4a51..d777d9990c 100644 --- a/pkg/gatherers/clusterconfig/gather_openshift_authentication_logs.go +++ b/pkg/gatherers/clusterconfig/gather_openshift_authentication_logs.go @@ -35,7 +35,7 @@ import ( // ### Changes // None func (g *Gatherer) GatherOpenshiftAuthenticationLogs(ctx context.Context) ([]record.Record, []error) { - containersFilter := common.LogResourceFilter{ + containersFilter := &common.LogResourceFilter{ Namespace: "openshift-authentication", LabelSelector: "app=oauth-openshift", } @@ -61,8 +61,8 @@ func (g *Gatherer) GatherOpenshiftAuthenticationLogs(ctx context.Context) ([]rec return records, nil } -func getOpenshiftAuthenticationLogsMessagesFilter() common.LogMessagesFilter { - return common.LogMessagesFilter{ +func getOpenshiftAuthenticationLogsMessagesFilter() *common.LogMessagesFilter { + return &common.LogMessagesFilter{ MessagesToSearch: []string{ "AuthenticationError: invalid resource name", }, diff --git a/pkg/gatherers/clusterconfig/gather_openshift_sdn_controller_logs.go b/pkg/gatherers/clusterconfig/gather_openshift_sdn_controller_logs.go index f89e9db9b3..863bd12b6d 100644 --- a/pkg/gatherers/clusterconfig/gather_openshift_sdn_controller_logs.go +++ b/pkg/gatherers/clusterconfig/gather_openshift_sdn_controller_logs.go @@ -46,7 +46,7 @@ import ( // ### Changes // None func (g *Gatherer) GatherOpenshiftSDNControllerLogs(ctx context.Context) ([]record.Record, []error) { - containersFilter := common.LogResourceFilter{ + containersFilter := &common.LogResourceFilter{ Namespace: "openshift-sdn", LabelSelector: "app=sdn-controller", } @@ -72,8 +72,8 @@ func (g *Gatherer) GatherOpenshiftSDNControllerLogs(ctx context.Context) ([]reco return records, nil } -func getSDNControllerLogsMessagesFilter() common.LogMessagesFilter { - return common.LogMessagesFilter{ +func getSDNControllerLogsMessagesFilter() *common.LogMessagesFilter { + return &common.LogMessagesFilter{ MessagesToSearch: []string{ `Node.+is not Ready`, `Node.+may be offline... retrying`, diff --git a/pkg/gatherers/clusterconfig/gather_openshift_sdn_logs.go b/pkg/gatherers/clusterconfig/gather_openshift_sdn_logs.go index f4b57a220a..a17ba2bed0 100644 --- a/pkg/gatherers/clusterconfig/gather_openshift_sdn_logs.go +++ b/pkg/gatherers/clusterconfig/gather_openshift_sdn_logs.go @@ -38,7 +38,7 @@ import ( // ### Changes // None func (g *Gatherer) GatherOpenshiftSDNLogs(ctx context.Context) ([]record.Record, []error) { - containersFilter := common.LogResourceFilter{ + containersFilter := &common.LogResourceFilter{ Namespace: "openshift-sdn", LabelSelector: "app=sdn", } @@ -64,8 +64,8 @@ func (g *Gatherer) GatherOpenshiftSDNLogs(ctx context.Context) ([]record.Record, return records, nil } -func getGatherOpenshiftSDNLogsMessageFilter() common.LogMessagesFilter { - return common.LogMessagesFilter{ +func getGatherOpenshiftSDNLogsMessageFilter() *common.LogMessagesFilter { + return &common.LogMessagesFilter{ MessagesToSearch: []string{ "Got OnEndpointsUpdate for unknown Endpoints", "Got OnEndpointsDelete for unknown Endpoints", diff --git a/pkg/gatherers/clusterconfig/gather_sap_vsystem_iptables_logs.go b/pkg/gatherers/clusterconfig/gather_sap_vsystem_iptables_logs.go index b927ca22a5..4a29f2a05a 100644 --- a/pkg/gatherers/clusterconfig/gather_sap_vsystem_iptables_logs.go +++ b/pkg/gatherers/clusterconfig/gather_sap_vsystem_iptables_logs.go @@ -85,7 +85,7 @@ func gatherSAPLicenseManagementLogs( var errs []error for _, item := range datahubs { - containersFilter := common.LogResourceFilter{ + containersFilter := &common.LogResourceFilter{ Namespace: item.GetNamespace(), ContainerNameRegexFilter: "^vsystem-iptables$", } @@ -107,8 +107,8 @@ func gatherSAPLicenseManagementLogs( return records, errs } -func getSAPLicenseManagementLogsMessageFilter() common.LogMessagesFilter { - return common.LogMessagesFilter{ +func getSAPLicenseManagementLogsMessageFilter() *common.LogMessagesFilter { + return &common.LogMessagesFilter{ MessagesToSearch: []string{ "can't initialize iptables table", }, diff --git a/pkg/gatherers/clusterconfig/gather_scheduler_logs.go b/pkg/gatherers/clusterconfig/gather_scheduler_logs.go index 3721787682..abed3c5ad8 100644 --- a/pkg/gatherers/clusterconfig/gather_scheduler_logs.go +++ b/pkg/gatherers/clusterconfig/gather_scheduler_logs.go @@ -46,7 +46,7 @@ func (g *Gatherer) GatherSchedulerLogs(ctx context.Context) ([]record.Record, [] func gatherSchedulerLogs(ctx context.Context, coreClient corev1client.CoreV1Interface) ([]record.Record, []error) { records, err := common.CollectLogsFromContainers(ctx, coreClient, - common.LogResourceFilter{ + &common.LogResourceFilter{ Namespace: "openshift-kube-scheduler", LabelSelector: "app=openshift-kube-scheduler", }, @@ -62,8 +62,8 @@ func gatherSchedulerLogs(ctx context.Context, coreClient corev1client.CoreV1Inte return records, nil } -func getSchedulerLogsMessagesFilter() common.LogMessagesFilter { - return common.LogMessagesFilter{ +func getSchedulerLogsMessagesFilter() *common.LogMessagesFilter { + return &common.LogMessagesFilter{ MessagesToSearch: []string{"PodTopologySpread"}, SinceSeconds: logDefaultSinceSeconds, LimitBytes: logDefaultLimitBytes, diff --git a/pkg/gatherers/common/gather_logs.go b/pkg/gatherers/common/gather_logs.go index f5604e037c..9e6f0c378a 100644 --- a/pkg/gatherers/common/gather_logs.go +++ b/pkg/gatherers/common/gather_logs.go @@ -65,8 +65,8 @@ type FilterLogOption func(line string) bool func CollectLogsFromContainers( //nolint:gocyclo ctx context.Context, coreClient v1.CoreV1Interface, - containersFilter LogResourceFilter, - messagesFilter LogMessagesFilter, + containersFilter *LogResourceFilter, + messagesFilter *LogMessagesFilter, buildLogFileName func(namespace, podName, containerName string) string, ) ([]record.Record, error) { if buildLogFileName == nil { @@ -245,7 +245,7 @@ func FilterLogFromScanner(scanner *bufio.Scanner, filter FilterLogOption, cb Fil return strings.Join(result, "\n"), nil } -func podLogOptions(containerName string, messagesFilter LogMessagesFilter) *corev1.PodLogOptions { +func podLogOptions(containerName string, messagesFilter *LogMessagesFilter) *corev1.PodLogOptions { sinceSeconds := &messagesFilter.SinceSeconds if messagesFilter.SinceSeconds == 0 { sinceSeconds = nil diff --git a/pkg/gatherers/common/gather_logs_test.go b/pkg/gatherers/common/gather_logs_test.go index 8c4f5afd1e..a1b1f24380 100644 --- a/pkg/gatherers/common/gather_logs_test.go +++ b/pkg/gatherers/common/gather_logs_test.go @@ -75,10 +75,10 @@ func testGatherLogs(t *testing.T, regexSearch bool, stringToSearch string, shoul records, err := CollectLogsFromContainers( ctx, coreClient, - LogResourceFilter{ + &LogResourceFilter{ Namespace: testPodName, }, - LogMessagesFilter{ + &LogMessagesFilter{ MessagesToSearch: []string{ stringToSearch, }, diff --git a/pkg/gatherers/conditional/gather_containers_logs.go b/pkg/gatherers/conditional/gather_containers_logs.go index 4a20ddd4ba..fa43d9b300 100644 --- a/pkg/gatherers/conditional/gather_containers_logs.go +++ b/pkg/gatherers/conditional/gather_containers_logs.go @@ -97,7 +97,7 @@ func (g *Gatherer) gatherContainersLogs( } } - logContainersFilter := common.LogResourceFilter{ + logContainersFilter := &common.LogResourceFilter{ Namespace: podNamespace, FieldSelector: fmt.Sprintf("metadata.name=%s", podName), } @@ -111,7 +111,7 @@ func (g *Gatherer) gatherContainersLogs( ctx, coreClient, logContainersFilter, - common.LogMessagesFilter{ + &common.LogMessagesFilter{ TailLines: params.TailLines, Previous: params.Previous, }, diff --git a/pkg/gatherers/conditional/gather_logs_of_namespace.go b/pkg/gatherers/conditional/gather_logs_of_namespace.go index bfe5ac0756..4602005b55 100644 --- a/pkg/gatherers/conditional/gather_logs_of_namespace.go +++ b/pkg/gatherers/conditional/gather_logs_of_namespace.go @@ -67,11 +67,11 @@ func (g *Gatherer) gatherLogsOfNamespace(ctx context.Context, namespace string, records, err := common.CollectLogsFromContainers( ctx, coreClient, - common.LogResourceFilter{ + &common.LogResourceFilter{ Namespace: namespace, MaxNamespaceContainers: 64, // arbitrary fixed value }, - common.LogMessagesFilter{ + &common.LogMessagesFilter{ TailLines: tailLines, }, func(namespace string, podName string, containerName string) string { diff --git a/pkg/gatherers/conditional/gather_pod_logs.go b/pkg/gatherers/conditional/gather_pod_logs.go index 9de9b4a52d..0973273b7c 100644 --- a/pkg/gatherers/conditional/gather_pod_logs.go +++ b/pkg/gatherers/conditional/gather_pod_logs.go @@ -29,17 +29,18 @@ func (g *Gatherer) BuildGatherPodLogs(paramsInterface interface{}) (gatherers.Ga return nil, []error{err} } coreClient := kubeClient.CoreV1() - return g.gatherPodLogs(ctx, params, coreClient) + return g.gatherPodLogs(ctx, ¶ms, coreClient) }, }, nil } -func (g *Gatherer) gatherPodLogs(ctx context.Context, params GatherPodLogsParams, coreClient v1.CoreV1Interface) ([]record.Record, []error) { +func (g *Gatherer) gatherPodLogs(ctx context.Context, params *GatherPodLogsParams, + coreClient v1.CoreV1Interface) ([]record.Record, []error) { records, err := common.CollectLogsFromContainers( ctx, coreClient, - params.ResourceFilter, - params.LogMessageFilter, + ¶ms.ResourceFilter, + ¶ms.LogMessageFilter, func(namespace string, podName string, containerName string) string { filename := "current.log" if params.LogMessageFilter.Previous {