Skip to content

Commit

Permalink
Merge pull request kubearmor#747 from daemon1024/fix-cri
Browse files Browse the repository at this point in the history
cri: handle bugs and edge cases
  • Loading branch information
nam-jaehyun authored Jul 4, 2022
2 parents 51241f2 + 8a0c7e2 commit 5b40a6b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 4 additions & 6 deletions KubeArmor/core/dockerHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ func (dh *DockerHandler) GetEventChannel() <-chan events.Message {

// GetAlreadyDeployedDockerContainers Function
func (dm *KubeArmorDaemon) GetAlreadyDeployedDockerContainers() {
// check if Docker exists
// check if Docker exists else instantiate
if Docker == nil {
return
Docker = NewDockerHandler()
}

if containerList, err := Docker.DockerClient.ContainerList(context.Background(), types.ContainerListOptions{}); err == nil {
Expand Down Expand Up @@ -376,11 +376,9 @@ func (dm *KubeArmorDaemon) MonitorDockerEvents() {
dm.WgDaemon.Add(1)
defer dm.WgDaemon.Done()

Docker = NewDockerHandler()

// check if Docker exists
// check if Docker exists else instantiate
if Docker == nil {
return
Docker = NewDockerHandler()
}

dm.Logger.Print("Started to monitor Docker events")
Expand Down
6 changes: 3 additions & 3 deletions KubeArmor/core/kubeArmor.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,15 +461,15 @@ func KubeArmor() {
}

// monitor containers
if strings.Contains(cfg.GlobalCfg.CRISocket, "docker") {
if strings.Contains(dm.Node.ContainerRuntimeVersion, "docker") {
// update already deployed containers
dm.GetAlreadyDeployedDockerContainers()
// monitor docker events
go dm.MonitorDockerEvents()
} else if strings.Contains(cfg.GlobalCfg.CRISocket, "containerd") {
} else if strings.Contains(dm.Node.ContainerRuntimeVersion, "containerd") {
// monitor containerd events
go dm.MonitorContainerdEvents()
} else if strings.Contains(cfg.GlobalCfg.CRISocket, "crio") {
} else if strings.Contains(dm.Node.ContainerRuntimeVersion, "crio") {
// monitor crio events
go dm.MonitorCrioEvents()
} else {
Expand Down

0 comments on commit 5b40a6b

Please sign in to comment.