Merge lp:~sylvain-pineau/checkbox/fix-1618197 into lp:checkbox

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: no longer in the revision history of the source branch.
Merged at revision: 4476
Proposed branch: lp:~sylvain-pineau/checkbox/fix-1618197
Merge into: lp:checkbox
Diff against target: 61 lines (+26/-3)
3 files modified
plainbox/docs/manpages/plainbox-job-units.rst (+8/-0)
plainbox/plainbox/impl/ctrl.py (+9/-3)
plainbox/plainbox/impl/unit/job.py (+9/-0)
To merge this branch: bzr merge lp:~sylvain-pineau/checkbox/fix-1618197
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Maciej Kisielewski Approve
Review via email: mp+304342@code.launchpad.net

Description of the change

Fixes the linked bug where on snappy all docker commands fail to run with this error:

unable to change to original directory. errmsg: No such file or directory

It might be a bug or a limitation of the docker executable but since it works from the command line but not from a plainbox job command, it's better to fix it first on our side.

I created a new job flag to avoid running those command from a temp dir (tested on snappy device with the docker snap it works).

To post a comment you must log in.
Revision history for this message
Maciej Kisielewski (kissiel) wrote :

Code looks good.

I'm still digesting the idea, tho.
Does this mean that those docker jobs will require checkbox to be run in a particular directory (outside the nest)?

review: Approve
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Let's land it. I'll issue another post release of plainbox to pypi to use the new flag in the docker snap provider.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plainbox/docs/manpages/plainbox-job-units.rst'
2--- plainbox/docs/manpages/plainbox-job-units.rst 2015-11-04 14:35:46 +0000
3+++ plainbox/docs/manpages/plainbox-job-units.rst 2016-08-30 08:23:40 +0000
4@@ -301,6 +301,14 @@
5 command: echo "Jobs are simple!"
6 flags: simple
7
8+.. _job_flag_preserve_cwd:
9+
10+ ``preserve-cwd``:
11+ This flag makes plainbox run the job command in the current working
12+ directory without creating a temp folder (and running the command from
13+ this temp folder). Sometimes needed on snappy
14+ (See http://pad.lv/1618197)
15+
16 Additional flags may be present in job definition; they are ignored.
17
18 ``imports``:
19
20=== modified file 'plainbox/plainbox/impl/ctrl.py'
21--- plainbox/plainbox/impl/ctrl.py 2016-08-17 07:57:21 +0000
22+++ plainbox/plainbox/impl/ctrl.py 2016-08-30 08:23:40 +0000
23@@ -551,9 +551,15 @@
24 job, job_state, config, session_dir, nest_dir)
25 with self.temporary_cwd(job, config) as cwd_dir:
26 # run the command
27- logger.debug(_("job[%s] executing %r with env %r in cwd %r"),
28- job.id, cmd, env, cwd_dir)
29- return_code = extcmd_popen.call(cmd, env=env, cwd=cwd_dir)
30+ if 'preserve-cwd' in job.get_flag_set():
31+ logger.debug(_("job[%s] executing %r with env %r"),
32+ job.id, cmd, env)
33+ return_code = extcmd_popen.call(cmd, env=env)
34+ else:
35+ logger.debug(_("job[%s] executing %r with env %r "
36+ "in cwd %r"),
37+ job.id, cmd, env, cwd_dir)
38+ return_code = extcmd_popen.call(cmd, env=env, cwd=cwd_dir)
39 if 'noreturn' in job.get_flag_set():
40 self._halt()
41 return return_code
42
43=== modified file 'plainbox/plainbox/impl/unit/job.py'
44--- plainbox/plainbox/impl/unit/job.py 2016-05-11 14:36:13 +0000
45+++ plainbox/plainbox/impl/unit/job.py 2016-08-30 08:23:40 +0000
46@@ -979,6 +979,15 @@
47 'has-leftovers makes no sense without a command'
48 ),
49 onlyif=lambda unit: unit.command is None),
50+ # The preserve-cwd flag is useless without a command
51+ CorrectFieldValueValidator(
52+ lambda value, unit: (
53+ 'preserve-cwd' not in unit.get_flag_set()),
54+ Problem.useless, Severity.advice,
55+ message=_(
56+ 'preserve-cwd makes no sense without a command'
57+ ),
58+ onlyif=lambda unit: unit.command is None),
59 ],
60 fields.qml_file: [
61 UntranslatableFieldValidator,

Subscribers

People subscribed via source and target branches