Change error handling of "Reboot Required" detection (#556)

This commit is contained in:
Mai MISHIRO
2017-12-12 17:03:42 +09:00
committed by Kota Kanbe
parent b4cd96fc9a
commit 1214d8c14d

View File

@@ -262,8 +262,10 @@ func (o *redhat) scanPackages() error {
func (o *redhat) rebootRequired() (bool, error) {
r := o.exec("rpm -q --last kernel", noSudo)
scanner := bufio.NewScanner(strings.NewReader(r.Stdout))
if !r.isSuccess(0, 1) {
return false, fmt.Errorf("Failed to detect the last installed kernel : %v", r)
}
if !r.isSuccess() || !scanner.Scan() {
o.log.Warn("Failed to detect the last installed kernel : %v", r)
return false, nil
}
lastInstalledKernelVer := strings.Fields(scanner.Text())[0]