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

operator-sdk create api fails because of missing go packages: logr@v0.3.0, ginkgo@v1.14.1, gomega@v1.10.2 #4610

Closed
bwoolf1 opened this issue Mar 5, 2021 · 1 comment
Labels
language/go Issue is related to a Go operator project

Comments

@bwoolf1
Copy link

bwoolf1 commented Mar 5, 2021

Bug Report

What did you do?

I ran operator-sdk create api --group=cache --version=v1alpha1 --kind=Memcached --controller --resource. (This is after running operator-sdk init --domain=example.com --repo=github.com/example/memcached-operator and setting GO111MODULE=on.)

What did you expect to see?

When I got it working, I saw this:

~ operator-sdk create api --group=cache --version=v1alpha1 --kind=Memcached --controller --resource
Writing scaffold for you to edit...
api/v1alpha1/memcached_types.go
controllers/memcached_controller.go
Running make:
$ make
/Users/bwoolf/dev/memcached-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
go build -o bin/manager main.go

To get this to work, I had to import these packages after I initialized my environment but before I created the API:

~ go get github.com/go-logr/logr@v0.3.0
~ go get github.com/onsi/ginkgo@v1.14.1
~ go get github.com/onsi/gomega@v1.10.2

It looks like the operator-sdk requires these packages and should include them as part of its install.

What did you see instead? Under which circumstances?

When I first ran it, I saw this:

~ operator-sdk create api --group=cache --version=v1alpha1 --kind=Memcached --controller --resource
Writing scaffold for you to edit...
api/v1alpha1/memcached_types.go
controllers/memcached_controller.go
Running make:
$ make
/Users/bwoolf/dev/memcached-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
Error: go [-e -json -compiled=true -test=false -export=false -deps=true -find=false -tags ignore_autogenerated -- ./...]: exit status 1: go: github.com/example/memcached-operator/controllers: package github.com/go-logr/logr imported from implicitly required module; to add missing requirements, run:
	go get github.com/go-logr/logr@v0.3.0

Usage:
  controller-gen [flags]
. . .

I recreated my environment, ran go get github.com/go-logr/logr@v0.3.0, then ran operator-sdk create api again and got this:

~ operator-sdk create api --group=cache --version=v1alpha1 --kind=Memcached --controller --resource
Writing scaffold for you to edit...
api/v1alpha1/memcached_types.go
controllers/memcached_controller.go
Running make:
$ make
/Users/bwoolf/dev/memcached-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
go fmt ./...
go vet ./...
go: github.com/example/memcached-operator/controllers: package github.com/onsi/ginkgo imported from implicitly required module; to add missing requirements, run:
	go get github.com/onsi/ginkgo@v1.14.1
go: github.com/example/memcached-operator/controllers: package github.com/onsi/gomega imported from implicitly required module; to add missing requirements, run:
	go get github.com/onsi/gomega@v1.10.2
make: *** [vet] Error 1
Error: failed to create API with "go.kubebuilder.io/v3": exit status 2
Usage:
  operator-sdk create api [flags]
. . .

It looks like operator-sdk create api fails because it's missing three packages:

  • github.com/go-logr/logr@v0.3.0
  • github.com/onsi/ginkgo@v1.14.1
  • github.com/onsi/gomega@v1.10.2

Environment

Operator type:

/language go

Kubernetes cluster type:

~ oc version
Client Version: 4.6.16
Server Version: 4.5.31
Kubernetes Version: v1.18.3+e574db2

$ operator-sdk version

~ operator-sdk version
operator-sdk version: "v1.4.2", commit: "4b083393be65589358b3e0416573df04f4ae8d9b", kubernetes version: "v1.19.4", go version: "go1.15.8", GOOS: "darwin", GOARCH: "amd64"

$ go version (if language is Go)

~ go version
go version go1.16 darwin/amd64

$ kubectl version

~ kubectl version
Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", GitCommit:"18d7461aca47e77cefb355339252a8d4c149188f", GitTreeState:"clean", BuildDate:"2021-01-30T16:44:37Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"18+", GitVersion:"v1.18.3+e574db2", GitCommit:"e574db2", GitTreeState:"clean", BuildDate:"2021-01-30T06:33:00Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}

Possible Solution

The operator-sdk needs to import these three packages when it's installed:

  • github.com/go-logr/logr@v0.3.0
  • github.com/onsi/ginkgo@v1.14.1
  • github.com/onsi/gomega@v1.10.2

Additional context

None.

@openshift-ci-robot openshift-ci-robot added the language/go Issue is related to a Go operator project label Mar 5, 2021
@joelanford
Copy link
Member

This is an issue because you're using Go 1.16, which no longer automatically updates go.mod and go.sum as side effects of go build, go install, go test, etc.

Once this upstream fix makes it into operator-sdk, this issue should be resolved.
kubernetes-sigs/kubebuilder#2037

For now, downgrade to Go 1.15 to avoid this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language/go Issue is related to a Go operator project
Projects
None yet
Development

No branches or pull requests

3 participants