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

NETOBSERV-848 eBPF agent multi-arch builds (upstream) #100

Merged
merged 4 commits into from
May 11, 2023

Conversation

jpinsonneau
Copy link
Contributor

@jpinsonneau jpinsonneau commented Mar 2, 2023

Implements multi arch builds and add documentation and consistency

$ make help

Usage:
  make <target>

General
  help                  Display this help.
  vendors               Check go vendors
  prereqs               Check if prerequisites are met, and install missing dependencies

Develop
  fmt                   Run go fmt against code.
  lint                  Lint the code
  generate              Generate artifacts of the code repo (pkg/ebpf and pkg/proto packages)
  docker-generate       Create the container that generates the eBPF binaries
  compile               Compile ebpf agent project
  test                  Test code using go test
  coverage-report       Generate coverage report
  coverage-report-html  Generate HTML coverage report
  tests-e2e             Run e2e tests

Images
  image-build           Build MULTIARCH_TARGETS images
  image-push            Push MULTIARCH_TARGETS images
  manifest-build        Build MULTIARCH_TARGETS manifest
  manifest-push         Push MULTIARCH_TARGETS manifest
  ci-images-build       Build CI images
  ci-images-push        Push CI images

shortcuts helpers
  build                 Test and Build ebpf agent
  build-image           Build MULTIARCH_TARGETS images
  push-image            Push MULTIARCH_TARGETS images
  build-manifest        Build MULTIARCH_TARGETS manifest
  push-manifest         Push MULTIARCH_TARGETS manifest
  images                Build and push MULTIARCH_TARGETS images and related manifest
  build-ci-images       Build CI images
  push-ci-images        Push CI images
  ci-images             Build and push CI images

image

Please use netobserv/flowlogs-pipeline#426 for main discussion and this PR only for specific items

Makefile Outdated
@@ -115,14 +112,43 @@ coverage-report-html: cov-exclude-generated
image-build: ## Build OCI image with the manager.
$(OCI_BIN) build --build-arg SW_VERSION="$(SW_VERSION)" -t ${IMG} .
Copy link
Contributor

Choose a reason for hiding this comment

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

why we didn't pass in the new build-arg here and make the platform env var and user can pass in the arch it needs to build for instead of having the new targets

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so the var will update it's value one after the other for multiarch build ? you will loose the ability to run in parallel like make -j multiarch-manifest-build 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking of two make invocation in case of amd and ppc tomorrow could be another platform for ibm or windows

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 didn't found a way to make multiarch-manifest-build dependencies passing environment variables

The trick here is to concat a simple string that build the dependencies using $(foreach T,$(MULTIARCH_TARGETS),image-push/$T )

Does that work for you ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

another alternative would be to always rely on MULTIARCH_TARGETS for both image-build and image-push and totally get rid of multiarch-manifest-build and multiarch-manifest-push commands.

the manifest can either always be created or created only when MULTIARCH_TARGETS contains at least 2 items.

@OlivierCazade @jotak WDYT ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

sry I'd like to wait for Olivier's input here - he's been the one who has most explored the various options

Makefile Outdated
OCI_BIN=podman
endif
endif
OCI_BIN_PATH = $(shell which podman || which docker)
Copy link

Choose a reason for hiding this comment

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

  • If podman doesn't exist, for example, it will display an error message.  This should be suppressed. 
  • It should also check that one of podman or docker exists and quit if that is not the case.
  • Use := instead of =.

Suggest:

OCI_BIN_PATH := $(shell which podman 2> /dev/null || which docker 2> /dev/null)
ifeq ($(OCI_BIN_PATH),)
$(error Requires podman or docker in PATH)
endif

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, I relied on FLP Makefile for such changes. Let's all agree on how to manage that and apply it everywhere !

@jotak @OlivierCazade @msherif1234

Copy link
Member

Choose a reason for hiding this comment

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

How about a slight variation:

OCI_BIN_PATH ?= $(shell which podman 2> /dev/null || which docker 2> /dev/null)
ifeq ($(OCI_BIN_PATH),)
$(error Requires OCI-compliant CLI such as podman or docker in PATH)
endif

?= allows for overriding it, e.g. using a different installation path or another OCI compliant tool

Copy link

Choose a reason for hiding this comment

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

The only problem is that in other parts of the Makefile, it generally uses OCI_BIN, which is the basename of OCI_BIN_PATH (either 'podman' or 'docker') instead of OCI_BIN_PATH which has the absolute path.  Therefore, it's possible if you override OCI_BIN_PATH, OCI_BIN could fail or even use a different version depending on PATH.

You could change all OCI_BIN usage to OCI_BIN_PATH.  There is at least one case where it's using OCI_BIN to determine if you are running docker or podman.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

your suggestions doesn't work with docker.io/library/golang:1.19 image + it's common to simply use $(shell which podman || which docker) without further checks

I'll keep this as is for now

@codecov
Copy link

codecov bot commented Apr 18, 2023

Codecov Report

Merging #100 (072e9e8) into main (beb50b3) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #100   +/-   ##
=======================================
  Coverage   41.80%   41.80%           
=======================================
  Files          30       30           
  Lines        2050     2050           
=======================================
  Hits          857      857           
  Misses       1155     1155           
  Partials       38       38           
Flag Coverage Δ
unittests 41.80% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@msherif1234
Copy link
Contributor

/LGTM

@jpinsonneau
Copy link
Contributor Author

/approve

@openshift-ci
Copy link

openshift-ci bot commented May 11, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jpinsonneau

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit cc0ca5a into netobserv:main May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants