Task #12002 (closed)
BUG: bin/omero read-only operations rewrite config.xml
Reported by: | spli | Owned by: | jamoore |
---|---|---|---|
Priority: | critical | Milestone: | 5.0.1 |
Component: | Configuration | Version: | 5.0.0-rc2 |
Keywords: | n.a. | Cc: | jamoore, sbesson, |
Resources: | n.a. | Referenced By: | n.a. |
References: | n.a. | Remaining Time: | 0.0d |
Sprint: | n.a. |
Description
Add an additional print statement to config.py; it turns out the file is rewritten twice, before and after displaying the config values. This can lead to loss of config.xml- if the filesystem runs out of space an empty file will be written even though a user would not expect config get to modify anything.
$ diff -U5 OMERO-CURRENT/lib/python/omero/config.py.orig OMERO-CURRENT/lib/python/omero/config.py --- OMERO-CURRENT/lib/python/omero/config.py.orig 2014-02-11 14:34:18.000000000 +0000 +++ OMERO-CURRENT/lib/python/omero/config.py 2014-02-19 10:38:15.000000000 +0000 @@ -237,10 +237,13 @@ def save(self): """ Creates a fresh <icegrid> block (removing any unwanted intra-element whitespace) and overwrites the file on disk. """ + + print 'Saving %s' % self + icegrid = Element("icegrid") comment = Comment("\n".join(["\n", "\tThis file was generated at %s by the OmeroConfig system.", "\tDo not edit directly but see bin/omero config for details.", "\tThis file may be included into your IceGrid application.",
$ OMERO-CURRENT/bin/omero config get Saving <omero.config.ConfigXml object at 0x10c7f2850> omero.data.dir=/OMERO ... omero.web.debug=True Saving <omero.config.ConfigXml object at 0x10c0b1f10>
config.py: ConfigXml.__init__ sets self.save_on_close = True
Change History (7)
comment:1 Changed 10 years ago by spli
- Cc sbesson added
comment:2 Changed 10 years ago by spli
comment:3 Changed 10 years ago by jamoore
- Milestone changed from Unscheduled to 5.0.1
- Priority changed from major to critical
Agreed.
comment:4 Changed 10 years ago by jamoore
- Owner set to jamoore
- Status changed from new to accepted
comment:5 Changed 10 years ago by jamoore
- Resolution set to fixed
- Status changed from accepted to closed
comment:6 Changed 10 years ago by jmoore <josh@…>
- Remaining Time set to 0
(In [31bd14990094c007c9430773a05f92b4f08771f1/ome.git] on branch develop) Use temp/rename for config.xml writing (Fix #12002)
comment:7 Changed 10 years ago by jmoore <josh@…>
(In [cd570cbffc8b187964475386131ff62f0e886a64/ome.git] on branch develop) Prevent save_on_close from omeroweb/settings.py (See #12002)
In addition Roger suggested we should use a safe rewrite where it does need to be saved, i.e. save to a temporary file and rename.