Cleanup duplicated code
Implement Detect method of socketBasedIsolationDetector using
DetectForSocket.
@@ -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
