Merge pull request #31022 from yifan-gu/fix_error_handling_os_release

Automatic merge from submit-queue

rkt: Do not error out when there are unrecognized lines in os-release

Also fix the error handling which will cause panic. Also fix the error handling which will cause panic.

cc @kubernetes/sig-rktnetes
pull/6/head
Kubernetes Submit Queue 2016-08-19 14:33:26 -07:00 committed by GitHub
commit bcf2d48ed5
1 changed files with 10 additions and 9 deletions

View File

@ -974,14 +974,14 @@ func (r *Runtime) generateRunCommand(pod *api.Pod, uuid, netnsName string) (stri
osInfos, err := getOSReleaseInfo()
if err != nil {
glog.Errorf("rkt: Failed to read the os release info: %v", err)
}
// Overlay fs is not supported for SELinux yet on many distros.
// See https://github.com/coreos/rkt/issues/1727#issuecomment-173203129.
// For now, coreos carries a patch to support it: https://github.com/coreos/coreos-overlay/pull/1703
if osInfos["ID"] != "coreos" && pod.Spec.SecurityContext != nil && pod.Spec.SecurityContext.SELinuxOptions != nil {
runPrepared = append(runPrepared, "--no-overlay=true")
glog.Warningf("rkt: Failed to read the os release info: %v", err)
} else {
// Overlay fs is not supported for SELinux yet on many distros.
// See https://github.com/coreos/rkt/issues/1727#issuecomment-173203129.
// For now, coreos carries a patch to support it: https://github.com/coreos/coreos-overlay/pull/1703
if osInfos["ID"] != "coreos" && pod.Spec.SecurityContext != nil && pod.Spec.SecurityContext.SELinuxOptions != nil {
runPrepared = append(runPrepared, "--no-overlay=true")
}
}
// Apply '--net=host' to pod that is running on host network or inside a network namespace.
@ -2338,7 +2338,8 @@ func getOSReleaseInfo() (map[string]string, error) {
line := scanner.Text()
info := strings.SplitN(line, "=", 2)
if len(info) != 2 {
return nil, fmt.Errorf("unexpected entry in os-release %q", line)
glog.Warningf("Unexpected entry in os-release %q", line)
continue
}
result[info[0]] = info[1]
}