Skip to content

bpftool: Only compile for the relevant platform#339

Merged
aanm merged 1 commit intomasterfrom
pr/HadrienPatte/bpftool
Jul 3, 2025
Merged

bpftool: Only compile for the relevant platform#339
aanm merged 1 commit intomasterfrom
pr/HadrienPatte/bpftool

Conversation

@HadrienPatte
Copy link
Copy Markdown
Member

@HadrienPatte HadrienPatte commented Jun 23, 2025

Currently the bpftool image compiles bpftool for both the "native" arch and crosscompiles for the "aarch64" arch, to then only keep the binary matching the TARGETPLATFORM.

With this PR we only build one version of bpftool based on TARGETPLATFORM.

Additional changes:

  • Fix FromAsCasing and LegacyKeyValueFormat violations
  • Only copy cst test spec in the test stage where it's used to avoid having it in the final image
  • Updated the COMPILERS_IMAGE ref as the one used was a single arch adm64 one, the new one is a proper multi-platform manifest:
crane manifest quay.io/cilium/image-compilers:1732033829-330cbaf@sha256:5c54f614fb8ee7939492aa4b7d74b37922d98199f5993f6d957a1637ce30eb9e
{
  "schemaVersion": 2,
  "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
  "manifests": [
    {
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "digest": "sha256:302fc3b1a13cd7ecf28178f52dd7cdb1757353e3f9468aab7f6200a7912ea999",
      "size": 504,
      "platform": {
        "architecture": "amd64",
        "os": "linux"
      }
    },
    {
      "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
      "digest": "sha256:7ce45a14c376d51b5fa901436f863770d8f60624e4e35b74ff34fd598f5a50e2",
      "size": 504,
      "platform": {
        "architecture": "arm64",
        "os": "linux"
      }
    }
  ]
}

Test of the new image:

docker run --platform linux/arm64 bpftool /bin/bash -c "uname -a && bpftool version"
Linux 36320293ac9a 6.10.14-linuxkit #1 SMP Tue Apr 15 16:00:54 UTC 2025 aarch64 aarch64 aarch64 GNU/Linux
bpftool v7.4.0
using libbpf v1.4
features:
docker run --platform linux/amd64 bpftool /bin/bash -c "uname -a && bpftool version"
Linux 3e38a5621633 6.10.14-linuxkit #1 SMP Tue Apr 15 16:00:54 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
bpftool v7.4.0
using libbpf v1.4
features:

@HadrienPatte HadrienPatte marked this pull request as ready for review June 23, 2025 18:30
@HadrienPatte HadrienPatte requested a review from a team as a code owner June 23, 2025 18:30
@HadrienPatte HadrienPatte requested a review from ti-mo June 23, 2025 18:30
@HadrienPatte HadrienPatte force-pushed the pr/HadrienPatte/bpftool branch 2 times, most recently from 48fb19d to 74fe4e8 Compare June 24, 2025 08:57
Copy link
Copy Markdown
Contributor

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

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

Thanks! One nit and a question.

@HadrienPatte HadrienPatte force-pushed the pr/HadrienPatte/bpftool branch from 74fe4e8 to 3e0ff56 Compare July 1, 2025 11:58
Copy link
Copy Markdown
Contributor

@ti-mo ti-mo left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the feedback! One more nit.

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
@HadrienPatte HadrienPatte force-pushed the pr/HadrienPatte/bpftool branch from 3e0ff56 to e4609e3 Compare July 1, 2025 19:19
@HadrienPatte HadrienPatte added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jul 1, 2025
@aanm aanm merged commit 11a6d98 into master Jul 3, 2025
13 checks passed
@aanm aanm deleted the pr/HadrienPatte/bpftool branch July 3, 2025 07:24
HadrienPatte added a commit to cilium/cilium that referenced this pull request Aug 23, 2025
With #41230, renovate will now handle updating those images, but since
they haven't been updated in a while, there's some manual adjustments
that are required before renovate can handle those.

With cilium/image-tools#339 and
cilium/image-tools#343, these two images no
longer include their test files. This PR removes the test stage from the
`runtime` image as it was just rerunning those tests and there are no
`runtime` image tests.

This PR also fixes the tests for the `builder` image. It turns out that
those tests have been broken since #32767 because they haven't been
running in CI for years. Those tests aren't running since we switched
from the legacy docker engine to buildkit, see [details](https://docs.docker.com/build/building/multi-stage/#differences-between-legacy-builder-and-buildkit):

> The legacy Docker Engine builder processes all stages of a Dockerfile leading up to the selected --target. It will build a stage even if the selected target doesn't depend on that stage.
>
> BuildKit only builds the stages that the target stage depends on.

Future followups:
* Does it make sense to have a test expect a specific version of `libprotoc` when this dependency is regularly automatically updated by renovate? With the current setup, this test will break everytime renovate updates `libprotoc`. I'd argue that the version string should be removed from the expected output so we only test that `protoc --version` runs sucessfully without expecting a given version string.
* Consider either:
  * Update the CI to ensure those container structure tests are run on
    PRs
  * Remove container structure tests as after this PR, only the `builder` image will have [some](https://github.com/cilium/cilium/blob/a7de0143835a080750dbbde7285be37ab8599883/images/builder/test/spec.yaml) and all they test is that `protoc` is installed in the image

Note: the release note for this PR is more focused on the user-visible
change related to the update of the `bpftools` and `llvm` images.

```release
images: Update `bpftools` and `llvm` images to reduce the size of the
`cilium` image by 39MB (`amd64`) / 35MB (arm64)
```

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
HadrienPatte added a commit to cilium/cilium that referenced this pull request Aug 23, 2025
With #41230, renovate will now handle updating those images, but since
they haven't been updated in a while, there's some manual adjustments
that are required before renovate can handle those.

With cilium/image-tools#339 and
cilium/image-tools#343, these two images no
longer include their test files. This PR removes the test stage from the
`runtime` image as it was just rerunning those tests and there are no
`runtime` image tests.

This PR also fixes the tests for the `builder` image. It turns out that
those tests have been broken since #32767 because they haven't been
running in CI for years. Those tests aren't running since we switched
from the legacy docker engine to buildkit, see [details](https://docs.docker.com/build/building/multi-stage/#differences-between-legacy-builder-and-buildkit):

> The legacy Docker Engine builder processes all stages of a Dockerfile leading up to the selected --target. It will build a stage even if the selected target doesn't depend on that stage.
>
> BuildKit only builds the stages that the target stage depends on.

Future followups:
* Does it make sense to have a test expect a specific version of `libprotoc` when this dependency is regularly automatically updated by renovate? With the current setup, this test will break everytime renovate updates `libprotoc`. I'd argue that the version string should be removed from the expected output so we only test that `protoc --version` runs successfully without expecting a given version string.
* Consider either:
  * Update the CI to ensure those container structure tests are run on
    PRs
  * Remove container structure tests as after this PR, only the `builder` image will have [some](https://github.com/cilium/cilium/blob/a7de0143835a080750dbbde7285be37ab8599883/images/builder/test/spec.yaml) and all they test is that `protoc` is installed in the image

Note: the release note for this PR is more focused on the user-visible
change related to the update of the `bpftools` and `llvm` images.

```release
images: Update `bpftools` and `llvm` images to reduce the size of the
`cilium` image by 39MB (`amd64`) / 35MB (arm64)
```

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
HadrienPatte added a commit to cilium/cilium that referenced this pull request Sep 3, 2025
With #41230, renovate will now handle updating those images, but since
they haven't been updated in a while, there's some manual adjustments
that are required before renovate can handle those.

With cilium/image-tools#339 and
cilium/image-tools#343, these two images no
longer include their test files. This PR removes the test stage from the
`runtime` image as it was just rerunning those tests and there are no
`runtime` image tests.

This PR also fixes the tests for the `builder` image. It turns out that
those tests have been broken since #32767 because they haven't been
running in CI for years. Those tests aren't running since we switched
from the legacy docker engine to buildkit, see [details](https://docs.docker.com/build/building/multi-stage/#differences-between-legacy-builder-and-buildkit):

> The legacy Docker Engine builder processes all stages of a Dockerfile leading up to the selected --target. It will build a stage even if the selected target doesn't depend on that stage.
>
> BuildKit only builds the stages that the target stage depends on.

Future followups:
* Does it make sense to have a test expect a specific version of `libprotoc` when this dependency is regularly automatically updated by renovate? With the current setup, this test will break everytime renovate updates `libprotoc`. I'd argue that the version string should be removed from the expected output so we only test that `protoc --version` runs successfully without expecting a given version string.
* Consider either:
  * Update the CI to ensure those container structure tests are run on
    PRs
  * Remove container structure tests as after this PR, only the `builder` image will have [some](https://github.com/cilium/cilium/blob/a7de0143835a080750dbbde7285be37ab8599883/images/builder/test/spec.yaml) and all they test is that `protoc` is installed in the image

Note: the release note for this PR is more focused on the user-visible
change related to the update of the `bpftools` and `llvm` images.

```release
images: Update `bpftools` and `llvm` images to reduce the size of the
`cilium` image by 39MB (`amd64`) / 35MB (arm64)
```

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
HadrienPatte added a commit to cilium/cilium that referenced this pull request Sep 4, 2025
With #41230, renovate will now handle updating those images, but since
they haven't been updated in a while, there's some manual adjustments
that are required before renovate can handle those.

With cilium/image-tools#339 and
cilium/image-tools#343, these two images no
longer include their test files. This PR removes the test stage from the
`runtime` image as it was just rerunning those tests and there are no
`runtime` image tests.

This PR also fixes the tests for the `builder` image. It turns out that
those tests have been broken since #32767 because they haven't been
running in CI for years. Those tests aren't running since we switched
from the legacy docker engine to buildkit, see [details](https://docs.docker.com/build/building/multi-stage/#differences-between-legacy-builder-and-buildkit):

> The legacy Docker Engine builder processes all stages of a Dockerfile leading up to the selected --target. It will build a stage even if the selected target doesn't depend on that stage.
>
> BuildKit only builds the stages that the target stage depends on.

Future followups:
* Does it make sense to have a test expect a specific version of `libprotoc` when this dependency is regularly automatically updated by renovate? With the current setup, this test will break everytime renovate updates `libprotoc`. I'd argue that the version string should be removed from the expected output so we only test that `protoc --version` runs successfully without expecting a given version string.
* Consider either:
  * Update the CI to ensure those container structure tests are run on
    PRs
  * Remove container structure tests as after this PR, only the `builder` image will have [some](https://github.com/cilium/cilium/blob/a7de0143835a080750dbbde7285be37ab8599883/images/builder/test/spec.yaml) and all they test is that `protoc` is installed in the image

Note: the release note for this PR is more focused on the user-visible
change related to the update of the `bpftools` and `llvm` images.

```release
images: Update `bpftools` and `llvm` images to reduce the size of the
`cilium` image by 39MB (`amd64`) / 35MB (arm64)
```

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
HadrienPatte added a commit to DataDog/cilium that referenced this pull request Sep 8, 2025
With cilium#41230, renovate will now handle updating those images, but since
they haven't been updated in a while, there's some manual adjustments
that are required before renovate can handle those.

With cilium/image-tools#339 and
cilium/image-tools#343, these two images no
longer include their test files. This PR removes the test stage from the
`runtime` image as it was just rerunning those tests and there are no
`runtime` image tests.

This PR also fixes the tests for the `builder` image. It turns out that
those tests have been broken since cilium#32767 because they haven't been
running in CI for years. Those tests aren't running since we switched
from the legacy docker engine to buildkit, see [details](https://docs.docker.com/build/building/multi-stage/#differences-between-legacy-builder-and-buildkit):

> The legacy Docker Engine builder processes all stages of a Dockerfile leading up to the selected --target. It will build a stage even if the selected target doesn't depend on that stage.
>
> BuildKit only builds the stages that the target stage depends on.

Future followups:
* Does it make sense to have a test expect a specific version of `libprotoc` when this dependency is regularly automatically updated by renovate? With the current setup, this test will break everytime renovate updates `libprotoc`. I'd argue that the version string should be removed from the expected output so we only test that `protoc --version` runs successfully without expecting a given version string.
* Consider either:
  * Update the CI to ensure those container structure tests are run on
    PRs
  * Remove container structure tests as after this PR, only the `builder` image will have [some](https://github.com/cilium/cilium/blob/a7de0143835a080750dbbde7285be37ab8599883/images/builder/test/spec.yaml) and all they test is that `protoc` is installed in the image

Note: the release note for this PR is more focused on the user-visible
change related to the update of the `bpftools` and `llvm` images.

```release
images: Update `bpftools` and `llvm` images to reduce the size of the
`cilium` image by 39MB (`amd64`) / 35MB (arm64)
```

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
github-merge-queue bot pushed a commit to cilium/cilium that referenced this pull request Sep 9, 2025
With #41230, renovate will now handle updating those images, but since
they haven't been updated in a while, there's some manual adjustments
that are required before renovate can handle those.

With cilium/image-tools#339 and
cilium/image-tools#343, these two images no
longer include their test files. This PR removes the test stage from the
`runtime` image as it was just rerunning those tests and there are no
`runtime` image tests.

This PR also fixes the tests for the `builder` image. It turns out that
those tests have been broken since #32767 because they haven't been
running in CI for years. Those tests aren't running since we switched
from the legacy docker engine to buildkit, see [details](https://docs.docker.com/build/building/multi-stage/#differences-between-legacy-builder-and-buildkit):

> The legacy Docker Engine builder processes all stages of a Dockerfile leading up to the selected --target. It will build a stage even if the selected target doesn't depend on that stage.
>
> BuildKit only builds the stages that the target stage depends on.

Future followups:
* Does it make sense to have a test expect a specific version of `libprotoc` when this dependency is regularly automatically updated by renovate? With the current setup, this test will break everytime renovate updates `libprotoc`. I'd argue that the version string should be removed from the expected output so we only test that `protoc --version` runs successfully without expecting a given version string.
* Consider either:
  * Update the CI to ensure those container structure tests are run on
    PRs
  * Remove container structure tests as after this PR, only the `builder` image will have [some](https://github.com/cilium/cilium/blob/a7de0143835a080750dbbde7285be37ab8599883/images/builder/test/spec.yaml) and all they test is that `protoc` is installed in the image

Note: the release note for this PR is more focused on the user-visible
change related to the update of the `bpftools` and `llvm` images.

```release
images: Update `bpftools` and `llvm` images to reduce the size of the
`cilium` image by 39MB (`amd64`) / 35MB (arm64)
```

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
jarrodb pushed a commit to 46labs/cilium that referenced this pull request Sep 10, 2025
With cilium#41230, renovate will now handle updating those images, but since
they haven't been updated in a while, there's some manual adjustments
that are required before renovate can handle those.

With cilium/image-tools#339 and
cilium/image-tools#343, these two images no
longer include their test files. This PR removes the test stage from the
`runtime` image as it was just rerunning those tests and there are no
`runtime` image tests.

This PR also fixes the tests for the `builder` image. It turns out that
those tests have been broken since cilium#32767 because they haven't been
running in CI for years. Those tests aren't running since we switched
from the legacy docker engine to buildkit, see [details](https://docs.docker.com/build/building/multi-stage/#differences-between-legacy-builder-and-buildkit):

> The legacy Docker Engine builder processes all stages of a Dockerfile leading up to the selected --target. It will build a stage even if the selected target doesn't depend on that stage.
>
> BuildKit only builds the stages that the target stage depends on.

Future followups:
* Does it make sense to have a test expect a specific version of `libprotoc` when this dependency is regularly automatically updated by renovate? With the current setup, this test will break everytime renovate updates `libprotoc`. I'd argue that the version string should be removed from the expected output so we only test that `protoc --version` runs successfully without expecting a given version string.
* Consider either:
  * Update the CI to ensure those container structure tests are run on
    PRs
  * Remove container structure tests as after this PR, only the `builder` image will have [some](https://github.com/cilium/cilium/blob/a7de0143835a080750dbbde7285be37ab8599883/images/builder/test/spec.yaml) and all they test is that `protoc` is installed in the image

Note: the release note for this PR is more focused on the user-visible
change related to the update of the `bpftools` and `llvm` images.

```release
images: Update `bpftools` and `llvm` images to reduce the size of the
`cilium` image by 39MB (`amd64`) / 35MB (arm64)
```

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
NihaNallappagari pushed a commit to NihaNallappagari/cilium that referenced this pull request Sep 17, 2025
With cilium#41230, renovate will now handle updating those images, but since
they haven't been updated in a while, there's some manual adjustments
that are required before renovate can handle those.

With cilium/image-tools#339 and
cilium/image-tools#343, these two images no
longer include their test files. This PR removes the test stage from the
`runtime` image as it was just rerunning those tests and there are no
`runtime` image tests.

This PR also fixes the tests for the `builder` image. It turns out that
those tests have been broken since cilium#32767 because they haven't been
running in CI for years. Those tests aren't running since we switched
from the legacy docker engine to buildkit, see [details](https://docs.docker.com/build/building/multi-stage/#differences-between-legacy-builder-and-buildkit):

> The legacy Docker Engine builder processes all stages of a Dockerfile leading up to the selected --target. It will build a stage even if the selected target doesn't depend on that stage.
>
> BuildKit only builds the stages that the target stage depends on.

Future followups:
* Does it make sense to have a test expect a specific version of `libprotoc` when this dependency is regularly automatically updated by renovate? With the current setup, this test will break everytime renovate updates `libprotoc`. I'd argue that the version string should be removed from the expected output so we only test that `protoc --version` runs successfully without expecting a given version string.
* Consider either:
  * Update the CI to ensure those container structure tests are run on
    PRs
  * Remove container structure tests as after this PR, only the `builder` image will have [some](https://github.com/cilium/cilium/blob/a7de0143835a080750dbbde7285be37ab8599883/images/builder/test/spec.yaml) and all they test is that `protoc` is installed in the image

Note: the release note for this PR is more focused on the user-visible
change related to the update of the `bpftools` and `llvm` images.

```release
images: Update `bpftools` and `llvm` images to reduce the size of the
`cilium` image by 39MB (`amd64`) / 35MB (arm64)
```

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has passed all tests and received consensus from code owners to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants