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

Srv6d openstack dualstack #1805

Merged
merged 3 commits into from
Nov 17, 2022
Merged

Srv6d openstack dualstack #1805

merged 3 commits into from
Nov 17, 2022

Conversation

SRv6d
Copy link
Contributor

@SRv6d SRv6d commented Oct 28, 2022

Proposed Commit Message

Add Support for IPv6 metadata to DataSourceOpenStack

Add Support for IPv6 metadata to `DataSourceOpenStack`

- Add openstack IPv6 metadata url `fe80::a9fe:a9fe`
- Enable requesting multiple metadata sources in parallel

This PR is very similar to #1160, reusing the provided `url_heper` logic.

LP: #1906849 

Additional Context

Test Steps

cloud-init clean --logs
cloud-init init --local

Will successfully request metadata over IPv6 from the openstack provider, given
it is reachable over IPv6. If not, or if IPv4 is faster it will be used instead.

Checklist:

  • My code follows the process laid out in the documentation
  • I have updated or added any unit tests accordingly
  • I have updated or added any documentation accordingly

@holmanb
Copy link
Member

holmanb commented Oct 29, 2022

Thanks for the PR! Could you please insert your github username alphabetically (with matching capitalization) instead of at the bottom?

@SRv6d
Copy link
Contributor Author

SRv6d commented Oct 31, 2022

Sure, done.

@holmanb holmanb self-assigned this Nov 8, 2022
@holmanb
Copy link
Member

holmanb commented Nov 8, 2022

With AWS we went ipv4 first, since many of their instances don't have a functioning ipv6 IMDS. When all new AWS deployments get an ipv6 imds we intend to switch this order to prioritize ipv6.

In this current PR, the ipv6 address will be tried first with a minor delay before ipv4. Since I think new openstack deployments are expected to have an ipv6 IMDS, I think this approach makes sense. I'm mentioning this in case anyone with more depth in openstack wants to chime in.

@TheRealFalcon
Copy link
Member

I think it makes more sense to keep IPv4 first as you're still likely to have tons of deployments without IPv6.

@SRv6d
Copy link
Contributor Author

SRv6d commented Nov 9, 2022

@TheRealFalcon In my tests there weren't any noticeable delays with v4 metadata caused by this change. In my opinion this behaviour makes sense, since most users would expect a happy eyeballs like approach and ipv4 is seldomly preferred when ipv6 is available.

Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the PR!

  • CLA signed

@holmanb holmanb merged commit 25da3c7 into canonical:main Nov 17, 2022
@SRv6d SRv6d deleted the srv6d-openstack-dualstack branch November 19, 2022 16:40
@qsliao
Copy link

qsliao commented Jun 19, 2024

The virtual machine cannot directly access fe80::a9fe
; it needs to add %ens1 to work. Below is the error from cloud-init
'''
2024-06-19 02:05:09,291 - url_helper.py[WARNING]: Exception(s) [UrlError("HTTPConnectionPool(host='fe80::a9fe:a9fe', port=80): Max retries exceeded with url: /openstack (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f345fd8e760>: Failed to establish a new connection: [Errno 22] Invalid argument'))"), UrlError("HTTPConnectionPool(host='169.254.169.254', port=80): Max retries exceeded with url: /openstack (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f3460abf160>: Failed to establish a new connection: [Errno 101] Network is unreachable'))")] during request to http://169.254.169.254/openstack, raising last exception
2024-06-19 02:05:09,291 - url_helper.py[ERROR]: Timed out, no response from urls: ['http://[fe80::a9fe:a9fe]/openstack', 'http://169.254.169.254/openstack']
2024-06-19 02:05:09,291 - DataSourceOpenStack.py[DEBUG]: Giving up on OpenStack md from['http://[fe80::a9fe:a9fe]/openstack', 'http://169.254.169.254/openstack'] after 0 seconds
'''
Manual testing of the requests library
image

@qsliao
Copy link

qsliao commented Jun 19, 2024

The following is the configuration for virtual machine IPv6

[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc mq state UP group default qlen 1000
    link/ether 52:54:00:28:94:88 brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    altname ens1
    inet6 2001:2:0:68d7:0:4:0:2/128 scope global dynamic noprefixroute
       valid_lft 84885sec preferred_lft 84885sec
    inet6 fe80::5054:ff:fe28:9488/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
[root@localhost ~]#
[root@localhost ~]# ip -6 route list
::1 dev lo proto kernel metric 256 pref medium
2001:2:0:68d7:0:4:0:2 dev eth0 proto kernel metric 100 pref medium
2001:2:0:68d7::/64 dev eth0 proto ra metric 100 pref medium
fe80::/64 dev eth0 proto kernel metric 1024 pref medium
default via fe80::1 dev eth0 proto ra metric 100 pref medium

@frittentheke
Copy link
Contributor

frittentheke commented Jun 20, 2024

@qsliao I converted your comments into a bug report: #5422
and proposed a PR to fix this: #5419

Please check if this works you and kindly comment on my PR.

@ani-sinha
Copy link
Contributor

After application of this change to 24.1.4 cloud-init, we are failing a test which surprisingly passes when we use Ubuntu's 24.3.1 version of cloud-init under identical setup:

[K         Starting [0;1;39mcloud-init.service[0m - Cloud-init: Network Stage...
[   51.425393] cloud-init[1155]: Cloud-init v. 24.2-1.el10.xiachen202410081653 running 'init' at Sat, 12 Oct 2024 07:35:28 +0000. Up 51.40 seconds.
[   51.458179] cloud-init[1155]: ci-info: +++++++++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++++++++
[   51.466753] cloud-init[1155]: ci-info: +--------+------+------------------------------+-----------+--------+-------------------+
[   51.475232] cloud-init[1155]: ci-info: | Device |  Up  |           Address            |    Mask   | Scope  |     Hw-Address    |
[   51.483694] cloud-init[1155]: ci-info: +--------+------+------------------------------+-----------+--------+-------------------+
[   51.492234] cloud-init[1155]: ci-info: | enp3s0 | True | fd2e:6f44:5dd8:c956::9f/128  |     .     | global | fa:16:3e:be:3d:62 |
[   51.500750] cloud-init[1155]: ci-info: | enp3s0 | True | fe80::f816:3eff:febe:3d62/64 |     .     |  link  | fa:16:3e:be:3d:62 |
[   51.509193] cloud-init[1155]: ci-info: |   lo   | True |          127.0.0.1           | 255.0.0.0 |  host  |         .         |
[   51.517523] cloud-init[1155]: ci-info: |   lo   | True |           ::1/128            |     .     |  host  |         .         |
[   51.525862] cloud-init[1155]: ci-info: +--------+------+------------------------------+-----------+--------+-------------------+
[   51.534528] cloud-init[1155]: ci-info: ++++++++++++++++++++++++++++++++++Route IPv6 info+++++++++++++++++++++++++++++++++++
[   51.543976] cloud-init[1155]: ci-info: +-------+--------------------------+---------------------------+-----------+-------+
[   51.552187] cloud-init[1155]: ci-info: | Route |       Destination        |          Gateway          | Interface | Flags |
[   51.560231] cloud-init[1155]: ci-info: +-------+--------------------------+---------------------------+-----------+-------+
[   51.568184] cloud-init[1155]: ci-info: |   0   | fd2e:6f44:5dd8:c956::9f  |             ::            |   enp3s0  |   U   |
[   51.576194] cloud-init[1155]: ci-info: |   1   | fd2e:6f44:5dd8:c956::/64 |             ::            |   enp3s0  |   U   |
[   51.584119] cloud-init[1155]: ci-info: |   2   |        fe80::/64         |             ::            |   enp3s0  |   U   |
[   51.592097] cloud-init[1155]: ci-info: |   3   |           ::/0           | fe80::f816:3eff:fea6:4411 |   enp3s0  |   UG  |
[   51.599952] cloud-init[1155]: ci-info: |   5   |          local           |             ::            |   enp3s0  |   U   |
[   51.607837] cloud-init[1155]: ci-info: |   6   |          local           |             ::            |   enp3s0  |   U   |
[   51.615757] cloud-init[1155]: ci-info: |   7   |        multicast         |             ::            |   enp3s0  |   U   |
[   51.623673] cloud-init[1155]: ci-info: +-------+--------------------------+---------------------------+-----------+-------+
[   51.660201] cloud-init[1155]: 2024-10-12 07:35:29,188 - url_helper.py[WARNING]: Exception(s) [UrlError("HTTPConnectionPool(host='fe80::a9fe:a9fe%25enp3s0', port=80): Max retries exceeded with url: /openstack (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f36e5042a50>: Failed to establish a new connection: [Errno -2] Name or service not known'))"), UrlError("HTTPConnectionPool(host='169.254.169.254', port=80): Max retries exceeded with url: /openstack (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f36e5043380>: Failed to establish a new connection: [Errno 101] Network is unreachable'))")] during request to http://169.254.169.254/openstack, raising last exception
[   51.706374] cloud-init[1155]: 2024-10-12 07:35:29,189 - url_helper.py[ERROR]: Timed out, no response from urls: ['http://[fe80::a9fe:a9fe%25enp3s0]/openstack', 'http://169.254.169.254/openstack']
[   51.718984] cloud-init[1155]: 2024-10-12 07:35:29,189 - util.py[WARNING]: No active metadata service found

@ani-sinha
Copy link
Contributor

After application of this change to 24.1.4 cloud-init, we are failing a test which surprisingly passes when we use Ubuntu's 24.3.1 version of cloud-init under identical setup:

[K         Starting [0;1;39mcloud-init.service[0m - Cloud-init: Network Stage...
[   51.425393] cloud-init[1155]: Cloud-init v. 24.2-1.el10.xiachen202410081653 running 'init' at Sat, 12 Oct 2024 07:35:28 +0000. Up 51.40 seconds.
[   51.458179] cloud-init[1155]: ci-info: +++++++++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++++++++
[   51.466753] cloud-init[1155]: ci-info: +--------+------+------------------------------+-----------+--------+-------------------+
[   51.475232] cloud-init[1155]: ci-info: | Device |  Up  |           Address            |    Mask   | Scope  |     Hw-Address    |
[   51.483694] cloud-init[1155]: ci-info: +--------+------+------------------------------+-----------+--------+-------------------+
[   51.492234] cloud-init[1155]: ci-info: | enp3s0 | True | fd2e:6f44:5dd8:c956::9f/128  |     .     | global | fa:16:3e:be:3d:62 |
[   51.500750] cloud-init[1155]: ci-info: | enp3s0 | True | fe80::f816:3eff:febe:3d62/64 |     .     |  link  | fa:16:3e:be:3d:62 |
[   51.509193] cloud-init[1155]: ci-info: |   lo   | True |          127.0.0.1           | 255.0.0.0 |  host  |         .         |
[   51.517523] cloud-init[1155]: ci-info: |   lo   | True |           ::1/128            |     .     |  host  |         .         |
[   51.525862] cloud-init[1155]: ci-info: +--------+------+------------------------------+-----------+--------+-------------------+
[   51.534528] cloud-init[1155]: ci-info: ++++++++++++++++++++++++++++++++++Route IPv6 info+++++++++++++++++++++++++++++++++++
[   51.543976] cloud-init[1155]: ci-info: +-------+--------------------------+---------------------------+-----------+-------+
[   51.552187] cloud-init[1155]: ci-info: | Route |       Destination        |          Gateway          | Interface | Flags |
[   51.560231] cloud-init[1155]: ci-info: +-------+--------------------------+---------------------------+-----------+-------+
[   51.568184] cloud-init[1155]: ci-info: |   0   | fd2e:6f44:5dd8:c956::9f  |             ::            |   enp3s0  |   U   |
[   51.576194] cloud-init[1155]: ci-info: |   1   | fd2e:6f44:5dd8:c956::/64 |             ::            |   enp3s0  |   U   |
[   51.584119] cloud-init[1155]: ci-info: |   2   |        fe80::/64         |             ::            |   enp3s0  |   U   |
[   51.592097] cloud-init[1155]: ci-info: |   3   |           ::/0           | fe80::f816:3eff:fea6:4411 |   enp3s0  |   UG  |
[   51.599952] cloud-init[1155]: ci-info: |   5   |          local           |             ::            |   enp3s0  |   U   |
[   51.607837] cloud-init[1155]: ci-info: |   6   |          local           |             ::            |   enp3s0  |   U   |
[   51.615757] cloud-init[1155]: ci-info: |   7   |        multicast         |             ::            |   enp3s0  |   U   |
[   51.623673] cloud-init[1155]: ci-info: +-------+--------------------------+---------------------------+-----------+-------+
[   51.660201] cloud-init[1155]: 2024-10-12 07:35:29,188 - url_helper.py[WARNING]: Exception(s) [UrlError("HTTPConnectionPool(host='fe80::a9fe:a9fe%25enp3s0', port=80): Max retries exceeded with url: /openstack (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f36e5042a50>: Failed to establish a new connection: [Errno -2] Name or service not known'))"), UrlError("HTTPConnectionPool(host='169.254.169.254', port=80): Max retries exceeded with url: /openstack (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f36e5043380>: Failed to establish a new connection: [Errno 101] Network is unreachable'))")] during request to http://169.254.169.254/openstack, raising last exception
[   51.706374] cloud-init[1155]: 2024-10-12 07:35:29,189 - url_helper.py[ERROR]: Timed out, no response from urls: ['http://[fe80::a9fe:a9fe%25enp3s0]/openstack', 'http://169.254.169.254/openstack']
[   51.718984] cloud-init[1155]: 2024-10-12 07:35:29,189 - util.py[WARNING]: No active metadata service found

@holmanb @frittentheke

@frittentheke
Copy link
Contributor

@ani-sinha please keep the discussion in one place and please check out my idea on the cause: #5419 (comment)

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.

6 participants