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

cannot find module providing package #1502

Closed
qw1mb0 opened this issue May 30, 2019 · 19 comments · Fixed by #1401
Closed

cannot find module providing package #1502

qw1mb0 opened this issue May 30, 2019 · 19 comments · Fixed by #1401
Assignees

Comments

@qw1mb0
Copy link

qw1mb0 commented May 30, 2019

What did you do?
I following the guide to add example-inc API, but got cannot find module providing package:

$ operator-sdk add api --api-version=app.example.com/v1alpha1 --kind=AppService
INFO[0000] Generating api version app.example.com/v1alpha1 for kind AppService. 
INFO[0000] Created pkg/apis/app/v1alpha1/appservice_types.go 
INFO[0000] Created pkg/apis/addtoscheme_app_v1alpha1.go 
INFO[0000] Created pkg/apis/app/v1alpha1/register.go    
INFO[0000] Created pkg/apis/app/v1alpha1/doc.go         
INFO[0000] Created deploy/crds/app_v1alpha1_appservice_cr.yaml 
W0530 09:51:53.863324   20942 parse.go:239] Ignoring child directory github.com/example-inc/app-operator/pkg/apis/app: unable to import "github.com/example-inc/app-operator/pkg/apis/app": go/build: importGo github.com/example-inc/app-operator/pkg/apis/app: exit status 1
can't load package: package github.com/example-inc/app-operator/pkg/apis/app: unknown import path "github.com/example-inc/app-operator/pkg/apis/app": cannot find module providing package github.com/example-inc/app-operator/pkg/apis/app

INFO[0013] Created deploy/crds/app_v1alpha1_appservice_crd.yaml 
Error: exit status 1
Usage:
  operator-sdk add api [flags]

Flags:
      --api-version string   Kubernetes APIVersion that has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1)
  -h, --help                 help for api
      --kind string          Kubernetes resource Kind name. (e.g AppService)

Global Flags:
      --verbose   Enable verbose loggin

What did you expect to see?
I pass without error

What did you see instead? Under which circumstances?
I use the operator-sdk v0.8.1 release and make install to build and install.

Environment

  • operator-sdk version: operator-sdk version: v0.8.1, commit: 33b3bfe10176f8647f5354516fff29dea42b6342

  • Kubernetes version information: Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.0", GitCommit:"0ed33881dc4355495f623c6f22e7dd0b7632b7c0", GitTreeState:"clean", BuildDate:"2018-09-27T17:05:32Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"}

  • Kubernetes cluster kind: minikube

  • go version: go version go1.12 linux/amd64

  • go variables:

GO111MODULE=on
GOPATH=/home/user/go
GOROOT=/usr/lib/go-1.12/bin/
  • current directory: /home/user/go/src/github.com/example-inc/app-operator
@joelanford
Copy link
Member

@qw1mb0 The error output is not very helpful unfortunately. Looking at the code, my guess would be that there was an error compiling the code generation binaries, which is the next step after creating the CRD.

The code I'm thinking is the culprit is here and here

Do you have any files in /home/user/go/src/github.com/example-inc/app-operator/build/_output/bin?

@mossuchida
Copy link

mossuchida commented May 30, 2019

I also have similar issue. It was working last week, but today, when I tried to create a new operator, I got this following error (My OS is macOS Mojave ):

nauvoo-3:app-operator super$ operator-sdk add api --api-version=app.example.com/v1alpha1 --kind=AppService
INFO[0000] Generating api version app.example.com/v1alpha1 for kind AppService.
INFO[0000] Created pkg/apis/app/v1alpha1/appservice_types.go
INFO[0000] Created pkg/apis/addtoscheme_app_v1alpha1.go
INFO[0000] Created pkg/apis/app/v1alpha1/register.go
INFO[0000] Created pkg/apis/app/v1alpha1/doc.go
INFO[0000] Created deploy/crds/app_v1alpha1_appservice_cr.yaml
W0530 12:18:01.256270 53532 parse.go:239] Ignoring child directory github.com/moss-inc/app-operator/pkg/apis/app: unable to import "github.com/moss-inc/app-operator/pkg/apis/app": go/build: importGo github.com/moss-inc/app-operator/pkg/apis/app: exit status 1
go: github.com/peterbourgon/[email protected]: go.mod has post-v0 module path "github.com/peterbourgon/diskv/v3" at revision 0be1b92a6df0
go: error loading module requirements

W0530 12:18:01.303688 53532 parse.go:239] Ignoring child directory github.com/moss-inc/app-operator/pkg/apis/app/v1alpha1: unable to import "github.com/moss-inc/app-operator/pkg/apis/app/v1alpha1": go/build: importGo github.com/moss-inc/app-operator/pkg/apis/app/v1alpha1: exit status 1
go: github.com/peterbourgon/[email protected]: go.mod has post-v0 module path "github.com/peterbourgon/diskv/v3" at revision 0be1b92a6df0
go: error loading module requirements

INFO[0000] Created deploy/crds/app_v1alpha1_appservice_crd.yaml
INFO[0000] RBAC rules in deploy/role.yaml already up to date for the resource (app.example.com/v1alpha1, AppService)
Error: exit status 1

@mossuchida
Copy link

mossuchida commented May 30, 2019

Well, in my case, my go.mod had the following:
github.com/peterbourgon/diskv v0.0.0-20190425080511-0be1b92a6df0
so, I changed it to
github.com/peterbourgon/diskv/v3 v3.0.0
Then I run
go mod vendor
this made me pass this part, but I have noticed bunch of stuffs are missing in vendor dir now (e.g. Error: chdir path-to/go/src/acmeair-operator/vendor/k8s.io/code-generator: no such file or directory)
I am not sure what is going wrong in my env right now..

@jonathanbeber
Copy link

@qw1mb0 can you run operator-sdk add api --api-version=app.example.com/v1alpha1 --kind=AppService with the --verbose flag:

operator-sdk --verbose add api --api-version=app.example.com/v1alpha1 --kind=AppService

I had problems with that, I resolved it setting the right value for GOROOT, but I'm not sure what's happening in your case. I suspect that you GOROOT should be pointing to /usr/lib/go-1.12/, not /usr/lib/go-1.12/bin, but the detailed output (verbose mode) would help.

@jonathanbeber
Copy link

You can try to update your go version to v1.12.5 as well

@estroz
Copy link
Member

estroz commented Jun 3, 2019

@qw1mb0 @mossuchida are you running operator-sdk add api/is your operator project in $GOPATH/src?

@estroz estroz self-assigned this Jun 3, 2019
@mossuchida
Copy link

mossuchida commented Jun 4, 2019

Yes, I am running the command in $GOPATH/src/app-operator dir. I have upgraded go version to v1.12.5, but still the same issue. Maybe I need to upgrade Operator SDK also? (Are there upgrade documentation?) . Currently, my version is operator-sdk version: v0.7.0

@estroz
Copy link
Member

estroz commented Jun 4, 2019

Try running the following:

$ mkdir -p pkg/apis/app && echo "package app" > pkg/apis/app/stub.go

To see if that gets rid of the first error.

@chinglinwen
Copy link

I got this similar issue

$ operator-sdk new project-operator
INFO[0000] Creating new Go operator 'project-operator'. 
INFO[0000] Created go.mod                               
INFO[0000] Created tools.go                             
INFO[0000] Created cmd/manager/main.go                  
INFO[0000] Created build/Dockerfile                     
INFO[0000] Created build/bin/entrypoint                 
INFO[0000] Created build/bin/user_setup                 
INFO[0000] Created deploy/service_account.yaml          
INFO[0000] Created deploy/role.yaml                     
INFO[0000] Created deploy/role_binding.yaml             
INFO[0000] Created deploy/operator.yaml                 
INFO[0000] Created pkg/apis/apis.go                     
INFO[0000] Created pkg/controller/controller.go         
INFO[0000] Created version/version.go                   
INFO[0000] Created .gitignore                           
INFO[0000] Running go mod ...                           
go: finding github.com/operator-framework/operator-sdk v0.8.x
go: errors parsing go.mod:
/home/wen/gocode/src/wen/project-operator/go.mod:22: invalid module version "v0.8.x": unknown revision v0.8.x
Error: failed to exec []string{"go", "mod", "vendor", "-v"}: exit status 1
Usage:
$ operator-sdk version
operator-sdk version: v0.8.1, commit: 33b3bfe10176f8647f5354516fff29dea42b6342

@estroz
Copy link
Member

estroz commented Jun 12, 2019

@qw1mb0 @mossuchida have you tried the suggested fix?
@chinglinwen is this a persistent error? I was unable to reproduce it. Can you submit a separate issue with all the required information? Thanks!

@chinglinwen
Copy link

I just changed go.mod operator-sdk v0.8.x to operator-sdk v0.8.1 @estroz , it works now

@qw1mb0
Copy link
Author

qw1mb0 commented Jun 13, 2019

Hm.
After add --verbose flag all fine.

@mossuchida
Copy link

After upgrading to v0.8.1, It seems like it is working although I see some errors while creating. Is this expected?
INFO[0002] Created deploy/crds/app_v1alpha1_appservice_cr.yaml
W0613 13:36:27.958214 2867 parse.go:239] Ignoring child directory github.com/example-inc/app-operator/pkg/apis/app: unable to import "github.com/example-inc/app-operator/pkg/apis/app": go/build: importGo github.com/example-inc/app-operator/pkg/apis/app: exit status 1
can't load package: package github.com/example-inc/app-operator/pkg/apis/app: unknown import path "github.com/example-inc/app-operator/pkg/apis/app": cannot find module providing package github.com/example-inc/app-operator/pkg/apis/app

INFO[0011] Created deploy/crds/app_v1alpha1_appservice_crd.yaml

@estroz
Copy link
Member

estroz commented Jun 13, 2019

@mossuchida yes, see #1546

@darmenliu
Copy link

I just changed go.mod operator-sdk v0.8.x to operator-sdk v0.8.1 @estroz , it works now

hi, same issue with you, please help to share your solution detail info.

@chinglinwen
Copy link

@darmenliu

manual edit go.mod file, replace operator-sdk v0.8.x with operator-sdk v0.8.1, then try again with operator-sdk new. ( I don't remember much )

@spanichellazhaw
Copy link

@mossuchida yes, see #1546

After add --verbose flag all fine.

NicolasT added a commit to scality/metalk8s that referenced this issue Jul 8, 2019
Without such file in place, code-generation using `operator-sdk generate
openapi` tends to fail. This is fixed in later versions of
`operator-sdk`, which generate exactly this file when scaffolding a new
API.

See: operator-framework/operator-sdk#1401
See: operator-framework/operator-sdk#1502
See: operator-framework/operator-sdk#1546
NicolasT added a commit to scality/metalk8s that referenced this issue Jul 8, 2019
Without such file in place, code-generation using `operator-sdk generate
openapi` tends to fail. This is fixed in later versions of
`operator-sdk`, which generate exactly this file when scaffolding a new
API.

See: operator-framework/operator-sdk#1401
See: operator-framework/operator-sdk#1502
See: operator-framework/operator-sdk#1546
NicolasT added a commit to scality/metalk8s that referenced this issue Jul 9, 2019
Without such file in place, code-generation using `operator-sdk generate
openapi` tends to fail. This is fixed in later versions of
`operator-sdk`, which generate exactly this file when scaffolding a new
API.

See: operator-framework/operator-sdk#1401
See: operator-framework/operator-sdk#1502
See: operator-framework/operator-sdk#1546
slaperche-scality pushed a commit to scality/metalk8s that referenced this issue Jul 12, 2019
Without such file in place, code-generation using `operator-sdk generate
openapi` tends to fail. This is fixed in later versions of
`operator-sdk`, which generate exactly this file when scaffolding a new
API.

See: operator-framework/operator-sdk#1401
See: operator-framework/operator-sdk#1502
See: operator-framework/operator-sdk#1546
slaperche-scality pushed a commit to scality/metalk8s that referenced this issue Jul 12, 2019
Without such file in place, code-generation using `operator-sdk generate
openapi` tends to fail. This is fixed in later versions of
`operator-sdk`, which generate exactly this file when scaffolding a new
API.

See: operator-framework/operator-sdk#1401
See: operator-framework/operator-sdk#1502
See: operator-framework/operator-sdk#1546
slaperche-scality pushed a commit to scality/metalk8s that referenced this issue Jul 12, 2019
Without such file in place, code-generation using `operator-sdk generate
openapi` tends to fail. This is fixed in later versions of
`operator-sdk`, which generate exactly this file when scaffolding a new
API.

See: operator-framework/operator-sdk#1401
See: operator-framework/operator-sdk#1502
See: operator-framework/operator-sdk#1546
slaperche-scality pushed a commit to scality/metalk8s that referenced this issue Jul 15, 2019
Without such file in place, code-generation using `operator-sdk generate
openapi` tends to fail. This is fixed in later versions of
`operator-sdk`, which generate exactly this file when scaffolding a new
API.

See: operator-framework/operator-sdk#1401
See: operator-framework/operator-sdk#1502
See: operator-framework/operator-sdk#1546
@sfxworks
Copy link

Is anyone running into this issue with 0.13?

quantomworks@DESKTOP-6VDCHBC:~/work/src/github.com/mhausenblas$ operator-sdk new nodefpol-operator
INFO[0000] Creating new Go operator 'nodefpol-operator'.
INFO[0000] Created go.mod
INFO[0000] Created tools.go
INFO[0000] Created cmd/manager/main.go
INFO[0000] Created build/Dockerfile
INFO[0000] Created build/bin/entrypoint
INFO[0000] Created build/bin/user_setup
INFO[0000] Created deploy/service_account.yaml
INFO[0000] Created deploy/role.yaml
INFO[0000] Created deploy/role_binding.yaml
INFO[0000] Created deploy/operator.yaml
INFO[0000] Created pkg/apis/apis.go
INFO[0000] Created pkg/controller/controller.go
INFO[0000] Created version/version.go
INFO[0000] Created .gitignore
INFO[0000] Validating project
cmd/manager/main.go:18:2: cannot find package "github.com/operator-framework/operator-sdk/pkg/k8sutil" in any of:
        /usr/lib/go-1.10/src/github.com/operator-framework/operator-sdk/pkg/k8sutil (from $GOROOT)
        /home/quantomworks/work/src/github.com/operator-framework/operator-sdk/pkg/k8sutil (from $GOPATH)
cmd/manager/main.go:19:2: cannot find package "github.com/operator-framework/operator-sdk/pkg/kube-metrics" in any of:
        /usr/lib/go-1.10/src/github.com/operator-framework/operator-sdk/pkg/kube-metrics (from $GOROOT)
        /home/quantomworks/work/src/github.com/operator-framework/operator-sdk/pkg/kube-metrics (from $GOPATH)
cmd/manager/main.go:20:2: cannot find package "github.com/operator-framework/operator-sdk/pkg/leader" in any of:
        /usr/lib/go-1.10/src/github.com/operator-framework/operator-sdk/pkg/leader (from $GOROOT)
        /home/quantomworks/work/src/github.com/operator-framework/operator-sdk/pkg/leader (from $GOPATH)
cmd/manager/main.go:21:2: cannot find package "github.com/operator-framework/operator-sdk/pkg/log/zap" in any of:
        /usr/lib/go-1.10/src/github.com/operator-framework/operator-sdk/pkg/log/zap (from $GOROOT)
        /home/quantomworks/work/src/github.com/operator-framework/operator-sdk/pkg/log/zap (from $GOPATH)
cmd/manager/main.go:22:2: cannot find package "github.com/operator-framework/operator-sdk/pkg/metrics" in any of:
        /usr/lib/go-1.10/src/github.com/operator-framework/operator-sdk/pkg/metrics (from $GOROOT)
        /home/quantomworks/work/src/github.com/operator-framework/operator-sdk/pkg/metrics (from $GOPATH)
cmd/manager/main.go:23:2: cannot find package "github.com/operator-framework/operator-sdk/pkg/restmapper" in any of:
        /usr/lib/go-1.10/src/github.com/operator-framework/operator-sdk/pkg/restmapper (from $GOROOT)
        /home/quantomworks/work/src/github.com/operator-framework/operator-sdk/pkg/restmapper (from $GOPATH)
cmd/manager/main.go:24:2: cannot find package "github.com/operator-framework/operator-sdk/version" in any of:
        /usr/lib/go-1.10/src/github.com/operator-framework/operator-sdk/version (from $GOROOT)
        /home/quantomworks/work/src/github.com/operator-framework/operator-sdk/version (from $GOPATH)
cmd/manager/main.go:25:2: cannot find package "github.com/spf13/pflag" in any of:
        /usr/lib/go-1.10/src/github.com/spf13/pflag (from $GOROOT)
        /home/quantomworks/work/src/github.com/spf13/pflag (from $GOPATH)
cmd/manager/main.go:26:2: cannot find package "k8s.io/api/core/v1" in any of:
        /usr/lib/go-1.10/src/k8s.io/api/core/v1 (from $GOROOT)
        /home/quantomworks/work/src/k8s.io/api/core/v1 (from $GOPATH)
pkg/apis/apis.go:4:2: cannot find package "k8s.io/apimachinery/pkg/runtime" in any of:
        /usr/lib/go-1.10/src/k8s.io/apimachinery/pkg/runtime (from $GOROOT)
        /home/quantomworks/work/src/k8s.io/apimachinery/pkg/runtime (from $GOPATH)
cmd/manager/main.go:27:2: cannot find package "k8s.io/apimachinery/pkg/util/intstr" in any of:
        /usr/lib/go-1.10/src/k8s.io/apimachinery/pkg/util/intstr (from $GOROOT)
        /home/quantomworks/work/src/k8s.io/apimachinery/pkg/util/intstr (from $GOPATH)
cmd/manager/main.go:11:2: cannot find package "k8s.io/client-go/plugin/pkg/client/auth" in any of:
        /usr/lib/go-1.10/src/k8s.io/client-go/plugin/pkg/client/auth (from $GOROOT)
        /home/quantomworks/work/src/k8s.io/client-go/plugin/pkg/client/auth (from $GOPATH)
cmd/manager/main.go:12:2: cannot find package "k8s.io/client-go/rest" in any of:
        /usr/lib/go-1.10/src/k8s.io/client-go/rest (from $GOROOT)
        /home/quantomworks/work/src/k8s.io/client-go/rest (from $GOPATH)
cmd/manager/main.go:28:2: cannot find package "sigs.k8s.io/controller-runtime/pkg/client/config" in any of:
        /usr/lib/go-1.10/src/sigs.k8s.io/controller-runtime/pkg/client/config (from $GOROOT)
        /home/quantomworks/work/src/sigs.k8s.io/controller-runtime/pkg/client/config (from $GOPATH)
cmd/manager/main.go:29:2: cannot find package "sigs.k8s.io/controller-runtime/pkg/log" in any of:
        /usr/lib/go-1.10/src/sigs.k8s.io/controller-runtime/pkg/log (from $GOROOT)
        /home/quantomworks/work/src/sigs.k8s.io/controller-runtime/pkg/log (from $GOPATH)
pkg/controller/controller.go:4:2: cannot find package "sigs.k8s.io/controller-runtime/pkg/manager" in any of:
        /usr/lib/go-1.10/src/sigs.k8s.io/controller-runtime/pkg/manager (from $GOROOT)
        /home/quantomworks/work/src/sigs.k8s.io/controller-runtime/pkg/manager (from $GOPATH)
cmd/manager/main.go:31:2: cannot find package "sigs.k8s.io/controller-runtime/pkg/manager/signals" in any of:
        /usr/lib/go-1.10/src/sigs.k8s.io/controller-runtime/pkg/manager/signals (from $GOROOT)
        /home/quantomworks/work/src/sigs.k8s.io/controller-runtime/pkg/manager/signals (from $GOPATH)
Error: failed to exec []string{"go", "build", "./..."}: exit status 1
Usage:
  operator-sdk new <project-name> [flags]

Flags:
      --api-version string          Kubernetes apiVersion and has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1) - used with "ansible" or "helm" types
      --generate-playbook           Generate a playbook skeleton. (Only used for --type ansible)
      --git-init                    Initialize the project directory as a git repository (default false)
      --header-file string          Path to file containing headers for generated Go files. Copied to hack/boilerplate.go.txt
      --helm-chart string           Initialize helm operator with existing helm chart (<URL>, <repo>/<name>, or local path)
      --helm-chart-repo string      Chart repository URL for the requested helm chart
      --helm-chart-version string   Specific version of the helm chart (default is latest version)
  -h, --help                        help for new
      --kind string                 Kubernetes CustomResourceDefintion kind. (e.g AppService) - used with "ansible" or "helm" types
      --repo string                 Project repository path for Go operators. Used as the project's Go import path. This must be set if outside of $GOPATH/src (e.g. github.com/example-inc/my-operator)
      --skip-validation             Do not validate the resulting project's structure and dependencies. (Only used for --type go)
      --type string                 Type of operator to initialize (choices: "go", "ansible" or "helm") (default "go")
      --vendor                      Use a vendor directory for dependencies

Global Flags:
      --verbose   Enable verbose logging

@estroz
Copy link
Member

estroz commented Dec 30, 2019

@sfxworks can you open a new issue detailing your environment info? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants