Bug 712443

Summary: failed kickstart script errors are reported using non-existing detailedMessageWindow method
Product: Red Hat Enterprise Linux 5 Reporter: Charlie Brady <charlieb-fedora-bugzilla>
Component: anacondaAssignee: David Cantrell <dcantrell>
Status: CLOSED ERRATA QA Contact: Release Test Team <release-test-team>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.6CC: atodorov
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: anaconda-11.1.2.244-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-21 05:38:07 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 726828    

Description Charlie Brady 2011-06-10 16:05:12 UTC
bash-3.2$ grep -r detailedMessage anaconda-11.1.2.224/
anaconda-11.1.2.224/kickstart.py:                        intf.detailedMessageWindow(_("Scriptlet Failure"), msg, err)
bash-3.2$ 

Code is here - exception will be triggered if the script has non-zero exit status, and error output and -erroronfail was used in kickstart file:

...
        # Always log an error.  Only fail if we have a handle on the
        # windowing system and the kickstart file included --erroronfail.
        if rc != 0:
            log.error("Error code %s running the kickstart script at line %s" % (rc, self.lineno))

            try:
                f = open(messages, "r")
                err = f.readlines()
                f.close()
                for l in err:
                    log.error("\t%s" % l)
            except:
                err = None

            if self.errorOnFail:
                if intf != None:
                    msg = _("There was an error running the kickstart "
                            "script at line %(lineno)s.  You may examine the "
                            "output in %(msgs)s.  This is a fatal error and "
                            "installation will be aborted.  Press the "
                            "OK button to exit the installer.") \
                          % {'lineno': self.lineno, 'msgs': messages}

                    if err:
                        intf.detailedMessageWindow(_("Scriptlet Failure"), msg, err)
                    else:
                        intf.messageWindow(_("Scriptlet Failure"), msg)
...

Problem has not been fixed in later anaconda-11.1.2.xxx:

bash-3.2$ grep -r detailedMessageWindow anaconda-11.1.2.231/
anaconda-11.1.2.231/kickstart.py:                        intf.detailedMessageWindow(_("Scriptlet Failure"), msg, err)
bash-3.2$

Comment 1 Charlie Brady 2011-06-10 16:09:11 UTC
detailedMessageWindow appears in rhel6 and master branches, so I guess this is a bad merge/c&p at some point.

Comment 2 Charlie Brady 2011-06-10 18:05:41 UTC
thel6 branch (anaconda-13.21.82) provides this definition:

    def detailedMessageWindow(self, title, text, longText=None, type="ok",
                              default=None, custom_icon=None,
                              custom_buttons=[], expanded=False):
        t = TextboxReflowed(60, text, maxHeight=8)
        lt = Textbox(60, 6, longText, scroll=1, wrap=1)
        g = GridFormHelp(self.screen, title, help, 1, 3)
        g.add(t, 0, 0)
        g.add(lt, 0, 1, padding = (0, 1, 0, 1))

        if type == "ok":
            bb = ButtonBar(self.screen, [TEXT_OK_BUTTON])
            g.add(bb, 0, 2, growx = 1)
            return bb.buttonPressed(g.runOnce(None, None))
        elif type == "yesno":
            if default and default == "no":
                buttons = [TEXT_NO_BUTTON, TEXT_YES_BUTTON]
            else:
                buttons = [TEXT_YES_BUTTON, TEXT_NO_BUTTON]

            bb = ButtonBar(self.screen, buttons)
            g.add(bb, 0, 2, growx = 1)
            rc = bb.buttonPressed(g.runOnce(None, None))

            if rc == "yes":
                return 1
            else:
                return 0
        elif type == "custom":
            buttons = []
            idx = 0

            for button in custom_buttons:
                buttons.append(string.replace(button, "_", ""))

            bb = ButtonBar(self.screen, buttons)
            g.add(bb, 0, 2, growx = 1)
            rc = bb.buttonPressed(g.runOnce(None, None))

            for b in buttons:
                if string.lower(b) == rc:
                    return idx
                idx += 1

            return 0
        else:
            return self.messageWindow(title, text, type, default, custom_icon,
                                      custom_buttons)

But that still leads to an exception:

http://web.archiveorange.com/archive/v/YcynVafxgSyloaQqsOhY

Comment 3 Charlie Brady 2011-06-10 18:38:52 UTC
> But that still leads to an exception:

This would be one way of avoiding that exception:

-        lt = Textbox(60, 6, longText, scroll=1, wrap=1)
+        lt = Textbox(60, 6, ''.join(longText), scroll=1, wrap=1)

Or change the caller:

-                        intf.detailedMessageWindow(_("Scriptlet Failure"), msg, err)
+                        intf.detailedMessageWindow(_("Scriptlet Failure"), msg, ''.join(err))

Or change the reading of the errlog file:

...
                f = open(messages, "r")
                err = f.readlines()
                f.close()
                for l in err:
                    log.error("\t%s" % l)
...

Comment 4 Charlie Brady 2011-06-16 15:18:58 UTC
(In reply to comment #2)

> But that still leads to an exception:
> 
> http://web.archiveorange.com/archive/v/YcynVafxgSyloaQqsOhY

Hence this bug should be cloned to RHEL6 as well.

Comment 5 RHEL Program Management 2011-08-05 12:36:26 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 6 David Cantrell 2011-09-16 14:17:32 UTC
How about a more simple approach:

commit a8a8d61d7428754b6baacd79cd54801e44357922
Author: David Cantrell <dcantrell>
Date:   Fri Sep 16 10:07:13 2011 -0400

    Remove call to detailedMessageWindow (#712443)
    
    detailedMessageWindow is from rhel6-branch.  We use messageWindow on
    rhel5-branch, so adjust the call a little.

diff --git a/kickstart.py b/kickstart.py
index 415ddf1..cfe12a0 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -100,7 +100,7 @@ class AnacondaKSScript(Script):
                           % {'lineno': self.lineno, 'msgs': messages}
 
                     if err:
-                        intf.detailedMessageWindow(_("Scriptlet Failure"), msg, err)
+                        intf.messageWindow(_("Scriptlet Failure"), msg + "\n" + "\n".join(err))
                     else:
                         intf.messageWindow(_("Scriptlet Failure"), msg)

Comment 8 Alexander Todorov 2011-12-02 15:03:41 UTC
In anaconda-11.1.2.248 there's a message window which informs you about the error.

Comment 9 errata-xmlrpc 2012-02-21 05:38:07 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0197.html