Skip to content

Commit 6278df2

Browse files
authored
Merge pull request kubernetes#82223 from rikatz/issue77493
Check first if ipvs module is builtin
2 parents 05b6c32 + 6aaae7d commit 6278df2

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

pkg/proxy/ipvs/proxier.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,11 +598,24 @@ func (handle *LinuxKernelHandler) GetModules() ([]string, error) {
598598

599599
var bmods []string
600600

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
602602
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+
}
603617
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)
606619
}
607620

608621
mods, err := getFirstColumn(modulesFile)

0 commit comments

Comments
 (0)