EC2 metadata retuns ip of instance and ip of nova-api service node

Bug #1334857 reported by NickS
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Matthew Gilliard

Bug Description

curl -vL http://169.254.169.254/latest/meta-data/local-ipv4/
* About to connect() to 169.254.169.254 port 80 (#0)
* Trying 169.254.169.254... connected
* Connected to 169.254.169.254 (169.254.169.254) port 80 (#0)
> GET /latest/meta-data/local-ipv4/ HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: 169.254.169.254
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
< Content-Length: 12
< Date: Sun, 22 Jun 2014 15:15:52 GMT
<
* Connection #0 to host 169.254.169.254 left intact
* Closing connection #0
192.168.0.22, 10.2.0.50

192.168.0.22 - instance ip 10.2.0.50 - controller ip

Happens only for /latest/meta-data/local-ipv4/

Quick investigation shows that the issue is caused by

https://github.com/openstack/nova/blob/master/nova/api/metadata/base.py#L243 (https://github.com/openstack/nova/blo...)

'local-ipv4': self.address or fixed_ip, string

self.address variable contains "192.168.0.22, 10.2.0.50" while fixed_ip contains correct "192.168.0.22" value.

The workaround is: swapping those two variables: 'local-ipv4': fixed_ip or self.address, and restart of all nova-compute services

Tags: ec2
lizheming (lizheming-li)
Changed in nova:
assignee: nobody → lizheming (lizheming-li)
Revision history for this message
lizheming (lizheming-li) wrote :
Revision history for this message
NickS (n-stakanov) wrote :

Yep correct.
But when you do curl -vL http://169.254.169.254/latest/meta-data/local-ipv4/
it returns <instanceIP, Controller_Local_IP>
curl -vL http://169.254.169.254/latest/meta-data/local-ipv4/ -> 192.168.0.22, 10.2.0.50

instead of curl -vL http://169.254.169.254/latest/meta-data/local-ipv4/ -> 192.168.0.22

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/104138

Changed in nova:
status: New → In Progress
Revision history for this message
Dag Stenstad (dag-stenstad) wrote :

I applied the following patch to my havana nova-api to get this working:

$ diff base.py /usr/share/pyshared/nova/api/metadata/base.py
195,197d194
< fixed_ips = self.ip_info['fixed_ips']
< fixed_ip = fixed_ips and fixed_ips[0] or ''
<
206c203
< 'local-ipv4': fixed_ip or self.address,
---
> 'local-ipv4': self.address,

local-ipv4 is used by CoreOS/discovery.etcd.io to get instances to talk to eachother.

Changed in nova:
assignee: lizheming (lizheming-li) → Matthew Gilliard (matthew-gilliard-u)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/104138
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=68789d58792ec149bea5e06a7ca1123141daa486
Submitter: Jenkins
Branch: master

commit 68789d58792ec149bea5e06a7ca1123141daa486
Author: lizheming <email address hidden>
Date: Wed Jul 2 17:34:02 2014 +0800

    Get EC2 metadata localip return controller node ip

    When Get EC2 metadata localip, it will return
    <instanceIP, Controller_Local_IP>, but for ec2
    metadata localip, it expects to return instanceIP.
    This patch fixes the issue.

    Change-Id: I6c42e713265ebb3138f7a94df5ee996e6f68d02f
    Closes-Bug: #1334857

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → kilo-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: kilo-1 → 2015.1.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.