diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 376b2a406..d440f7590 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -37,3 +37,61 @@ jobs: fail_ci_if_error: true verbose: true + kubernetes-integration-tests: + runs-on: ubuntu-latest + strategy: + matrix: + go: ['1.21'] + env: + BPFMAN_AGENT_IMG: quay.io/bpfman/bpfman-agent:int-test + BPFMAN_OPERATOR_IMG: quay.io/bpfman/bpfman-operator:int-test + XDP_PASS_PRIVATE_IMAGE_CREDS: ${{ secrets.XDP_PASS_PRIVATE_IMAGE_CREDS }} + steps: + - name: Check disk space + run: df -h + + - name: Free up space + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + sudo rm -rf /usr/local/lib/android + + - name: Check disk space again + run: df -h + + - name: set up go 1.x + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + + - name: cache go modules + uses: actions/cache@v4 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-build-codegen-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-build-codegen- + - name: checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: build images + run: make build-images + + - name: run integration tests + run: make test-integration + + - name: Check disk space + run: df -h + + ## Upload diagnostics if integration test step failed. + - name: upload diagnostics + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: kubernetes-integration-test-diag + path: /tmp/ktf-diag* + if-no-files-found: ignore diff --git a/Makefile b/Makefile index 046ed57e5..fbfe39d49 100644 --- a/Makefile +++ b/Makefile @@ -302,14 +302,13 @@ build-images: ## Build bpfman, bpfman-agent, and bpfman-operator images. docker build -t ${BPFMAN_AGENT_IMG} -f Containerfile.bpfman-agent ./ .PHONY: push-images -push-images: ## Push bpfman, bpfman-agent, bpfman-operator images. +push-images: ## Push bpfman-agent, bpfman-operator images. docker push ${BPFMAN_OPERATOR_IMG} docker push ${BPFMAN_AGENT_IMG} - docker push ${BPFMAN_IMG} .PHONY: load-images-kind -load-images-kind: ## Load bpfman, bpfman-agent, and bpfman-operator images into the running local kind devel cluster. - kind load docker-image ${BPFMAN_IMG} ${BPFMAN_OPERATOR_IMG} ${BPFMAN_AGENT_IMG} --name ${KIND_CLUSTER_NAME} +load-images-kind: ## Load bpfman-agent, and bpfman-operator images into the running local kind devel cluster. + kind load docker-image ${BPFMAN_OPERATOR_IMG} ${BPFMAN_AGENT_IMG} --name ${KIND_CLUSTER_NAME} .PHONY: bundle-build bundle-build: ## Build the bundle image. @@ -361,6 +360,10 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified setup-kind: ## Setup Kind cluster kind delete cluster --name ${KIND_CLUSTER_NAME} && kind create cluster --config hack/kind-config.yaml --name ${KIND_CLUSTER_NAME} +.PHONY: destroy-kind +destroy-kind: ## Destroy Kind cluster + kind delete cluster --name ${KIND_CLUSTER_NAME} + ## Default deploy target is KIND based with its CSI driver initialized. .PHONY: deploy deploy: manifests kustomize ## Deploy bpfman-operator to the K8s cluster specified in ~/.kube/config with the csi driver initialized. diff --git a/config/test/patch.yaml b/config/test/patch.yaml index 2d06f90a5..709b3cdfd 100644 --- a/config/test/patch.yaml +++ b/config/test/patch.yaml @@ -5,6 +5,6 @@ metadata: namespace: kube-system data: bpfman.agent.image: quay.io/bpfman/bpfman-agent:int-test - bpfman.image: quay.io/bpfman/bpfman:int-test + bpfman.image: quay.io/bpfman/bpfman:latest bpfman.log.level: bpfman=debug bpfman.agent.log.level: debug diff --git a/controllers/bpfman-agent/common.go b/controllers/bpfman-agent/common.go index a4c7bd03e..119bc6dae 100644 --- a/controllers/bpfman-agent/common.go +++ b/controllers/bpfman-agent/common.go @@ -478,7 +478,7 @@ func (r *ReconcilerCommon) updateStatus(ctx context.Context, bpfProgram *bpfmani meta.SetStatusCondition(&bpfProgram.Status.Conditions, cond.Condition()) r.Logger.V(1).Info("Updating bpfProgram condition", "bpfProgram", bpfProgram.Name, "condition", cond.Condition().Type) - if err := r.Update(ctx, bpfProgram); err != nil { + if err := r.Status().Update(ctx, bpfProgram); err != nil { r.Logger.Error(err, "failed to set bpfProgram object status") } diff --git a/controllers/bpfman-operator/common.go b/controllers/bpfman-operator/common.go index 5a04876ce..fccec2792 100644 --- a/controllers/bpfman-operator/common.go +++ b/controllers/bpfman-operator/common.go @@ -220,8 +220,8 @@ func (r *ReconcilerCommon) updateCondition(ctx context.Context, obj client.Objec meta.SetStatusCondition(conditions, cond.Condition(message)) - if err := r.Update(ctx, obj); err != nil { - r.Logger.V(1).Info("failed to set *Program object status...requeuing") + if err := r.Status().Update(ctx, obj); err != nil { + r.Logger.V(1).Info("failed to set *Program object status...requeuing", "error", err) return ctrl.Result{Requeue: true, RequeueAfter: retryDurationOperator}, nil } diff --git a/test/integration/kprobe_test.go b/test/integration/kprobe_test.go index f80ab2e76..9c9e89709 100644 --- a/test/integration/kprobe_test.go +++ b/test/integration/kprobe_test.go @@ -19,7 +19,7 @@ import ( ) const ( - kprobeGoCounterKustomize = "../../../examples/config/default/go-kprobe-counter" + kprobeGoCounterKustomize = "https://github.com/bpfman/bpfman/examples/config/default/go-kprobe-counter/?timeout=120&ref=main" kprobeGoCounterUserspaceNs = "go-kprobe-counter" kprobeGoCounterUserspaceDsName = "go-kprobe-counter-ds" ) @@ -38,8 +38,8 @@ func TestKprobeGoCounter(t *testing.T) { require.NoError(t, err) return daemon.Status.DesiredNumberScheduled == daemon.Status.NumberAvailable }, - // Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043 - 5*time.Minute, 10*time.Second) + // Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043 + 5*time.Minute, 10*time.Second) pods, err := env.Cluster().Client().CoreV1().Pods(kprobeGoCounterUserspaceNs).List(ctx, metav1.ListOptions{LabelSelector: "name=go-kprobe-counter"}) require.NoError(t, err) diff --git a/test/integration/suite_test.go b/test/integration/suite_test.go index b935ff1e2..d37789754 100644 --- a/test/integration/suite_test.go +++ b/test/integration/suite_test.go @@ -30,12 +30,8 @@ var ( // These images should already be built on the node so they can // be loaded into kind. - bpfmanImage = os.Getenv("BPFMAN_IMG") bpfmanAgentImage = os.Getenv("BPFMAN_AGENT_IMG") bpfmanOperatorImage = os.Getenv("BPFMAN_OPERATOR_IMG") - tcExampleUsImage = "quay.io/bpfman-userspace/go-tc-counter:latest" - xdpExampleUsImage = "quay.io/bpfman-userspace/go-xdp-counter:latest" - tpExampleUsImage = "quay.io/bpfman-userspace/go-tracepoint-counter:latest" existingCluster = os.Getenv("USE_EXISTING_KIND_CLUSTER") keepTestCluster = func() bool { return os.Getenv("TEST_KEEP_CLUSTER") == "true" || existingCluster != "" }() @@ -50,30 +46,22 @@ const ( ) func TestMain(m *testing.M) { - // check that we have the bpfman, bpfman-agent, and bpfman-operator images to use for the tests. + // check that we have the bpfman-agent, and bpfman-operator images to use for the tests. // generally the runner of the tests should have built these from the latest // changes prior to the tests and fed them to the test suite. - if bpfmanImage == "" || bpfmanAgentImage == "" || bpfmanOperatorImage == "" { - exitOnErr(fmt.Errorf("BPFMAN_IMG, BPFMAN_AGENT_IMG, and BPFMAN_OPERATOR_IMG must be provided")) + if bpfmanAgentImage == "" || bpfmanOperatorImage == "" { + exitOnErr(fmt.Errorf("BPFMAN_AGENT_IMG, and BPFMAN_OPERATOR_IMG must be provided")) } ctx, cancel = context.WithCancel(context.Background()) defer cancel() - // to use the provided bpfman, bpfman-agent, and bpfman-operator images we will need to add + // to use the provided bpfman-agent, and bpfman-operator images we will need to add // them as images to load in the test cluster via an addon. - loadImages, err := loadimage.NewBuilder().WithImage(bpfmanImage) - exitOnErr(err) - loadImages, err = loadImages.WithImage(bpfmanAgentImage) + loadImages, err := loadimage.NewBuilder().WithImage(bpfmanAgentImage) exitOnErr(err) loadImages, err = loadImages.WithImage(bpfmanOperatorImage) exitOnErr(err) - loadImages, err = loadImages.WithImage(tcExampleUsImage) - exitOnErr(err) - loadImages, err = loadImages.WithImage(xdpExampleUsImage) - exitOnErr(err) - loadImages, err = loadImages.WithImage(tpExampleUsImage) - exitOnErr(err) if existingCluster != "" { fmt.Printf("INFO: existing kind cluster %s was provided\n", existingCluster) diff --git a/test/integration/tc_test.go b/test/integration/tc_test.go index 386e31d61..ca6469fb4 100644 --- a/test/integration/tc_test.go +++ b/test/integration/tc_test.go @@ -18,7 +18,7 @@ import ( ) const ( - tcGoCounterKustomize = "../../../examples/config/default/go-tc-counter" + tcGoCounterKustomize = "https://github.com/bpfman/bpfman/examples/config/default/go-tc-counter/?timeout=120&ref=main" tcGoCounterUserspaceNs = "go-tc-counter" tcGoCounterUserspaceDsName = "go-tc-counter-ds" ) @@ -36,9 +36,9 @@ func TestTcGoCounter(t *testing.T) { daemon, err := env.Cluster().Client().AppsV1().DaemonSets(tcGoCounterUserspaceNs).Get(ctx, tcGoCounterUserspaceDsName, metav1.GetOptions{}) require.NoError(t, err) return daemon.Status.DesiredNumberScheduled == daemon.Status.NumberAvailable - }, - // Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043 - 5 * time.Minute, 10 * time.Second) + }, + // Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043 + 5*time.Minute, 10*time.Second) pods, err := env.Cluster().Client().CoreV1().Pods(tcGoCounterUserspaceNs).List(ctx, metav1.ListOptions{LabelSelector: "name=go-tc-counter"}) require.NoError(t, err) diff --git a/test/integration/tracepoint_test.go b/test/integration/tracepoint_test.go index 1a4d9207f..15619f38c 100644 --- a/test/integration/tracepoint_test.go +++ b/test/integration/tracepoint_test.go @@ -19,7 +19,7 @@ import ( ) const ( - tracepointGoCounterKustomize = "../../../examples/config/default/go-tracepoint-counter" + tracepointGoCounterKustomize = "https://github.com/bpfman/bpfman/examples/config/default/go-tracepoint-counter/?timeout=120&ref=main" tracepointGoCounterUserspaceNs = "go-tracepoint-counter" tracepointGoCounterUserspaceDsName = "go-tracepoint-counter-ds" ) @@ -38,9 +38,9 @@ func TestTracepointGoCounter(t *testing.T) { require.NoError(t, err) return daemon.Status.DesiredNumberScheduled == daemon.Status.NumberAvailable }, - // Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043 - 5 * time.Minute, 10 * time.Second) - + // Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043 + 5*time.Minute, 10*time.Second) + pods, err := env.Cluster().Client().CoreV1().Pods(tracepointGoCounterUserspaceNs).List(ctx, metav1.ListOptions{LabelSelector: "name=go-tracepoint-counter"}) require.NoError(t, err) goTracepointCounterPod := pods.Items[0] diff --git a/test/integration/uprobe_test.go b/test/integration/uprobe_test.go index 4be4ae443..8b19ab899 100644 --- a/test/integration/uprobe_test.go +++ b/test/integration/uprobe_test.go @@ -19,10 +19,10 @@ import ( ) const ( - uprobeGoCounterKustomize = "../../../examples/config/default/go-uprobe-counter" + uprobeGoCounterKustomize = "https://github.com/bpfman/bpfman/examples/config/default/go-uprobe-counter/?timeout=120&ref=main" uprobeGoCounterUserspaceNs = "go-uprobe-counter" uprobeGoCounterUserspaceDsName = "go-uprobe-counter-ds" - targetKustomize = "../../../examples/config/default/go-target" + targetKustomize = "https://github.com/bpfman/bpfman/examples/config/default/go-target/?timeout=120&ref=main" targetUserspaceNs = "go-target" targetUserspaceDsName = "go-target-ds" ) @@ -41,8 +41,8 @@ func TestUprobeGoCounter(t *testing.T) { require.NoError(t, err) return daemon.Status.DesiredNumberScheduled == daemon.Status.NumberAvailable }, - // Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043 - 5*time.Minute, 10*time.Second) + // Wait 5 minutes since cosign is slow, https://github.com/bpfman/bpfman/issues/1043 + 5*time.Minute, 10*time.Second) t.Log("deploying uprobe counter program") require.NoError(t, clusters.KustomizeDeployForCluster(ctx, env.Cluster(), uprobeGoCounterKustomize)) diff --git a/test/integration/xdp_test.go b/test/integration/xdp_test.go index 502609223..1c5ad0add 100644 --- a/test/integration/xdp_test.go +++ b/test/integration/xdp_test.go @@ -22,7 +22,7 @@ import ( ) const ( - xdpGoCounterKustomize = "../../../examples/config/default/go-xdp-counter" + xdpGoCounterKustomize = "https://github.com/bpfman/bpfman/examples/config/default/go-xdp-counter/?timeout=120&ref=main" xdpGoCounterUserspaceNs = "go-xdp-counter" xdpGoCounterUserspaceDsName = "go-xdp-counter-ds" )