Skip to content

Commit db02503

Browse files
authored
CI fix - exit lapi during hub tests + another bug(#4202)
* CI fix - exit lapi during hub tests * pass StateDumper instead of BucketOverflows
1 parent 9ee3a13 commit db02503

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

cmd/crowdsec/crowdsec.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"strconv"
7+
"os"
78
"time"
89

910
log "github.com/sirupsen/logrus"
@@ -97,12 +98,12 @@ func startHeartBeat(ctx context.Context, _ *csconfig.Config, apiClient *apiclien
9798
apiClient.HeartBeat.StartHeartBeat(ctx)
9899
}
99100

100-
func startOutputRoutines(ctx context.Context, cConfig *csconfig.Config, parsers *parser.Parsers, apiClient *apiclient.ApiClient, stageCollector *parser.StageParseCollector, bucketOverflows []pipeline.Event) {
101+
func startOutputRoutines(ctx context.Context, cConfig *csconfig.Config, parsers *parser.Parsers, apiClient *apiclient.ApiClient, sd *StateDumper) {
101102
for idx := range cConfig.Crowdsec.OutputRoutinesCount {
102103
log.WithField("idx", idx).Info("Starting output routine")
103104
outputsTomb.Go(func() error {
104105
defer trace.CatchPanic("crowdsec/runOutput/"+strconv.Itoa(idx))
105-
return runOutput(ctx, inEvents, outEvents, buckets, *parsers.PovfwCtx, parsers.Povfwnodes, apiClient, stageCollector, bucketOverflows)
106+
return runOutput(ctx, inEvents, outEvents, buckets, *parsers.PovfwCtx, parsers.Povfwnodes, apiClient, sd)
106107
})
107108
}
108109
}
@@ -157,7 +158,7 @@ func runCrowdsec(
157158

158159
startHeartBeat(ctx, cConfig, apiClient)
159160

160-
startOutputRoutines(ctx, cConfig, parsers, apiClient, sd.StageParse, sd.BucketOverflows)
161+
startOutputRoutines(ctx, cConfig, parsers, apiClient, sd)
161162

162163
if err := startLPMetrics(ctx, cConfig, apiClient, hub, datasources); err != nil {
163164
return err
@@ -222,7 +223,7 @@ func serveCrowdsec(
222223
log.Fatal(err)
223224
}
224225

225-
return nil
226+
os.Exit(0)
226227
}
227228

228229
return nil

cmd/crowdsec/output.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ func runOutput(
6060
postOverflowCTX parser.UnixParserCtx,
6161
postOverflowNodes []parser.Node,
6262
client *apiclient.ApiClient,
63-
stageCollector *parser.StageParseCollector,
64-
bucketOverflows []pipeline.Event,
63+
sd *StateDumper,
6564
) error {
6665
var (
6766
cache []pipeline.RuntimeAlert
@@ -114,7 +113,7 @@ func runOutput(
114113
}
115114

116115
/* process post overflow parser nodes */
117-
event, err := parser.Parse(postOverflowCTX, event, postOverflowNodes, stageCollector)
116+
event, err := parser.Parse(postOverflowCTX, event, postOverflowNodes, sd.StageParse)
118117
if err != nil {
119118
return fmt.Errorf("postoverflow failed: %w", err)
120119
}
@@ -124,7 +123,7 @@ func runOutput(
124123
// if the Alert is nil, it's to signal bucket is ready for GC, don't track this
125124
// dump after postoveflow processing to avoid missing whitelist info
126125
if flags.DumpDir != "" && ov.Alert != nil {
127-
bucketOverflows = append(bucketOverflows, event)
126+
sd.BucketOverflows = append(sd.BucketOverflows, event)
128127
}
129128

130129
if ov.Whitelisted {

0 commit comments

Comments
 (0)