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

Run build and tests directly on Ubuntu 20.04, 22.04 without docker #3770

Merged
merged 12 commits into from
Dec 17, 2022
Merged

Run build and tests directly on Ubuntu 20.04, 22.04 without docker #3770

merged 12 commits into from
Dec 17, 2022

Conversation

davidbolvansky
Copy link
Contributor

No description provided.

@davidbolvansky davidbolvansky changed the title Rework base of Dockerfile (WIP) Rework base of Dockerfile, run build and tests on 22.04 as well. Dec 10, 2022
@davidbolvansky davidbolvansky changed the title Rework base of Dockerfile, run build and tests on 22.04 as well. Rework base of Dockerfile, run build and tests on 22.04 as well Dec 10, 2022
@davidbolvansky davidbolvansky changed the title Rework base of Dockerfile, run build and tests on 22.04 as well Change base image of Dockerfile to Ubuntu, run build and tests on Ubuntu 22.04 as well Dec 10, 2022
@fruffy
Copy link
Collaborator

fruffy commented Dec 10, 2022

https://github.com/p4lang/third-party/blob/main/Dockerfile contains most of the dependencies. You will also have to install protobuf, thrift, grpc, nanomsg etc. I am not sure if the bmv2 package provides these. But with newer versions they can easily be installed using debian.

@davidbolvansky
Copy link
Contributor Author

https://github.com/p4lang/third-party/blob/main/Dockerfile contains most of the dependencies. You will also have to install protobuf, thrift, grpc, nanomsg etc. I am not sure if the bmv2 package provides these. But with newer versions they can easily be installed using debian.

probably they are installed as building works fine on Ubuntu 22.

@davidbolvansky
Copy link
Contributor Author

davidbolvansky commented Dec 10, 2022

https://github.com/p4lang/third-party/blob/main/Dockerfile contains most of the dependencies. You will also have to install protobuf, thrift, grpc, nanomsg etc. I am not sure if the bmv2 package provides these. But with newer versions they can easily be installed using debian.

probably they are installed as building works fine on Ubuntu 22.

but ptf is missing. So lets switch to ubuntu only for normal tests, default to existing base image.

@davidbolvansky davidbolvansky changed the title Change base image of Dockerfile to Ubuntu, run build and tests on Ubuntu 22.04 as well Run build and tests on Ubuntu 22.04 as well Dec 10, 2022
@fruffy
Copy link
Collaborator

fruffy commented Dec 10, 2022

but ptf is missing. So lets switch to ubuntu only for normal tests, default to existing base image.

Isn't this install just pip3 install --user ptf?

@davidbolvansky davidbolvansky changed the title Run build and tests on Ubuntu 22.04 as well Run build and tests on Ubuntu 22.04 Dec 10, 2022
@fruffy
Copy link
Collaborator

fruffy commented Dec 10, 2022

I think it is also fine to just test the build for Ubuntu 18.04 and not run tests since there are limited guarantees.

@davidbolvansky
Copy link
Contributor Author

I think it is also fine to just test the build for Ubuntu 18.04 and not run tests since there are limited guarantees.

I was able to run them so it would be great to keep them for some time. If p4c project after April 2023 decides to drop this CI support for U18 with reasonable reasons, I am fine with that.

@davidbolvansky davidbolvansky marked this pull request as ready for review December 11, 2022 00:34
@davidbolvansky davidbolvansky changed the title Run build and tests on Ubuntu 22.04 Run build and tests on Ubuntu 18.04, 22.04 Dec 11, 2022
ir/ir-inline.h Outdated
@@ -269,7 +269,7 @@ void IR::NameMap<T, MAP, COMP, ALLOC>::visit_children(Visitor& v) {
namemap_insert_helper(i, cstring(obj_name(s)), std::move(s), symbols, new_symbols);
i = symbols.erase(i);
}
} else {
} else if (n) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

new gcc (false positive) warnings..

Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that n maybe be null pointer (not really, sanitizers would catch it)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of the if checks, we should use a BUG_CHECK here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

inline.patch.txt

How about this patch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But does not happen in practice as sanitizers would catch for sure.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, only if we have written the appropriate tests/P4-programs. :)

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should open a separate pull request with these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dont think we need another PR as this PR enables more testing, especially on Ubuntu 22, where we have newer GCC which emits more warnings. Seems OK to me to have such fixes in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests now fail - expected?

Sorry but I would really prefer first version of these changes (my) as your changes seems to break existing tests and I am not going to debug them.

@rst0git
Copy link
Member

rst0git commented Dec 11, 2022

You will also have to install protobuf, thrift, grpc, nanomsg etc. I am not sure if the bmv2 package provides these.

These are listed as dependencies for the bmv2 package.


- name: Build (Ubuntu 22.04, GCC)
run: |
docker build -t p4c --build-arg UBUNTU_VERSION=22.04 --build-arg IMAGE_TYPE=test --build-arg ENABLE_UNIFIED_COMPILATION=ON .
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you even need the docker image at this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, good point, probably not.


# we want to use Python as the default so change the symlinks
ln -sf /usr/bin/python3 /usr/bin/python
ln -sf /usr/bin/pip3 /usr/bin/pip

pip3 install --upgrade pip
pip3 install wheel
Copy link
Collaborator

Choose a reason for hiding this comment

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

wheel might not be needed anymore.

ir/ir-inline.h Outdated
@@ -269,7 +269,7 @@ void IR::NameMap<T, MAP, COMP, ALLOC>::visit_children(Visitor& v) {
namemap_insert_helper(i, cstring(obj_name(s)), std::move(s), symbols, new_symbols);
i = symbols.erase(i);
}
} else {
} else if (n) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the warning?

FROM p4lang/behavioral-model:latest
ARG UBUNTU_VERSION=20.04
ARG BASE_IMAGE=ubuntu:${UBUNTU_VERSION}
FROM ${BASE_IMAGE}
Copy link
Member

@rst0git rst0git Dec 11, 2022

Choose a reason for hiding this comment

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

I think we need to keep p4lang/behavioral-model:latest as default base image.
This Dockerfile is used to automatically build and publish the p4c container image in Docker Hub and this container image is being used in other projects (e.g., p4app).

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could keep this docker file for the release build. With David's new setup we might not need a docker file at all for the p4c image.

run: |
docker build -t p4c --build-arg IMAGE_TYPE=test --build-arg ENABLE_UNIFIED_COMPILATION=ON --build-arg COMPILE_WITH_CLANG=ON \
--build-arg BUILD_AUTO_VAR_INIT_PATTERN=ON --build-arg ENABLE_SANITIZERS=ON .
docker build -t p4c --build-arg BASE_IMAGE=ubuntu:18.04 --build-arg IMAGE_TYPE=test --build-arg ENABLE_UNIFIED_COMPILATION=ON .
Copy link
Collaborator

Choose a reason for hiding this comment

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

This also needs to be updated to use Ubuntu 18.04 directly. Also other images such as the tools test should not use docker anymore then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no Ubuntu 18.04 image for github actions. So nope, not possible.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But we do not modify the base image right now so this will test on the Ubuntu 20.04 docker image as far as I can see.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also other images such as the tools test should not use docker anymore then.

Sorry but for now I am not gonna do everything. We can move it incrementally.

The issue is that the new ci-build configuration seems to break the ccache that has been set up for the docker build process. As far as I can tell, the builds are taking longer now. We can check this by completing one build and rerunning to see whether the build is cached.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Build on Ubuntu 22 - 6m 14s.

Seems pretty OK to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is the other tests, static-build-test-p4c, test-tools, ptf-ebpf, validate etc.

I can convert them but then we would stop testing with Dockerfile so it can slowly bitrot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but this PR is breaking the ccache setup for all other tests.

How? Could you explain it?

Docker builds uses export_ccache.sh which runs
docker cp $(docker create --rm p4c):/p4c/.ccache .
, non-docker runs
sudo cp -rf /p4c/.ccache .

I pushed empty commit to see if regressions are real.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could be this change.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The problem is the other tests, static-build-test-p4c, test-tools, ptf-ebpf, validate etc.

I can convert them but then we would stop testing with Dockerfile so it can slowly bitrot.

We can either convert them or have a workaround. As Radostin mentioned we need to create one docker build either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In general, test-tools will now be the slowest test because the build alone takes 55 minutes.

ccache is working fine, rebuild time: 7m 25s

https://github.com/p4lang/p4c/actions/runs/3697344554/jobs/6262220551

./tools/export_ccache.sh
sudo cp -rf . /p4c/
(cd /p4c/ && sudo -E tools/ci-build.sh)
sudo cp -rf /p4c/.ccache .
Copy link
Collaborator

Choose a reason for hiding this comment

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

Both the cp commands should not be necessary to get ccache to work.

Copy link
Contributor Author

@davidbolvansky davidbolvansky Dec 14, 2022

Choose a reason for hiding this comment

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

ci-build.sh uses /p4c/

We would be more flexible after we drop docker, but for now, things needs to be done this way, probably.

I will think about it but probably I would leave it for followup, as this change is quite huge anyway.

@davidbolvansky davidbolvansky changed the title Run build and tests on Ubuntu 18.04, 22.04 Run build and tests directly on Ubuntu 18.04, 22.04 without docker Dec 14, 2022
@davidbolvansky davidbolvansky changed the title Run build and tests directly on Ubuntu 18.04, 22.04 without docker Run build and tests directly on Ubuntu 20.04, 22.04 without docker Dec 14, 2022
@davidbolvansky
Copy link
Contributor Author

Based on new runs, I believe ccache is working fine, rebuild times are short.

@davidbolvansky
Copy link
Contributor Author

davidbolvansky commented Dec 14, 2022

CI also significatly faster.

for example sanitizers 120min -> 71 min.

My assumption is that CTEST_PARALLEL_LEVEL was not handled correctly (when you run something with sudo you lose env vars, you need to use -E switch)

@davidbolvansky
Copy link
Contributor Author

Ok, done

@fruffy
Copy link
Collaborator

fruffy commented Dec 15, 2022

Looks good. The question is what we do with the docker build process that publishes builds to dockerhub. Have a nightly test run?

@davidbolvansky
Copy link
Contributor Author

Or we can preserve testing with docker on U20. I dont know..

@fruffy
Copy link
Collaborator

fruffy commented Dec 15, 2022

@rst0git any thoughts on this?

@rst0git
Copy link
Member

rst0git commented Dec 15, 2022

The question is what we do with the docker build process that publishes builds to dockerhub.

With the following change, when BASE_IMAGE is not specified, the container image should be the same.

-FROM p4lang/behavioral-model:latest
+ARG BASE_IMAGE=p4lang/behavioral-model:latest
+FROM ${BASE_IMAGE}

I think with these changes the CI workflow updating the container image in Dockerhub should continue to work as expected.

@fruffy
Copy link
Collaborator

fruffy commented Dec 16, 2022

The question is what we do with the docker build process that publishes builds to dockerhub.

With the following change, when BASE_IMAGE is not specified, the container image should be the same.

-FROM p4lang/behavioral-model:latest
+ARG BASE_IMAGE=p4lang/behavioral-model:latest
+FROM ${BASE_IMAGE}

I think with these changes the CI workflow updating the container image in Dockerhub should continue to work as expected.

It'd be nice if we ran tests on this release build. This way we can make sure the docker build does not rot.

@fruffy
Copy link
Collaborator

fruffy commented Dec 16, 2022

@antoninbas @mbudiu-vmw

This PR would remove the docker third-party build from most of the tests. Any further concerns?

@antoninbas
Copy link
Member

no concern from me, but then I am not the one maintaining this

@rst0git
Copy link
Member

rst0git commented Dec 16, 2022

It'd be nice if we ran tests on this release build. This way we can make sure the docker build does not rot.

If something with the container image ever breaks, we can introduce the necessary tests.

@mihaibudiu
Copy link
Contributor

I am not maintaining this either

@davidbolvansky
Copy link
Contributor Author

It'd be nice if we ran tests on this release build. This way we can make sure the docker build does not rot.

If something with the container image ever breaks, we can introduce the necessary tests.

Yes, exactly.

@davidbolvansky
Copy link
Contributor Author

@fruffy is it ok for you?

@rst0git
Copy link
Member

rst0git commented Dec 17, 2022

I am not maintaining this either

I would be happy to be a maintainer.

@davidbolvansky davidbolvansky merged commit 9bfb5a1 into p4lang:main Dec 17, 2022
@davidbolvansky davidbolvansky deleted the dbolvans/docker_ubuntu branch December 17, 2022 13:21
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.

5 participants