Bug 1063275

Summary: Undeclared variable causing traceback
Product: [Fedora] Fedora Reporter: Tomas Kopecek <tkopecek>
Component: mockAssignee: Clark Williams <williams>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: mebrown, tkopecek, williams
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: mock-1.1.38-1.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-04-09 13:18:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
patch
none
revised patch to fix undefined variable in try/finally none

Description Tomas Kopecek 2014-02-10 11:54:40 UTC
Created attachment 861354 [details]
patch

Code of cleanup phase in backend.py (in finally:) uses variable chrootstate which is not declared yet (error occurs before it), so causing chained traceback. Fix is testing if variable is set before using it. Patch is self-explanatory oneliner.

Tested build: mock-1.1.36-1.fc20
Patch against ebce599dca50c7c306aba7be631b1eb03febe9ec

Comment 1 Clark Williams 2014-03-25 04:51:36 UTC
Created attachment 878308 [details]
revised patch to fix undefined variable in try/finally

I like this one a little better. What do  you think?

Comment 2 Fedora Update System 2014-03-25 20:24:41 UTC
mock-1.1.37-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/mock-1.1.37-1.fc19

Comment 3 Fedora Update System 2014-03-25 20:27:06 UTC
mock-1.1.37-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.1.37-1.fc20

Comment 4 Fedora Update System 2014-03-25 20:29:12 UTC
mock-1.1.37-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.37-1.el6

Comment 5 Fedora Update System 2014-03-26 17:37:57 UTC
Package mock-1.1.37-1.el6:
* should fix your issue,
* was pushed to the Fedora EPEL 6 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=epel-testing mock-1.1.37-1.el6'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-EPEL-2014-0960/mock-1.1.37-1.el6
then log in and leave karma (feedback).

Comment 6 Tomas Kopecek 2014-03-27 08:52:29 UTC
My patch was focused to case when exception is raised before self.start(chroot). (My case, some directories can't be mounted in test env). So self.start is not called and self.finish yes in your patch. Does it make sense?

In such case it will raise:
mockbuild.exception.StateError, "state finish mismatch: current: %s, state: %s" % (current, state)

(not tested, just looking to code now)

Comment 7 Fedora Update System 2014-03-27 17:47:44 UTC
mock-1.1.37-2.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.1.37-2.fc20

Comment 8 Fedora Update System 2014-03-27 17:49:38 UTC
mock-1.1.37-2.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/mock-1.1.37-2.fc19

Comment 9 Fedora Update System 2014-03-27 17:51:32 UTC
mock-1.1.37-2.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.37-2.el6

Comment 10 Clark Williams 2014-03-27 20:17:17 UTC
Ah, good point. I'll look at it and we can put whatever we agree on into the 1.1.38 build.

Comment 11 Clark Williams 2014-03-27 21:05:43 UTC
How about we lift that self.start(chrootstate) out of the try block?

diff --git a/py/mockbuild/backend.py b/py/mockbuild/backend.py
index 8ed7d48..b56d28d 100644
--- a/py/mockbuild/backend.py
+++ b/py/mockbuild/backend.py
@@ -813,12 +813,12 @@ from mockbuild.trace_decorator import traceLog, decorate, getLog
         self._resetLogging()
         self._callHooks("prechroot")
         chrootstate = "chroot %s" % args
+        self.start(chrootstate)
         try:
             self._setupDirs()
             self._setupDev()
             self._setupFiles()
             self._mountall()
-            self.start(chrootstate)
             if options.unpriv:
                 self.doChroot(args, shell=shell, printOutput=True,
                               uid=self.chrootuid, gid=self.chrootgid, cwd=options.cwd)

Comment 12 Tomas Kopecek 2014-03-28 14:02:23 UTC
So clear, that I've missed this solution :-)
I'm for this one.

Comment 13 Clark Williams 2014-03-28 15:07:25 UTC
Good, this is now queued for testing in 1.1.38

Comment 14 Clark Williams 2014-03-28 15:14:37 UTC
Ugh, I meant 1.1.37-2. Sorry

Comment 15 Clark Williams 2014-03-28 15:19:44 UTC
and that last patch didn't make it into the build. Argh. I'll push a 1.1.38 build with that last bit when we finally get 1.1.37 through testing.

Comment 16 Fedora Update System 2014-03-31 19:04:20 UTC
mock-1.1.38-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/mock-1.1.38-1.fc19

Comment 17 Fedora Update System 2014-03-31 19:06:45 UTC
mock-1.1.38-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.38-1.el6

Comment 18 Fedora Update System 2014-03-31 19:08:38 UTC
mock-1.1.38-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.1.38-1.fc20

Comment 19 Fedora Update System 2014-04-09 13:18:35 UTC
mock-1.1.38-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 20 Fedora Update System 2014-04-18 15:37:33 UTC
mock-1.1.38-1.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 21 Fedora Update System 2014-04-19 09:19:52 UTC
mock-1.1.38-1.el6 has been pushed to the Fedora EPEL 6 stable repository.  If problems still persist, please make note of it in this bug report.