Merge ~pkashsurya/cloud-init/+git/cloud-init:gce-dns-fix into cloud-init:master

Proposed by Prakash Surya
Status: Work in progress
Proposed branch: ~pkashsurya/cloud-init/+git/cloud-init:gce-dns-fix
Merge into: cloud-init:master
Diff against target: 12 lines (+1/-0)
1 file modified
systemd/cloud-init.service.tmpl (+1/-0)
Reviewer Review Type Date Requested Status
Ryan Harper Needs Information
Review via email: mp+370335@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ryan Harper (raharper) wrote :

Have you filed a bug on cloud-init? If not, can you do so

https://bugs.launchpad.net/cloud-init/+filebug

Attaching the tarball of cloud-init collect-logs would be quite helpful.

Is this reproducible on Ubuntu images in GCE or other distros?

review: Needs Information
Revision history for this message
Prakash Surya (pkashsurya) wrote :

This is my first time using launchpad, so my apologies if I've done anything incorrectly. Please let me know if I have.

For some more context, read_md() in DataSourceGCE.py will call util.is_resolvable_url() on the address "http://metadata.google.internal/computeMetadata/v1/", which results is calling socket.getaddrinfo() for "metadata.google.internal", and it's this socket.getaddrinfo() call that fails.

Here's the code in question...

DataSourceGCE.py:

160 def read_md(address=None, platform_check=True):
...
173 # If we cannot resolve the metadata server, then no point in trying.
174 if not util.is_resolvable_url(address):
175 LOG.debug("%s is not resolvable", address)
176 ret['reason'] = 'address "%s" is not resolvable' % address
177 return ret

util.py:

1221 def is_resolvable_url(url):
1222 """determine if this url is resolvable (existing or ip)."""
1223 return log_time(logfunc=LOG.debug, msg="Resolving URL: " + url,
1224 func=is_resolvable,
1225 args=(urlparse.urlparse(url).hostname,))

1165 def is_resolvable(name):
...
1198 try:
1199 result = socket.getaddrinfo(name, None)
...
1205 except (socket.gaierror, socket.error):
1206 return False

Revision history for this message
Prakash Surya (pkashsurya) wrote :

> Have you filed a bug on cloud-init? If not, can you do so

I haven't yet. I'll do that now.

> Attaching the tarball of cloud-init collect-logs would be quite helpful.

Sure, I can do that.

> Is this reproducible on Ubuntu images in GCE or other distros?

I have not tried anything besides our slightly modified version of Ubuntu 18.04, so I cannot say either way.

FWIW, it's very easy to reproduce on our Ubuntu-based distro. We simply boot the image in GCE, and then look in "/var/log/cloud-init.log" for the relevant error message.

Revision history for this message
Prakash Surya (pkashsurya) wrote :
Revision history for this message
Prakash Surya (pkashsurya) wrote :

I've attached the results of "cloud-init collect-logs" to the bug.

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

Hi Prakash,

To contribute to cloud-init, 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

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

Please move this back to Needs Review once you've had a chance to sign the CLA.

Unmerged commits

9e0e6df... by Prakash Surya

systemd: Ensure cloud-init.service runs after systemd-resolved.service

When running on some cloud environments we need to be able to resolve
hostnames in order to function properly. Specifically, on GCE, we'll
attempt to resolve the "metadata.google.internal" hostname, which will
end up failing if DNS isn't (yet) working. Thus, this change modifies
"cloud-init.service" to ensure it runs after "systemd-resolved.service".

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/systemd/cloud-init.service.tmpl b/systemd/cloud-init.service.tmpl
2index 5cb0037..c17a155 100644
3--- a/systemd/cloud-init.service.tmpl
4+++ b/systemd/cloud-init.service.tmpl
5@@ -7,6 +7,7 @@ Wants=sshd-keygen.service
6 Wants=sshd.service
7 After=cloud-init-local.service
8 After=systemd-networkd-wait-online.service
9+After=systemd-resolved.service
10 {% if variant in ["ubuntu", "unknown", "debian"] %}
11 After=networking.service
12 {% endif %}

Subscribers

People subscribed via source and target branches