#12988 closed defect (fixed)
Upgrade reported as failed if trac.ini.sample is not writable
Reported by: | Ryan J Ollos | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.17 |
Component: | general | Version: | |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
|
||
API Changes: | |||
Internal Changes: |
Description
Upgrade reported as failed if trac.ini.sample
is not writable:
$ trac-admin /var/trac/trac upgrade The upgrade failed. Please fix the issue and try again. OSError: [Errno 13] Permission denied: '/var/trac/trac/conf/trac.ini.sample'
However, since trac.ini.sample is updated after the database upgrade, the database upgrade has succeeded and executing upgrade again reports that upgrade isn't needed. This might be confusing to the user.
Better behavior would be to update the trac.ini.sample before the upgrade so that the database isn't upgraded in the event of failure updating trac.ini.sample.
I've only tested with trunk so far. At least on trunk, the following change seems to be good:
-
trac/env.py
diff --git a/trac/env.py b/trac/env.py index b7dae8351..cc24b6577 100644
a b class Environment(Component, ComponentManager): 770 770 except Exception as e: 771 771 raise BackupError(e) 772 772 773 self._update_sample_config() 774 773 775 for participant in upgraders: 774 776 self.log.info("upgrading %s...", participant) 775 777 with self.component_guard(participant, reraise=True): … … class Environment(Component, ComponentManager): 779 781 if dbm.connection_uri != 'sqlite::memory:': 780 782 dbm.shutdown() 781 783 782 self._update_sample_config()783 784 del self.database_version 784 785 return True
Attachments (0)
Change History (5)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Did you try using trunk? I can reproduce on Linux and OSX running db45.py
upgrade step.
$ ls -al ../tracenvs/proj-1.3/conf/trac.ini.sample -rw-r--r-- 1 root staff 8543 Mar 2 22:33 ../tracenvs/proj-1.3/conf/trac.ini.sample
comment:3 by , 7 years ago
Okay. Reproduced it when upgrading 1.0.15 to 1.2.2 with different user id with owner of trac.ini.sample.
$ /venv/trac/1.2.2/bin/trac-admin /dev/shm/tracenv initenv 'My Project' sqlite:db/trac.db $ /venv/trac/1.2.2/bin/trac-admin /dev/shm/tracenv config set logging log_type file $ sudo chown root:root /dev/shm/tracenv/conf/trac.ini.sample $ ls -la /dev/shm/tracenv/conf total 16 drwxr-xr-x 2 jun66j5 jun66j5 80 Mar 5 17:11 . drwxr-xr-x 8 jun66j5 jun66j5 200 Mar 5 17:11 .. -rw------- 1 jun66j5 jun66j5 6074 Mar 5 17:11 trac.ini -rw-r--r-- 1 root root 5534 Mar 5 17:11 trac.ini.sample $ id uid=1000(jun66j5) gid=1000(jun66j5) groups=1000(jun66j5),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),111(lpadmin),112(sambashare) $ /venv/trac/1.2.2/bin/trac-admin /dev/shm/tracenv upgrade The upgrade failed. Please fix the issue and try again. OSError: [Errno 13] Permission denied: '/run/shm/tracenv/conf/trac.ini.sample'
trac.log:
2018-03-05 17:27:05,293 Trac[console] ERROR: Exception in trac-admin command: u'upgrade' Traceback (most recent call last): File "/venv/trac/1.2.2/lib/python2.6/site-packages/trac/admin/console.py", line 112, in onecmd rv = cmd.Cmd.onecmd(self, line) or 0 File "/usr/lib/python2.6/cmd.py", line 218, in onecmd return self.default(line) File "/venv/trac/1.2.2/lib/python2.6/site-packages/trac/admin/console.py", line 291, in default return self.cmd_mgr.execute_command(*args) File "/venv/trac/1.2.2/lib/python2.6/site-packages/trac/admin/api.py", line 127, in execute_command return f(*fargs) File "/venv/trac/1.2.2/lib/python2.6/site-packages/trac/env.py", line 1100, in _do_upgrade self.env.upgrade(backup=no_backup is None) File "/venv/trac/1.2.2/lib/python2.6/site-packages/trac/env.py", line 836, in upgrade participant.upgrade_environment(*args) File "/venv/trac/1.2.2/lib/python2.6/site-packages/trac/env.py", line 878, in upgrade_environment self._update_sample_config() File "/venv/trac/1.2.2/lib/python2.6/site-packages/trac/env.py", line 890, in _update_sample_config config.save() File "/venv/trac/1.2.2/lib/python2.6/site-packages/trac/config.py", line 351, in save self._write(parser) File "/venv/trac/1.2.2/lib/python2.6/site-packages/trac/config.py", line 435, in _write wait_for_file_mtime_change(self.filename) File "/venv/trac/1.2.2/lib/python2.6/site-packages/trac/util/compat.py", line 99, in wait_for_file_mtime_change touch_file(filename) File "/venv/trac/1.2.2/lib/python2.6/site-packages/trac/util/__init__.py", line 283, in touch_file os.utime(filename, None) OSError: [Errno 13] Permission denied: '/run/shm/tracenv/conf/trac.ini.sample'
comment:4 by , 7 years ago
Milestone: | 1.2.3 → 1.0.17 |
---|---|
Release Notes: | modified (diff) |
Resolution: | → fixed |
Status: | assigned → closed |
comment:5 by , 7 years ago
Owner: | changed from | to
---|
I'm trying to reproduce it with non-writable $ENV/conf/trac.ini.sample file or $ENV/conf directory but cannot reproduce….
Anyway,
IOError
is trapped when writing the sample file butOSError
is not trapped at source:/tags/trac-1.2.2/trac/env.py@:894#L882. I consider we should trapEnvironmentError
rather thanIOError
.