@@ -435,6 +435,10 @@ func (cm *CollectorManager) CollectContainerEvents(id *ContainerId) {
435
435
if containerState .attached {
436
436
appProfile .ObjectMeta .Labels = map [string ]string {"kapprofiler.kubescape.io/partial" : "true" }
437
437
}
438
+ // Check if we have over the limit of open events, if so, mark as failed.
439
+ if len (containerProfile .Opens ) >= MaxOpenEvents {
440
+ appProfile .ObjectMeta .Labels = map [string ]string {"kapprofiler.kubescape.io/failed" : "true" }
441
+ }
438
442
appProfileRawNew , err := runtime .DefaultUnstructuredConverter .ToUnstructured (appProfile )
439
443
if err != nil {
440
444
log .Printf ("error converting application profile: %s\n " , err )
@@ -467,6 +471,16 @@ func (cm *CollectorManager) CollectContainerEvents(id *ContainerId) {
467
471
return
468
472
}
469
473
474
+ // Check if we have over the limit of open events, if so, mark as failed.
475
+ if len (containerProfile .Opens ) >= MaxOpenEvents {
476
+ // Mark as failed
477
+ _ , err = cm .dynamicClient .Resource (AppProfileGvr ).Namespace (id .Namespace ).Patch (context .Background (),
478
+ appProfileName , apitypes .MergePatchType , []byte ("{\" metadata\" :{\" labels\" :{\" kapprofiler.kubescape.io/failed\" :\" true\" }}}" ), v1.PatchOptions {})
479
+ if err != nil {
480
+ log .Printf ("error patching application profile: %s\n " , err )
481
+ }
482
+ }
483
+
470
484
// Add the container profile into the application profile. If the container profile already exists, it will be merged.
471
485
existingApplicationProfileObject := & ApplicationProfile {}
472
486
err = runtime .DefaultUnstructuredConverter .FromUnstructured (existingApplicationProfile .Object , existingApplicationProfileObject )
0 commit comments