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 @@ -582,11 +582,24 @@ func (handle *LinuxKernelHandler) GetModules() ([]string, error) {
582
582
583
583
var bmods []string
584
584
585
- // Find out loaded kernel modules. If this is a full static kernel it will thrown an error
585
+ // 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
586
586
modulesFile , err := os .Open ("/proc/modules" )
587
+ if err == os .ErrNotExist {
588
+ klog .Warningf ("Failed to read file /proc/modules with error %v. Assuming this is a kernel without loadable modules support enabled" , err )
589
+ kernelConfigFile := fmt .Sprintf ("/boot/config-%s" , kernelVersionStr )
590
+ kConfig , err := ioutil .ReadFile (kernelConfigFile )
591
+ if err != nil {
592
+ return nil , fmt .Errorf ("Failed to read Kernel Config file %s with error %v" , kernelConfigFile , err )
593
+ }
594
+ for _ , module := range ipvsModules {
595
+ if match , _ := regexp .Match ("CONFIG_" + strings .ToUpper (module )+ "=y" , kConfig ); match {
596
+ bmods = append (bmods , module )
597
+ }
598
+ }
599
+ return bmods , nil
600
+ }
587
601
if err != nil {
588
- klog .Warningf ("Failed to read file /proc/modules with error %v. Kube-proxy requires loadable modules support enabled in the kernel" , err )
589
- return nil , err
602
+ return nil , fmt .Errorf ("Failed to read file /proc/modules with error %v" , err )
590
603
}
591
604
592
605
mods , err := getFirstColumn (modulesFile )
You can’t perform that action at this time.
0 commit comments