Skip to content

E2E workflow fails building manager image due to incomplete Dockerfile source copy #145

Description

@kaovilai

Summary

The E2E workflow fails during the Ginkgo BeforeSuite before any specs run because the suite cannot build the manager image.

Failing job: https://github.com/migtools/kubevirt-datamover-controller/actions/runs/30126138631/job/89589981078?pr=139
Related PR: #139
Commit: 50a76b5b76d810ee2103c7dc96350e20ccee6095

Failure details

The failure occurs in test/e2e/e2e_suite_test.go while running:

cmd := exec.Command("make", "docker-build", fmt.Sprintf("IMG=%s", managerImage))
_, err := utils.Run(cmd)
ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to build the manager image")

The command ultimately invokes the Makefile target:

docker-build: ## Build docker image with the manager.
	$(CONTAINER_TOOL) build -t ${IMG} .

The job log shows:

[BeforeSuite] building the manager image
running: "make docker-build IMG=example.com/kubevirt-datamover-controller:v0.0.1"
[FAILED] Failed to build the manager image
make: *** [Makefile:98: test-e2e] Error 1
Process completed with exit code 2.

Likely root cause

The Docker build only copies a subset of local Go source directories into the builder stage:

COPY cmd/main.go cmd/main.go
COPY internal/ internal/
COPY pkg/ pkg/

If cmd/main.go or packages under internal/ import local packages outside those directories, such as the Kubebuilder-style api/ package, the image build will fail because those files are missing inside the build context in the container.

Suggested fix

Update the Dockerfile to copy all local source directories required by the manager build before running go build.

At minimum, add api/:

 # Copy the go source
 COPY cmd/main.go cmd/main.go
+COPY api/ api/
 COPY internal/ internal/
 COPY pkg/ pkg/

If other local packages are imported by the manager, copy those as well.

Recommended section:

# Copy the go source
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY internal/ internal/
COPY pkg/ pkg/

# Build
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

Acceptance criteria

  • make docker-build IMG=example.com/kubevirt-datamover-controller:v0.0.1 succeeds locally or in CI.
  • make test-e2e proceeds past the Ginkgo BeforeSuite manager image build step.
  • The E2E workflow for PR [oadp-1.6] Issue #95: Add GCP Cloud Storage support #139 no longer fails at the image build step.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions