Skip to content

Commit 2bed7f6

Browse files
authored
Merge pull request #50 from slashben/improvement/handling-profile-write-errors
Marking the profile as unsuccessful if cannot update
2 parents 0ee7be5 + c87426a commit 2bed7f6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

pkg/collector/collector.go

+22
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,28 @@ func (cm *CollectorManager) CollectContainerEvents(id *ContainerId) {
493493
v1.UpdateOptions{})
494494
if err != nil {
495495
log.Printf("error updating application profile: %s\n", err)
496+
497+
// Remove this container from the filters of the event sink so that it does not collect events for it anymore
498+
cm.eventSink.RemoveFilter(&eventsink.EventSinkFilter{EventType: tracing.AllEventType, ContainerID: id.ContainerID})
499+
// Stop tracing container
500+
cm.tracer.StopTraceContainer(id.NsMntId, id.Pid, tracing.AllEventType)
501+
502+
// Mark stop recording
503+
cm.MarkPodNotRecording(id.PodName, id.Namespace)
504+
505+
// Remove the container from the map
506+
cm.containersMutex.Lock()
507+
delete(cm.containers, *id)
508+
cm.containersMutex.Unlock()
509+
510+
// Mark pod as failed recording
511+
_, err = cm.dynamicClient.Resource(AppProfileGvr).Namespace(id.Namespace).Patch(context.Background(),
512+
appProfileName, apitypes.MergePatchType, []byte("{\"metadata\":{\"labels\":{\"kapprofiler.kubescape.io/failed\":\"true\"}}}"), v1.PatchOptions{})
513+
if err != nil {
514+
log.Printf("error patching application profile: %s\n", err)
515+
}
516+
517+
return
496518
}
497519
}
498520

0 commit comments

Comments
 (0)