Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-10-02 Thread Joshua Harlow
A library that seems to have a pretty nice abstraction for this kind of thing/pattern, could be an idea to use it, or have something similar like it... https://boltons.readthedocs.org/en/latest/fileutils.html#atomic-file-saving -Josh On Sat, 26 Sep 2015 10:48:39 +0200 Julien Danjou

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-27 Thread Chris Friesen
On 09/26/2015 02:48 AM, Julien Danjou wrote: On Tue, Sep 22 2015, Chris Friesen wrote: On 09/22/2015 05:48 PM, Joshua Harlow wrote: A present: >>> import contextlib >>> import os >>> >>> @contextlib.contextmanager ... def synced_file(path, mode='wb'): ... with open(path, mode) as

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-26 Thread Julien Danjou
On Tue, Sep 22 2015, Chris Friesen wrote: > On 09/22/2015 05:48 PM, Joshua Harlow wrote: >> A present: >> >> >>> import contextlib >> >>> import os >> >>> >> >>> @contextlib.contextmanager >> ... def synced_file(path, mode='wb'): >> ... with open(path, mode) as fh: >> ... yield fh >>

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-25 Thread Chris Friesen
On 09/24/2015 04:21 PM, Chris Friesen wrote: On 09/24/2015 12:18 PM, Chris Friesen wrote: I think what happened is that we took the SIGTERM after the open() call in create_iscsi_target(), but before writing anything to the file. f = open(volume_path, 'w+')

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-25 Thread Mitsuhiro Tanino
> -Original Message- > From: Eric Harney [mailto:ehar...@redhat.com] > Sent: Friday, September 25, 2015 2:56 PM > To: OpenStack Development Mailing List (not for usage questions) > Subject: Re: [openstack-dev] [cinder] should we use fsync when writing iscsi > config f

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-25 Thread Mitsuhiro Tanino
> -Original Message- > From: Chris Friesen [mailto:chris.frie...@windriver.com] > Sent: Friday, September 25, 2015 3:04 PM > To: openstack-dev@lists.openstack.org > Subject: Re: [openstack-dev] [cinder] should we use fsync when writing iscsi > config file? > >

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-25 Thread Chris Friesen
On 09/25/2015 12:30 PM, Mitsuhiro Tanino wrote: On 09/22/2015 06:43 PM, Robert Collins wrote: On 23 September 2015 at 09:52, Chris Friesen wrote: Hi, I recently had an issue with one file out of a dozen or so in "/opt/cgcs/cinder/data/volumes/" being present but

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-25 Thread Eric Harney
gt; with proper authentication when c-vol is restarted. > I think this is a solution for this situation. > This may be possible, but fixing the target config file to be written more safely to work as currently intended is still a win. > Any thought? > > Thanks, > Mitsuhiro Tanino

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-25 Thread Mitsuhiro Tanino
ed. I think this is a solution for this situation. Any thought? Thanks, Mitsuhiro Tanino > -Original Message- > From: Chris Friesen [mailto:chris.frie...@windriver.com] > Sent: Friday, September 25, 2015 12:48 PM > To: openstack-dev@lists.openstack.org > Subject: Re: [openstack-

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-24 Thread Chris Friesen
On 09/24/2015 10:54 AM, Chris Friesen wrote: I took another look at the code and realized that the file *should* get rebuilt on restart after a power outage--if the file already exists it will print a warning message in the logs but it should still overwrite the contents of the file with the

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-24 Thread Chris Friesen
On 09/24/2015 12:18 PM, Chris Friesen wrote: I think what happened is that we took the SIGTERM after the open() call in create_iscsi_target(), but before writing anything to the file. f = open(volume_path, 'w+') f.write(volume_conf) f.close() The 'w+' causes the

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-24 Thread Chris Friesen
On 09/22/2015 06:19 PM, John Griffith wrote: On Tue, Sep 22, 2015 at 6:17 PM, John Griffith

[openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-22 Thread Chris Friesen
Hi, I recently had an issue with one file out of a dozen or so in "/opt/cgcs/cinder/data/volumes/" being present but of size zero. I'm running stable/kilo if it makes a difference. Looking at the code in volume.targets.tgt.TgtAdm.create_iscsi_target(), I'm wondering if we should do a

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-22 Thread Joshua Harlow
Chris Friesen wrote: On 09/22/2015 05:48 PM, Joshua Harlow wrote: A present: >>> import contextlib >>> import os >>> >>> @contextlib.contextmanager ... def synced_file(path, mode='wb'): ... with open(path, mode) as fh: ... yield fh ... os.fdatasync(fh.fileno()) ... >>> with

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-22 Thread John Griffith
On Tue, Sep 22, 2015 at 6:17 PM, John Griffith wrote: > > > On Tue, Sep 22, 2015 at 5:48 PM, Joshua Harlow > wrote: > >> A present: >> >> >>> import contextlib >> >>> import os >> >>> >> >>> @contextlib.contextmanager >> ... def synced_file(path,

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-22 Thread Joshua Harlow
A present: >>> import contextlib >>> import os >>> >>> @contextlib.contextmanager ... def synced_file(path, mode='wb'): ... with open(path, mode) as fh: ... yield fh ... os.fdatasync(fh.fileno()) ... >>> with synced_file("/tmp/b.txt") as fh: ...fh.write("b") ... Have fun :-P

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-22 Thread Chris Friesen
On 09/22/2015 05:48 PM, Joshua Harlow wrote: A present: >>> import contextlib >>> import os >>> >>> @contextlib.contextmanager ... def synced_file(path, mode='wb'): ... with open(path, mode) as fh: ... yield fh ... os.fdatasync(fh.fileno()) ... >>> with

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-22 Thread Robert Collins
On 23 September 2015 at 09:52, Chris Friesen wrote: > Hi, > > I recently had an issue with one file out of a dozen or so in > "/opt/cgcs/cinder/data/volumes/" being present but of size zero. I'm > running stable/kilo if it makes a difference. > > Looking at the code

Re: [openstack-dev] [cinder] should we use fsync when writing iscsi config file?

2015-09-22 Thread John Griffith
On Tue, Sep 22, 2015 at 5:48 PM, Joshua Harlow wrote: > A present: > > >>> import contextlib > >>> import os > >>> > >>> @contextlib.contextmanager > ... def synced_file(path, mode='wb'): > ... with open(path, mode) as fh: > ... yield fh > ...