@@ -60,7 +60,7 @@ func CollectLogsFromContainers( //nolint:gocyclo
60
60
containersFilter LogContainersFilter ,
61
61
messagesFilter LogMessagesFilter ,
62
62
buildLogFileName func (namespace string , podName string , containerName string ) string ,
63
- ) ([]record.Record , error ) {
63
+ ) ([]record.Record , [] error ) {
64
64
if buildLogFileName == nil {
65
65
buildLogFileName = func (namespace string , podName string , containerName string ) string {
66
66
return fmt .Sprintf ("config/pod/%s/logs/%s/errors.log" , namespace , podName )
@@ -72,9 +72,10 @@ func CollectLogsFromContainers( //nolint:gocyclo
72
72
FieldSelector : containersFilter .FieldSelector ,
73
73
})
74
74
if err != nil {
75
- return nil , err
75
+ return nil , [] error { err }
76
76
}
77
77
78
+ var errs []error
78
79
var records []record.Record
79
80
80
81
for i := range pods .Items {
@@ -92,7 +93,7 @@ func CollectLogsFromContainers( //nolint:gocyclo
92
93
if len (containersFilter .ContainerNameRegexFilter ) > 0 {
93
94
match , err := regexp .MatchString (containersFilter .ContainerNameRegexFilter , containerName )
94
95
if err != nil {
95
- return nil , err
96
+ return nil , [] error { err }
96
97
}
97
98
if ! match {
98
99
continue
@@ -115,8 +116,8 @@ func CollectLogsFromContainers( //nolint:gocyclo
115
116
}
116
117
117
118
if containersFilter .MaxNamespaceContainers > 0 && len (records ) >= containersFilter .MaxNamespaceContainers {
118
- klog . Infof ( " Max containers per namespace reached (max: %d). Skipping %s for %s. " ,
119
- containersFilter . MaxNamespaceContainers , containerName , containersFilter .Namespace )
119
+ errs = append ( errs , fmt . Errorf ( "skipping %s for %s. Max containers per namespace reached (max: %d)" ,
120
+ containerName , containersFilter .Namespace , containersFilter . MaxNamespaceContainers ) )
120
121
continue
121
122
}
122
123
@@ -131,7 +132,7 @@ func CollectLogsFromContainers( //nolint:gocyclo
131
132
132
133
logs , err := filterLogs (ctx , request , messagesFilter .MessagesToSearch , messagesFilter .IsRegexSearch )
133
134
if err != nil {
134
- return nil , err
135
+ return nil , [] error { err }
135
136
}
136
137
137
138
if len (strings .TrimSpace (logs )) != 0 {
@@ -147,7 +148,7 @@ func CollectLogsFromContainers( //nolint:gocyclo
147
148
klog .Infof ("no pods in %v namespace were found" , containersFilter .Namespace )
148
149
}
149
150
150
- return records , nil
151
+ return records , errs
151
152
}
152
153
153
154
func filterLogs (
0 commit comments