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

Chris Friesen chris.friesen at windriver.com
Thu Sep 24 22:21:23 UTC 2015


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 file to be immediately truncated on opening, leading to an
> empty file.
>
> To work around this, I think we need to do the classic "write to a temporary
> file and then rename it to the desired filename" trick.  The atomicity of the
> rename ensures that either the old contents or the new contents are present.

I'm pretty sure that upstream code is still susceptible to zeroing out the file 
in the above scenario.  However, it doesn't take an exception--that's due to a 
local change on our part that attempted to fix the below issue.

The stable/kilo code *does* have a problem in that when it regenerates the file 
it's missing the CHAP authentication line (beginning with "incominguser").

Chris



More information about the OpenStack-dev mailing list