File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -598,11 +598,24 @@ func (handle *LinuxKernelHandler) GetModules() ([]string, error) {
598
598
599
599
var bmods []string
600
600
601
- // Find out loaded kernel modules. If this is a full static kernel it will thrown an error
601
+ // Find out loaded kernel modules. If this is a full static kernel it will try to verify if the module is compiled using /boot/config-KERNELVERSION
602
602
modulesFile , err := os .Open ("/proc/modules" )
603
+ if err == os .ErrNotExist {
604
+ klog .Warningf ("Failed to read file /proc/modules with error %v. Assuming this is a kernel without loadable modules support enabled" , err )
605
+ kernelConfigFile := fmt .Sprintf ("/boot/config-%s" , kernelVersionStr )
606
+ kConfig , err := ioutil .ReadFile (kernelConfigFile )
607
+ if err != nil {
608
+ return nil , fmt .Errorf ("Failed to read Kernel Config file %s with error %v" , kernelConfigFile , err )
609
+ }
610
+ for _ , module := range ipvsModules {
611
+ if match , _ := regexp .Match ("CONFIG_" + strings .ToUpper (module )+ "=y" , kConfig ); match {
612
+ bmods = append (bmods , module )
613
+ }
614
+ }
615
+ return bmods , nil
616
+ }
603
617
if err != nil {
604
- klog .Warningf ("Failed to read file /proc/modules with error %v. Kube-proxy requires loadable modules support enabled in the kernel" , err )
605
- return nil , err
618
+ return nil , fmt .Errorf ("Failed to read file /proc/modules with error %v" , err )
606
619
}
607
620
608
621
mods , err := getFirstColumn (modulesFile )
You can’t perform that action at this time.
0 commit comments