-
Notifications
You must be signed in to change notification settings - Fork 1.3k
vr: Ensuring dnsmasq.leases file is populated #4529
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ def process(self): | |
| self.cloud = CsFile(DHCP_HOSTS) | ||
| self.dhcp_opts = CsFile(DHCP_OPTS) | ||
| self.conf = CsFile(CLOUD_CONF) | ||
| self.dhcp_leases = CsFile(LEASES) | ||
|
|
||
| self.cloud.repopulate() | ||
| self.dhcp_opts.repopulate() | ||
|
|
@@ -60,6 +61,9 @@ def process(self): | |
| if self.cloud.commit(): | ||
| restart_dnsmasq = True | ||
|
|
||
| if self.dhcp_leases.commit(): | ||
| restart_dnsmasq = True | ||
|
|
||
| self.dhcp_opts.commit() | ||
|
|
||
| if restart_dnsmasq: | ||
|
|
@@ -186,6 +190,9 @@ def add(self, entry): | |
| entry['ipv4_address'], | ||
| entry['host_name'], | ||
| lease)) | ||
| self.dhcp_leases.search(entry['mac_address'], "0 %s %s %s *" % (entry['mac_address'], | ||
| entry['ipv4_address'], | ||
| entry['host_name'])) | ||
| else: | ||
| tag = entry['ipv4_address'].replace(".", "_") | ||
| self.cloud.add("%s,set:%s,%s,%s,%s" % (entry['mac_address'], | ||
|
|
@@ -196,6 +203,9 @@ def add(self, entry): | |
| self.dhcp_opts.add("%s,%s" % (tag, 3)) | ||
| self.dhcp_opts.add("%s,%s" % (tag, 6)) | ||
| self.dhcp_opts.add("%s,%s" % (tag, 15)) | ||
| self.dhcp_leases.search(entry['mac_address'], "0 %s %s %s *" % (entry['mac_address'], | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above - can you check if the lease should have a high expiry (80yrs or inf?) instead of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0 is infinite lease time (generally the epoch when the lease expires), * is the client id (which is generally the mac, but can change) |
||
| entry['ipv4_address'], | ||
| entry['host_name'])) | ||
|
|
||
| i = IPAddress(entry['ipv4_address']) | ||
| # Calculate the device | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhtyd @davidjumani
the only issue I see is, dnsmasq will be restarted each time when conf/host/dhcp lease is changed.
if there are many vms in the network, might it be a problem ?
it is not caused by this pr , but the line above
might it be better to restart dnsmasq when all are processed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I could see at https://github.com/apache/cloudstack/blob/master/systemvm/debian/opt/cloud/bin/cs/CsFile.py#L58, a commit returns a boolean value of whether the file has changed, so if it tries to add a host which already exists in the file, it shouldn't restart dnsmasq
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhtyd @davidjumani no worries, it looks good.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidjumani from my testing, dnsmasq will be restarted each time when start a vm.
it's better to reload it. not a big problem.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's linked to #3613
I can create a separate PR to change it globally, but that will require extensive testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidjumani yeah.
@rhtyd this is ready for merge.