We were hitting strange intermittent errors in TripleO where the hiera
JSON file generated by Heat was not even valid JSON, ending with bits of
text which seem out of place, and of varying length, e.g.
"CREATE"}"}
or
"CREATE"}EATE"}
The cause could be that the generation of the file runs multiple times,
and if the first generated JSON is longer than the subsequent one, the
ending of the previous JSON is still present in the file, because the
generation opens the file with O_CREAT (create if not exists) and
O_WRONLY (write only) flags, but not with O_TRUNC (truncate file before
writing). This patch adds the truncation to fix the issue.
Reviewed: https:/ /review. openstack. org/168328 /git.openstack. org/cgit/ openstack/ heat-templates/ commit/ ?id=f00cf8fbb89 e04851d9cb0c5f2 f99c80beb7d5c3
Committed: https:/
Submitter: Jenkins
Branch: master
commit f00cf8fbb89e048 51d9cb0c5f2f99c 80beb7d5c3
Author: Jiri Stransky <email address hidden>
Date: Fri Mar 27 13:31:10 2015 +0100
Fix hiera deployment JSON generation
We were hitting strange intermittent errors in TripleO where the hiera
JSON file generated by Heat was not even valid JSON, ending with bits of
text which seem out of place, and of varying length, e.g.
"CREATE"}"}
or
"CREATE"}EATE"}
The cause could be that the generation of the file runs multiple times,
and if the first generated JSON is longer than the subsequent one, the
ending of the previous JSON is still present in the file, because the
generation opens the file with O_CREAT (create if not exists) and
O_WRONLY (write only) flags, but not with O_TRUNC (truncate file before
writing). This patch adds the truncation to fix the issue.
Change-Id: Icf184f973decec 2eb7de1dee9959b 60774d83eb6
Closes-Bug: #1434187