Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move single-request-reopen into OS specific scripts #174

Closed
wants to merge 1 commit into from

Conversation

rjocoleman
Copy link
Contributor

related to #171

@juliandunn I've completed this move/change.

I established that Fedora 19 and 20 show the same issue under virtualbox.

  1. I removed the line from packer/scripts/centos/ks.cfg
  2. Added discrete fix-slow-dns.sh scripts for Fedora and Centos/RHEL. These are at the start of post-install script execution incase any later post-install scripts download things so they'll benefit from the fix.
  3. Limited the execution of this post-install script to virtualbox only.
  4. I moved the Centos into /etc/sysconfig/network, this is used when resolv.conf is generated when dhclient runs. resolv.conf can be overwritten and the change lost otherwise.
  5. Fedora uses NetworkManager to generate resolv.conf, added a script to hook into that to add the required line to resolv.conf
  6. Fedora 19 has a known bug with the install media version of NetworkManager that prevents dispatchers (the hook I'm using) from running so on F19 updated NM to mitigate this.
  7. I built new boxes with the changes applied and verified that they were showing the desired behaviour, as below.

In short this should apply only the the effected operating systems and persist past network changes/reboots.

How to reproduce:

To reproduce this issue I set up a basic Vagrant test: https://gist.github.com/rjocoleman/9161682

Bad:

[default] Running: inline script
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   220  100   220    0     0     26      0  0:00:08  0:00:08 --:--:--    47
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   220  100   220    0     0     34      0  0:00:06  0:00:06 --:--:--    57
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   220  100   220    0     0     34      0  0:00:06  0:00:06 --:--:--    58
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   220  100   220    0     0     33      0  0:00:06  0:00:06 --:--:--    54
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   220  100   220    0     0     34      0  0:00:06  0:00:06 --:--:--    58

Fixed

[default] Running: inline script
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   220  100   220    0     0    323      0 --:--:-- --:--:-- --:--:--   323
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   220  100   220    0     0    305      0 --:--:-- --:--:-- --:--:--   305
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   220  100   220    0     0    289      0 --:--:-- --:--:-- --:--:--   289
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   220  100   220    0     0    274      0 --:--:-- --:--:-- --:--:--   274
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   220  100   220    0     0    326      0 --:--:-- --:--:-- --:--:--   326

* Ensure that it will be added to /etc/resolv.conf when it's generated
* handle fedora 19 NetoworkManager bug
# add 'single-request-reopen' so it is included when /etc/resolv.conf is generated
cat >> /etc/NetworkManager/dispatcher.d/fix-slow-dns <<EOF
#!/bin/bash
echo "options single-request-reopen" >> /etc/resolv.conf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How often will this run? Is the generation of /etc/resolv.conf by NM convergent? My only concern is that if the user restarts NM then this line will be echoed to resolv.conf each time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/etc/resolv.conf is made from scratch each time. So we don't need any handling of existing values - it's also why we can't just edit /etc/resolv.conf

$ vagrant ssh -- cat /etc/resolv.conf
# Generated by NetworkManager
domain hq.rjoc.me
search hq.rjoc.me
nameserver 10.0.2.3
options single-request-reopen
$ vagrant halt
... snip ...
$ vagrant up --provider virtualbox
... snip ...
$ vagrant ssh -- cat /etc/resolv.conf
# Generated by NetworkManager
domain hq.rjoc.me
search hq.rjoc.me
nameserver 10.0.2.3
options single-request-reopen
$ vagrant ssh -- sudo service NetworkManager restart
Redirecting to /bin/systemctl restart  NetworkManager.service
$ vagrant ssh -- cat /etc/resolv.conf
# Generated by NetworkManager
domain hq.rjoc.me
search hq.rjoc.me
nameserver 10.0.2.3
options single-request-reopen

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, LGTM

@juliandunn
Copy link
Contributor

Merged in e236d14

@juliandunn juliandunn closed this Feb 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants