[API] Fix config file race condition and improve test cases for DNS update hooks
- Request handler A writes hostname.conf.tmp.
- Request handler B opens hostname.conf.tmp for writing.
- Request handler A issues the move command.
Catch only the expected exceptions on the various write and update operations (IOError and SystemCallError?), not unexpected ones.
#6 Updated by Lucas Di Pentima over 2 years ago
Updates at branch
6304-dns-update-fix - 6da9f3666
Test run: https://ci.curoverse.com/job/developer-run-tests/220/
#7 Updated by Tom Clegg over 2 years ago
An ensure block should delete the stray temp file if we got as far as creating one (e.g., if f.puts fails). Something like this?
tmpfile = nil begin ... Tempfile.open(...) do |f| tmpfile = f.path f.puts ... end File.rename tmpfile, hostfile tmpfile = nil rescue ... ... ensure if tmpfile File.unlink tmpfile end end
It seems that the new "dns update with dir configured but no command configured" test actually tests "dns_server_update is a no-op when dns_server_conf_template is not set".
#10 Updated by Lucas Di Pentima over 2 years ago
As per Tom's suggestion, added the server_dns_template_conf setting so the test can pass, thanks Tom!
- char as a separator between the compute node's name and the rest of the temp file, to improve temp file name readability.