-
-
Save akutz/c1ae7a64ee1bf7503e723e7332063d20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Change netifaces dependency to 0.10.4 | |
Currently versions Ubuntu <=20.10 use netifaces 0.10.4 By requiring | |
netifaces 0.10.9, the VMware datasource omitted itself from cloud-init | |
on Ubuntu <=20.10. | |
This patch changes the netifaces dependency to 0.10.4. While it is true | |
there are patches to netifaces post 0.10.4 that are desirable, testing | |
against the most common network configuration was performed to verify | |
the VMware datasource will still function with netifaces 0.10.4. | |
To verify this patch, two Dockerfiles were created based on Ubuntu | |
20.04: | |
netifaces 0.10.4 | |
FROM ubuntu:20.04 | |
RUN apt-get -y update && \ | |
apt-get -y --no-install-recommends install \ | |
ca-certificates \ | |
curl \ | |
git \ | |
python3 \ | |
python3-configobj \ | |
python3-distutils \ | |
python3-requests \ | |
python3-yaml | |
RUN mkdir -p /usr/local/src && \ | |
git clone https://github.com/canonical/cloud-init.git /usr/local/src/cloud-init | |
RUN apt-get -y --no-install-recommends install python3-netifaces | |
WORKDIR /usr/local/src/cloud-init | |
ENV PYTHONPATH=/usr/local/src/cloud-init | |
CMD [ "/usr/local/src/cloud-init/cloudinit/sources/DataSourceVMware.py" ] | |
ENTRYPOINT [ "/usr/bin/python3" ] | |
netifaces 0.10.9 | |
FROM ubuntu:20.04 | |
RUN apt-get -y update && \ | |
apt-get -y --no-install-recommends install \ | |
ca-certificates \ | |
curl \ | |
git \ | |
python3 \ | |
python3-configobj \ | |
python3-distutils \ | |
python3-requests \ | |
python3-yaml | |
RUN mkdir -p /usr/local/src && \ | |
git clone https://github.com/canonical/cloud-init.git /usr/local/src/cloud-init | |
RUN apt-get -y install python3-pip && pip3 install 'netifaces == 0.10.9' | |
WORKDIR /usr/local/src/cloud-init | |
ENV PYTHONPATH=/usr/local/src/cloud-init | |
CMD [ "/usr/local/src/cloud-init/cloudinit/sources/DataSourceVMware.py" ] | |
ENTRYPOINT [ "/usr/bin/python3" ] | |
The two Dockerfiles were built with the following commands: | |
docker build -t cloud-init-netifaces-0.10.4 \ | |
-f Dockerfile.Ubuntu-20.04-Netifaces-0.10.4 . && \ | |
docker build -t cloud-init-netifaces-0.10.9 \ | |
-f Dockerfile.Ubuntu-20.04-Netifaces-0.10.9 . | |
The following command was used to prove there is no distinguishable | |
difference in the output for the datasource using the different versions of | |
netifaces against a single IPv4 address on a single device: | |
diff -I '"local-ipv4":' \ | |
-I '"addr":' \ | |
-I '"[[:digit:]]\{1,3\}.[[:digit:]]\{1,3\}.[[:digit:]]\{1,3\}.[[:digit:]]\{1,3\}":' \ | |
<(docker run --rm \ | |
--hostname netifaces \ | |
--mac-address 12:34:56:78:9a:bc \ | |
docker.io/library/cloud-init-netifaces-0.10.4 2>/dev/null) \ | |
<(docker run --rm \ | |
--hostname netifaces \ | |
--mac-address 12:34:56:78:9a:bc \ | |
docker.io/library/cloud-init-netifaces-0.10.9 2>/dev/null) | |
Finally, the following series of commands validates netifaces 0.10.4 against | |
a container with multiple network interfaces: | |
docker network create --subnet=172.19.0.0/16 netifaces | |
docker create \ | |
--hostname netifaces \ | |
--network bridge \ | |
--name netifaces-0.10.4 \ | |
docker.io/library/cloud-init-netifaces-0.10.4 && \ | |
docker network connect netifaces netifaces-0.10.4 | |
docker create \ | |
--hostname netifaces \ | |
--network bridge \ | |
--name netifaces-0.10.9 \ | |
docker.io/library/cloud-init-netifaces-0.10.9 && \ | |
docker network connect netifaces netifaces-0.10.9 | |
diff -I '"local-ipv4":' \ | |
-I '"addr":' \ | |
-I '"mac":' \ | |
-I '"[[:digit:]]\{1,3\}.[[:digit:]]\{1,3\}.[[:digit:]]\{1,3\}.[[:digit:]]\{1,3\}":' \ | |
-I '"[[:alnum:]]\{2\}:[[:alnum:]]\{2\}:[[:alnum:]]\{2\}:[[:alnum:]]\{2\}:[[:alnum:]]\{2\}:[[:alnum:]]\{2\}":' \ | |
<(docker start -a netifaces-0.10.4 2>/dev/null) \ | |
<(docker start -a netifaces-0.10.9 2>/dev/null) | |
docker stop netifaces-0.10.4 netifaces-0.10.9 && \ | |
docker rm netifaces-0.10.4 netifaces-0.10.9 | |
While this is not all of the possible network configurations, they are | |
the most common, and it is better to have the VMware datasource on | |
Ubuntu 20.04 with netifaces 0.10.4 than not have the datasource at all. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment