Skip to content

Commit

Permalink
Cleanup duplicated code
Browse files Browse the repository at this point in the history
Implement Detect method of socketBasedIsolationDetector using
DetectForSocket.

Signed-off-by: Vasiliy Ulyanov <[email protected]>
  • Loading branch information
vasiliy-ul committed Dec 22, 2020
1 parent 955cc5d commit 394dcc0
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions pkg/virt-handler/isolation/isolation.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,29 +113,13 @@ func (s *socketBasedIsolationDetector) Whitelist(controller []string) PodIsolati
}

func (s *socketBasedIsolationDetector) Detect(vm *v1.VirtualMachineInstance) (IsolationResult, error) {
var pid int
var slice string
var err error
var controller []string

// Look up the socket of the virt-launcher Pod which was created for that VM, and extract the PID from it
socket, err := cmdclient.FindSocketOnHost(vm)
if err != nil {
return nil, err
}

if pid, err = s.getPid(socket); err != nil {
log.Log.Object(vm).Reason(err).Errorf("Could not get owner Pid of socket %s", socket)
return nil, err
}

// Look up the cgroup slice based on the whitelisted controller
if controller, slice, err = s.getSlice(pid); err != nil {
log.Log.Object(vm).Reason(err).Errorf("Could not get cgroup slice for Pid %d", pid)
return nil, err
}

return NewIsolationResult(pid, slice, controller), nil
return s.DetectForSocket(vm, socket)
}

// standard golang libraries don't provide API to set runtime limits
Expand Down

0 comments on commit 394dcc0

Please sign in to comment.