coreemu / core

Common Open Research Emulator
BSD 2-Clause "Simplified" License
685 stars 165 forks source link

[BUG] Build from Dockerfile.ubuntu fails in ospf-mdr build. #833

Closed billw1955 closed 5 months ago

billw1955 commented 1 year ago

Describe the bug Build from Dockerfile.ubuntu fails. Apparently, a problem in ospf-mdr - I opened https://github.com/USNavalResearchLaboratory/ospf-mdr/issues/8, but you might see a workaround.

To Reproduce Follow coreemu document to build docker image from ubuntu base: docker build -t core -f dockerfiles/Dockerfile.ubuntu .

Error

In file included from interface.c:37:
../zebra/rtadv.h:71:8: error: redefinition of ‘struct nd_opt_adv_interval’
   71 | struct nd_opt_adv_interval {   /* Advertisement interval option */
      |        ^~~~~~~~~~~~~~~~~~~
In file included from ../lib/zebra.h:211,
                 from interface.c:23:
/usr/include/netinet/icmp6.h:329:8: note: originally defined here
  329 | struct nd_opt_adv_interval
      |        ^~~~~~~~~~~~~~~~~~~

core version 20071eed (HEAD -> master, tag: release-9.0.3, origin/master, origin/HEAD) Merge pull request #808 from coreemu/develop

bharnden commented 1 year ago

Does this actually currently end the build? I just pulled master and built with this file without issue. There are some currently expected errors that occur within the OSPF MDR build, but nothing that bails out on the build and stops standard functionality.

Also OSPF MDR in itself is not a hard requirement, but is technically a requirement currently for some of the default behavior for some of the nodes. There has been talks to transition away in the past, since OSPF MDR is not actively really being maintained.

billw1955 commented 1 year ago

Yes, it does end the build of the image:

make[2]: Leaving directory '/opt/ospf-mdr/zebra'
make[1]: *** [Makefile:481: all-recursive] Error 1
make[1]: Leaving directory '/opt/ospf-mdr'
make: *** [Makefile:413: all] Error 2
The command '/bin/sh -c git clone https://github.com/coreemu/core &&     cd core &&     git checkout ${BRANCH} &&     ./setup.sh &&     PATH=/root/.local/bin:$PATH inv install -v -p ${PREFIX} &&     cd /opt &&     rm -rf ospf-mdr' returned a non-zero code: 2
coreuser@host $
bharnden commented 1 year ago

What OS and version of docker are you using? I can see if I can replicate the problem, but right now, I cannot reproduce.

billw1955 commented 1 year ago

Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1

PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"

And your instance has the clashing header - /usr/include/netinet/icmp6.h?

bharnden commented 1 year ago

Starting up the container and checking

root@d307c230b0a6:~# ll /usr/include/netinet/icmp6.h
-rw-r--r-- 1 root root 11597 Sep 25 14:45 /usr/include/netinet/icmp6.h

My base Ubuntu image is cached from quite some time ago, so potentially that is related. I can try clearing it out and rebuilding to check.

billw1955 commented 1 year ago

Hmm, don't need ospf-mdr? So, something like set ospf to False in tasks.py:install?

bharnden commented 1 year ago

You can add --no-ospf to the inv install line to avoid it. You don't technically need it, but it is used by default in nodes and then it all depends on what you want to do etc, for how it might matter.

I tried building again on an Ubuntu 22.04 instance, albeit mine is slightly older and again, did not have issue. Even with making sure to clear out any existing base images (in case it mattered in any way).

My Docker version is different, but feels odd it would matter here:

Client: Docker Engine - Community
 Version:           20.10.18
 API version:       1.41
 Go version:        go1.18.6
 Git commit:        b40c2f6
 Built:             Thu Sep  8 23:11:43 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

My OS:

PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
billw1955 commented 1 year ago

This got me an image (need --no-check-certificate for the corporate MitM proxy)

diff --git a/dockerfiles/Dockerfile.ubuntu b/dockerfiles/Dockerfile.ubuntu
index 8eceebf7..6f19006f 100644
--- a/dockerfiles/Dockerfile.ubuntu
+++ b/dockerfiles/Dockerfile.ubuntu
@@ -22,6 +22,7 @@ RUN apt-get update -y && \
     libpcre3-dev \
     libprotobuf-dev \
     libxml2-dev \
+    libtool \
     protobuf-compiler \
     unzip \
     uuid-dev \
@@ -34,13 +35,14 @@ RUN apt-get update -y && \
 RUN git clone https://github.com/coreemu/core && \
     cd core && \
     git checkout ${BRANCH} && \
+    sed -i 's/ospf=True/ospf=False/' tasks.py && \
     ./setup.sh && \
     PATH=/root/.local/bin:$PATH inv install -v -p ${PREFIX} && \
     cd /opt && \
     rm -rf ospf-mdr

 # install emane
-RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && \
+RUN wget --no-check-certificate https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && \
     mkdir protoc && \
     unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d protoc && \
     git clone https://github.com/adjacentlink/emane.git && \
root@5c2d20e2b449:~# cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

root@5c2d20e2b449:~# core-cli
usage: core-cli [-h] [-js] {session,node,link,query,xml,wlan} ...
core-cli: error: the following arguments are required: command
root@5c2d20e2b449:~# core-python
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
bharnden commented 1 year ago

Maybe there is more to what you are receiving from your proxy that is impacting things, since I cannot reproduce your issue at all. The whole intent of Docker is to help isolate some of these issues into a constant repeated case, but potentially if what is being pulled down is different, that could explain it.

billw1955 commented 1 year ago

Yes, there're many packages pulled in from the outside in the Dockerfile. I've been looking carefully for evidence of the proxy changing something and haven't spotted anything to indicate the proxy is redirecting any request to, say, an internal mirror. To go back one step, this is the image I get for ubuntu 22.04:

# docker pull ubuntu:22.04
22.04: Pulling from library/ubuntu
Digest: sha256:2b7412e6465c3c7fc5bb21d3e6f1917c167358449fecac8176c6e496e5c1f05f
Status: Image is up to date for ubuntu:22.04
docker.io/library/ubuntu:22.04
bharnden commented 1 year ago

That is the identical starting image I have for my successful build on Ubuntu 22.04.1. But its possible it could be impacting everything else pulled and installed during the build, which would likely be much harder to compare.

bharnden commented 1 year ago

If its possible to attempt a build outside of your proxy scenario in some way and you have success. That would at least help isolate the main difference causing the problem.

billw1955 commented 1 year ago

Got it. I will look more closely for a way to eliminate or identity the proxy as the problem. Thank you.