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

Use bash to run 'test' Makefile target #2121

Closed
Wastack opened this issue Apr 1, 2021 · 1 comment · Fixed by #2149
Closed

Use bash to run 'test' Makefile target #2121

Wastack opened this issue Apr 1, 2021 · 1 comment · Fixed by #2149
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/duplicate Indicates an issue is a duplicate of other open issue.

Comments

@Wastack
Copy link

Wastack commented Apr 1, 2021

Let's assume I have /bin/sh as default shell. But error occurs also if I don't have $SHELL explicitly set (because GNU Make defaults to sh).

When running make test I have the following error messages:

/my/path/to/project/bin/controller-gen "crd:trivialVersions=true,preserveUnknownFields=false" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
/my/path/to/project/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
mkdir -p /my/path/to/project/bin
test -f /my/path/to/project/bin/setup-envtest.sh || curl -sSLo /my/path/to/project/bin/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.2/hack/setup-envtest.sh
source /my/path/to/project/bin/setup-envtest.sh; fetch_envtest_tools /my/path/to/project/bin; setup_envtest_env /my/path/to/project/bin; go test ./... -coverprofile cover.out
/bin/sh: 1: source: not found
/bin/sh: 1: fetch_envtest_tools: not found
/bin/sh: 1: setup_envtest_env: not found

And since sourcing script which would have set KUBEBUILDER_ASSETS failed, I have the following error as test result:

<*fmt.wrapError | 0xc000223120>: {
           msg: "failed to start the controlplane. retried 5 times: fork/exec /usr/local/kubebuilder/bin/etcd: no such file or directory",
          err: {
            Op: "fork/exec",
            Path: "/usr/local/kubebuilder/bin/etcd",
            Err: 0x2,
           },
}

What versions of software are you using? Specifically, the following are often useful:

  • go version: go1.15.10 darwin/amd64
  • kubebuilder version: 3.0.0-beta.1
  • controller-runtime version: v0.7.2

I've solved my issue with setting the SHELL environment variable to /bin/bash/ for the test target with the following code:

ENVTEST_ASSETS_DIR=$(shell pwd)/bin
+test: SHELL := /bin/bash
test: manifests generate fmt vet
       mkdir -p ${ENVTEST_ASSETS_DIR}
       test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.2/hack/setup-envtest.sh
       source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Apr 1, 2021
@estroz
Copy link
Contributor

estroz commented Apr 1, 2021

See #1892. I'm going to leave this open so others who encounter this issue see it.

/triage duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/duplicate Indicates an issue is a duplicate of other open issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants