go-build-test fails for operator written in go
Description
When using this ci template, the go_test function is failing when testing a Kubernetes operator written in Go following the Kubebuilder framework. Error messages are like the following one (XXX is the operator name):
[FAILED] in [BeforeSuite] - /builds/XXX/internal/controller/suite_test.go:72 @ 11/25/24 17:23:10.42
<< Timeline
[FAILED] Unexpected error:
<*fmt.wrapError | 0xc0000ecc00>:
unable to start control plane itself: failed to start the controlplane. retried 5 times: fork/exec ../../bin/k8s/1.28.3-linux-amd64/etcd: no such file or directory
{
msg: "unable to start control plane itself: failed to start the controlplane. retried 5 times: fork/exec ../../bin/k8s/1.28.3-linux-amd64/etcd: no such file or directory",
err: <*fmt.wrapError | 0xc0000ecbe0>{
msg: "failed to start the controlplane. retried 5 times: fork/exec ../../bin/k8s/1.28.3-linux-amd64/etcd: no such file or directory",
err: <*fs.PathError | 0xc0000f12c0>{
Op: "fork/exec",
Path: "../../bin/k8s/1.28.3-linux-amd64/etcd",
Err: <syscall.Errno>0x2,
},
},
}
occurred
In [BeforeSuite] at: /builds/XXX/internal/controller/suite_test.go:72
In K8s operators written in go, test can be run on an environment without Kubernetes. Required libs are downloaded and installed before the tests, see the Kubebuilder reference. The make test command is setting the environment before running tests. Without this setting, etcd and other K8s related binaries are not available and the operator testing fails.
Implementation ideas
- Overriding
go testbymake testin the go_test function if necessary - Or adding a go_test_operator function