Commits
Marcin Owsiany authored and Kir Kolyshkin committed 164d72740e6
Rework modification of container's /etc/hosts There are actually multiple problems with the original (as shipped with vzctl-3.0.22) awk script. I consider the most severe to be: - discarding all user changes/additions after the "special comment line". This is a serious problem for me, and probably to anyone using such automation software as puppet. Puppet (and almost certainly other things as well) are limited to just appending a line to the config file. This behaviour destroys the changes. - adding duplicate entries in some cases (multiple lines with the same IP address, but different contents). This is in violation with the documented format of hosts(5) and can cause subtle problems with third-party software. - discarding localhost aliases (the original report for this bug) There are others, which show up in some situations: - not including the "localhost" from the entry for 127.0.0.1 - not fixing the ip address when the special comment is missing (possibly a feature?) I have created a (rather heavily modified) version of the script which fixes all the problems which I've found. I also assembled a simple shell-script-based test suite which can serve as a specification and a regression test. Both are attached. The instructions on how to operate the test suite are in the README file in the tarball. To sum up, the results are: SUMMARY: orig: 133/162 tests passed, 29 failed SUMMARY: att-606: 142/162 tests passed, 20 failed SUMMARY: sl: 162/162 tests passed, 0 failed I think the biggest problem is that there is no clear specification of what the script should be doing in each situation. There are literally dozens of corner cases (my test suite runs 162 tests!) and since the script being kind of "grown organically", the results are sometimes surprising and inconsistent. As a result I might have changed some behaviour which was in fact a requirement! http://bugzilla.openvz.org/855