Skip to content

Commit

Permalink
Merge pull request #1264 from haytok/fix-messages-and-add-nil-check-i…
Browse files Browse the repository at this point in the history
…n-system-monitor

fix(monitor): fix UpdateNsKeyMap and DestroyBPFMaps functions
  • Loading branch information
daemon1024 authored Jun 13, 2023
2 parents 6864f48 + 9d0a402 commit c2f09c7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions KubeArmor/monitor/systemMonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ func (mon *SystemMonitor) initBPFMaps() error {

// DestroyBPFMaps Function
func (mon *SystemMonitor) DestroyBPFMaps() {
if mon.BpfNsVisibilityMap == nil {
return
}

err := mon.BpfNsVisibilityMap.Unpin()
if err != nil {
mon.Logger.Warnf("error unpinning bpf map kubearmor_visibility %v", err)
Expand Down Expand Up @@ -340,19 +344,19 @@ func (mon *SystemMonitor) UpdateNsKeyMap(action string, nsKey NsKey, visibility

err = visibilityMap.Put(file.Key, file.Value)
if err != nil {
mon.Logger.Warnf("Cannot update visibility map. nskey=%+v, value=%+v, scope=file", nsKey)
mon.Logger.Warnf("Cannot update visibility map. nskey=%+v, value=%+v, scope=file", nsKey, file.Value)
}
err = visibilityMap.Put(process.Key, process.Value)
if err != nil {
mon.Logger.Warnf("Cannot update visibility map. nskey=%+v, value=%+v, scope=process", nsKey)
mon.Logger.Warnf("Cannot update visibility map. nskey=%+v, value=%+v, scope=process", nsKey, process.Value)
}
err = visibilityMap.Put(network.Key, network.Value)
if err != nil {
mon.Logger.Warnf("Cannot update visibility map. nskey=%+v, value=%+v, scope=network", nsKey)
mon.Logger.Warnf("Cannot update visibility map. nskey=%+v, value=%+v, scope=network", nsKey, network.Value)
}
err = visibilityMap.Put(capability.Key, capability.Value)
if err != nil {
mon.Logger.Warnf("Cannot update visibility map. nskey=%+v, value=%+v, scope=capability", nsKey)
mon.Logger.Warnf("Cannot update visibility map. nskey=%+v, value=%+v, scope=capability", nsKey, capability.Value)
}
mon.Logger.Printf("Updated visibility map with key=%+v for cid %s", nsKey, mon.NsMap[nsKey])
} else if action == "DELETED" {
Expand Down

0 comments on commit c2f09c7

Please sign in to comment.