Merge ~joschi36/cloud-init:use-data-server-dns-entry into cloud-init:master

Proposed by Joshua Hügli
Status: Merged
Approved by: Ryan Harper
Approved revision: cfb75bbc71a5c620d2a65a749e1ba440c1c43837
Merge reported by: Chad Smith
Merged at revision: 9662a8791e53bac40a3a37aa3f5bee3076f7d447
Proposed branch: ~joschi36/cloud-init:use-data-server-dns-entry
Merge into: cloud-init:master
Diff against target: 47 lines (+20/-2)
1 file modified
cloudinit/sources/DataSourceCloudStack.py (+20/-2)
Reviewer Review Type Date Requested Status
Ryan Harper Approve
Server Team CI bot continuous-integration Approve
Joshua Hügli (community) Approve
Scott Moser Needs Information
Dan Watkins Pending
Review via email: mp+371807@code.launchpad.net

Commit message

add data-server dns entry as new metadata server detection

Description of the change

This Merge Requests adds a new preferred way to detect the metadata server address in CloudStack.

CloudStack has in it's Virtual Routers a DNS Server with a DNS entry that directs to the metadata server called 'data-server'. Only the Virtual Router which has a metadata server available will have this record. Therefore it should be the first method to try. If this one fails it goes next to detection via DHCP lease, and then falls back to the default gateway.

To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

test would be nice.

review: Needs Information
Revision history for this message
Joshua Hügli (joschi36) wrote :

added trailing dot

review: Needs Resubmitting
Revision history for this message
Joshua Hügli (joschi36) :
review: Approve
Revision history for this message
Wei Zhou (ustcweizhou) wrote :

Hi Joshua,

in line 21, should dot (.) after "data-server" be removed ?

Have you tested it ?

-Wei

Revision history for this message
Joshua Hügli (joschi36) wrote :

add it to scott moser's request.

> Can you put a trailing '.' on this ?
> So that it does not propogate across 'search' entries? We had a request to do that other places. It seems generally a good idea if possible.

Revision history for this message
Ryan Harper (raharper) wrote :

Hi Joshua,

To contribute, you must sign the Canonical Contributor License Agreement (CLA) [1].

If you have already signed it as an individual, your Launchpad user will be listed in the contributor-agreement-canonical launchpad group [2]. Unfortunately there is no easy way to check if an organization or company you are doing work for has signed. If you are unsure or have questions, email <email address hidden> or ping powersj in #cloud-init channel via freenode.

For information on how to sign, please see the HACKING document [3].

Thanks again, and please feel free to reach out with any questions.


[1] http://www.canonical.com/contributors
[2] https://launchpad.net/~contributor-agreement-canonical/+members
[3] http://cloudinit.readthedocs.io/en/latest/topics/hacking.html

review: Needs Information
Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:8f451890cc6298d171f59723bc999a483f5dd5c9
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1240/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1240//rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Joshua Hügli (joschi36) wrote :

I've signed the CLA.

Is it possible to retest? (can't access the Jenkins)

Also I think that there is no concern from the CloudStack side. This could be merged.

Revision history for this message
Ryan Harper (raharper) wrote :

Hi Joshua,

I'll resubmit this to jenkins for CI and let you know what's going on.

If you've recently signed the CLA it can take a bit before the the cla launchpad group updates. Once CI is passing and the cla group updates with your account we'll be able to land this.

We've recently migrated to github for cloud-init upstream, this post should
help you migrate over there for future contributions.

https://discourse.ubuntu.com/t/cloud-init-upstream-is-moving-to-github/13295

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

FAILED: Continuous integration, rev:8f451890cc6298d171f59723bc999a483f5dd5c9
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1282/
Executed test runs:
    SUCCESS: Checkout
    FAILED: Unit & Style Tests

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1282//rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ryan Harper (raharper) wrote :

The CI failure is related to a change in the pylint versions, we have a fix for this in master. Can you rebase your branch to master and force push here?

review: Needs Fixing
Revision history for this message
Joshua Hügli (joschi36) wrote :

I've rebased my branch please check. @raharper

review: Approve
Revision history for this message
Ryan Harper (raharper) wrote :

Thanks! Started CI up again

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:cfb75bbc71a5c620d2a65a749e1ba440c1c43837
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1283/
Executed test runs:
    SUCCESS: Checkout
    SUCCESS: Unit & Style Tests
    SUCCESS: Ubuntu LTS: Build
    SUCCESS: Ubuntu LTS: Integration
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/cloud-init-ci/1283//rebuild

review: Approve (continuous-integration)
Revision history for this message
Joshua Hügli (joschi36) wrote :

looks like CI is good with it. can this be merged now?

Revision history for this message
Ryan Harper (raharper) wrote :

Yep! Thanks!

review: Approve
Revision history for this message
Chad Smith (chad.smith) wrote :

This merge has landed in commit 9662a879 to cloud-init branch master.

To view that commit see the following URL:
https://github.com/canonical/cloud-init/commit/9662a879

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/sources/DataSourceCloudStack.py b/cloudinit/sources/DataSourceCloudStack.py
2index f185dc7..e333cb5 100644
3--- a/cloudinit/sources/DataSourceCloudStack.py
4+++ b/cloudinit/sources/DataSourceCloudStack.py
5@@ -13,7 +13,7 @@
6 # This file is part of cloud-init. See LICENSE file for license information.
7
8 import os
9-from socket import inet_ntoa
10+from socket import inet_ntoa, getaddrinfo, gaierror
11 from struct import pack
12 import time
13
14@@ -156,6 +156,17 @@ class DataSourceCloudStack(sources.DataSource):
15 return self.metadata['availability-zone']
16
17
18+def get_data_server():
19+ # Returns the metadataserver from dns
20+ try:
21+ addrinfo = getaddrinfo("data-server.", 80)
22+ except gaierror:
23+ LOG.debug("DNS Entry data-server not found")
24+ return None
25+ else:
26+ return addrinfo[0][4][0] # return IP
27+
28+
29 def get_default_gateway():
30 # Returns the default gateway ip address in the dotted format.
31 lines = util.load_file("/proc/net/route").splitlines()
32@@ -218,7 +229,14 @@ def get_vr_address():
33 # If no virtual router is detected, fallback on default gateway.
34 # See http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/4.8/virtual_machines/user-data.html # noqa
35
36- # Try networkd first...
37+ # Try data-server DNS entry first
38+ latest_address = get_data_server()
39+ if latest_address:
40+ LOG.debug("Found metadata server '%s' via data-server DNS entry",
41+ latest_address)
42+ return latest_address
43+
44+ # Try networkd second...
45 latest_address = dhcp.networkd_get_option_from_leases('SERVER_ADDRESS')
46 if latest_address:
47 LOG.debug("Found SERVER_ADDRESS '%s' via networkd_leases",

Subscribers

People subscribed via source and target branches