mojo fails to create workspace via sudo -i

Bug #1403395 reported by Haw Loeung
42
This bug affects 8 people
Affects Status Importance Assigned to Milestone
Mojo: Continuous Delivery for Juju
Fix Released
Medium
Paul Collins

Bug Description

Hi,

When trying to create a new workspace, mojo fails as follows:

| Creating workspace dir /srv/mojo/mojo-project/trusty/staging
| mojo --blunt workspace-new \
| --project mojo-project \
| -s trusty \
| /home/user/specs/mojo-project-spec staging
| Are you sure the project exists?
| Traceback (most recent call last):
| File "/usr/bin/mojo", line 9, in <module>
| load_entry_point('mojo==0.1', 'console_scripts', 'mojo')()
| File "/usr/lib/python2.7/dist-packages/mojo/cli.py", line 487, in main
| run_with_args(args, ap)
| File "/usr/lib/python2.7/dist-packages/mojo/cli.py", line 462, in run_with_args
| args.func(args)
| File "/usr/lib/python2.7/dist-packages/mojo/cli.py", line 147, in create_workspace
| stage=stage)
| File "/usr/lib/python2.7/dist-packages/mojo/__init__.py", line 412, in create_workspace
| mkdirs(ws_path, self.owner)
| File "/usr/lib/python2.7/dist-packages/mojo/utils.py", line 166, in mkdirs
| os.chown(path, uid, gid) OSError: [Errno 1] Operation not permitted: '/srv/mojo/mojo-project/trusty/ROOTFS/srv/mojo/mojo-project/trusty/staging'
| make: *** [/srv/mojo/mojo-project/trusty/staging] Error 1

We, Michael Nelson (https://launchpad.net/~michael.nelson) and I, managed to work it out in that if the SUDO_USER environment exists, mojo tries to use that and fails (line 273 of /usr/lib/python2.7/dist-packages/mojo/__init__.py).

| $ sudo su - user
| user@host:~$ echo $SUDO_USER

| $ sudo -iu user
| user@host:~$ echo $SUDO_USER
| michaeln

Any chance we could have it looked at and fixed?

Thanks,

Haw

Related branches

Tom Haddon (mthaddon)
Changed in mojo:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Haw Loeung (hloeung) wrote :

Caio also ran into this bug.

Revision history for this message
Sheila Miguez (codersquid) wrote :

This also affects me.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

This continues to be an issue. My muscle memory is to use 'sudo -iu <user>' to switch accounts, and every single time my mojo operations fail (it affects 'mojo run' as well, and probably others besides).

We could add 'unset SUDO_USER' to the end of ~/.bashrc, but that may have side-effects that we want to avoid.

Paul Collins (pjdc)
Changed in mojo:
assignee: nobody → Paul Collins (pjdc)
Revision history for this message
Paul Collins (pjdc) wrote :

I've proposed the linked branch for merging, which I believe will address this problem.

Changed in mojo:
status: Confirmed → In Progress
Revision history for this message
Paul Collins (pjdc) wrote :

One final check, now that it's live:

== $SUDO_USER unset ==

pjdc@wekufe:~$ sudo su - prodstack-is
[...]
prodstack-is@wekufe:~$ source ~/.prodstack/envrc/juju2-mojo-how-to
(prodstack-is-juju2-mojo-how-to)prodstack-is@wekufe:~$ echo $SUDO_USER

(prodstack-is-juju2-mojo-how-to)prodstack-is@wekufe:~$ mojo workspace-new $MOJO_SPEC pjdc-test-1
2017-02-16 22:14:28 [INFO] Using pre-existing container class lxc
2017-02-16 22:14:28 [INFO] Rsyncing /srv/prodstack/is/specs/juju2-is-mojo-how-to to /srv/mojo/juju2-is-mojo-how-to/xenial/pjdc-test-1/spec
2017-02-16 22:14:28 [INFO] Workspace created. Validating manifest
2017-02-16 22:14:28 [INFO] Retrieve the spec's manifest
2017-02-16 22:14:28 [INFO] Manifest OK (/srv/mojo/juju2-is-mojo-how-to/xenial/pjdc-test-1/spec/mojo-how-to/manifest)

== $SUDO_USER set ==

pjdc@wekufe:~$ sudo -iu prodstack-is
[...]
prodstack-is@wekufe:~$ source ~/.prodstack/envrc/juju2-mojo-how-to
(prodstack-is-juju2-mojo-how-to)prodstack-is@wekufe:~$ echo $SUDO_USER
pjdc
(prodstack-is-juju2-mojo-how-to)prodstack-is@wekufe:~$ mojo workspace-new $MOJO_SPEC pjdc-test-2
2017-02-16 22:16:41 [INFO] Using pre-existing container class lxc
2017-02-16 22:16:42 [INFO] Rsyncing /srv/prodstack/is/specs/juju2-is-mojo-how-to to /srv/mojo/juju2-is-mojo-how-to/xenial/pjdc-test-2/spec
2017-02-16 22:16:42 [INFO] Workspace created. Validating manifest
2017-02-16 22:16:42 [INFO] Retrieve the spec's manifest
2017-02-16 22:16:42 [INFO] Manifest OK (/srv/mojo/juju2-is-mojo-how-to/xenial/pjdc-test-2/spec/mojo-how-to/manifest)

Changed in mojo:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.