operator-framework / operator-sdk

SDK for building Kubernetes applications. Provides high level APIs, useful abstractions, and project scaffolding.
https://sdk.operatorframework.io
Apache License 2.0
7.26k stars 1.75k forks source link

cannot find module providing package k8s.io/api/admissionregistration/v1alpha1 when compiling operator-sdk #1637

Closed BIAOXYZ closed 5 years ago

BIAOXYZ commented 5 years ago

Bug Report

What did you do? Try to compile the latest version of operator-sdk.

What did you expect to see? After successfully executing make dep, I expect that make install step will also succeed.

What did you see instead? Under which circumstances?

root@cloudsec1 operator-sdk [dev] $ make install
go: finding k8s.io/api/admissionregistration/v1alpha1 latest
go: finding k8s.io/client-go/util/integer latest
go: finding k8s.io/api/admissionregistration latest
go: finding k8s.io/client-go/util latest
go: finding k8s.io/api latest
build github.com/operator-framework/operator-sdk/cmd/operator-sdk: cannot load k8s.io/api/admissionregistration/v1alpha1: cannot find module providing package k8s.io/api/admissionregistration/v1alpha1
make: *** [install] Error 1

Environment

root@cloudsec1 operator-sdk [dev] $ kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.0", GitCommit:"e8462b5b5dc2584fdcd18e6bcfe9f1e4d970a529", GitTreeState:"clean", BuildDate:"2019-06-19T16:40:16Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.0", GitCommit:"e8462b5b5dc2584fdcd18e6bcfe9f1e4d970a529", GitTreeState:"clean", BuildDate:"2019-06-19T16:32:14Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}

root@cloudsec1 operator-sdk [dev] $ go version
go version go1.12.5 linux/amd64

// "dev" is the same of "master" in the current trunk
root@cloudsec1 operator-sdk [dev] $ git log --oneline
d6903be Makefile: remove test/ansible from ci-ansible (#1623)
5507e00 pkg/metrics: pass rest.Config to avoid flag issue in library (#1626)
907c4a7 cmd/operator-sdk/alpha/*,internal/olm: added alpha subcommands to manage OLM installation (#1577)
af139c3 CHANGELOG.md,doc/dev/release.md: get patch versions into main CHANGELOG, clarify release doc (#1621)

Additional context

This is the content of the go.mod file in the root path of the repo. I have try to mannually change the k8s.io/api part of it following the way of https://github.com/kubernetes/client-go/issues/551. But it still does not work.

root@cloudsec1 operator-sdk [dev] $ cat go.mod
module github.com/operator-framework/operator-sdk

go 1.12

require (
        cloud.google.com/go v0.34.0
        contrib.go.opencensus.io/exporter/ocagent v0.0.0-20190402164949-bc69a6023000
        github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78
        github.com/Azure/go-autorest v11.1.0+incompatible
        github.com/BurntSushi/toml v0.3.1
        github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e
        github.com/Masterminds/goutils v0.0.0-20181203091226-41ac8693c5c1
        github.com/Masterminds/semver v0.0.0-20180410204347-c7af12943936
        github.com/Masterminds/sprig v0.0.0-20190301161902-9f8fceff796f
        github.com/PuerkitoBio/purell v1.1.0
        github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578
        github.com/appscode/jsonpatch v0.0.0-20190108182946-7c0e3b262f30
        github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973
        github.com/census-instrumentation/opencensus-proto v0.2.0
        github.com/chai2010/gettext-go v0.0.0-20170215093142-bf70f2a70fb1
        github.com/coreos/go-semver v0.2.0
        github.com/coreos/prometheus-operator v0.0.0-20190220095547-7a25bf6b6bb2
        github.com/cyphar/filepath-securejoin v0.0.0-20180905110808-a261ee33d7a5
        github.com/davecgh/go-spew v1.1.1
        github.com/dgrijalva/jwt-go v3.2.0+incompatible
        github.com/docker/distribution v2.7.0+incompatible
        github.com/docker/docker v0.0.0-20180612054059-a9fbbdc8dd87
        github.com/docker/go-connections v0.4.0 // indirect
        github.com/docker/go-units v0.4.0 // indirect
        github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c
        github.com/emicklei/go-restful v2.8.1+incompatible
        github.com/evanphx/json-patch v4.1.0+incompatible
        github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d
        github.com/fatih/camelcase v1.0.0 // indirect
        github.com/fsnotify/fsnotify v1.4.7
        github.com/ghodss/yaml v1.0.0
        github.com/go-logr/logr v0.0.0-20180629235805-9fb12b3b21c5
        github.com/go-logr/zapr v0.0.0-20190306234327-03f06a783fbb
        github.com/go-openapi/jsonpointer v0.17.0
        github.com/go-openapi/jsonreference v0.17.0
        github.com/go-openapi/spec v0.17.2
        github.com/go-openapi/swag v0.17.0
        github.com/gobuffalo/envy v1.6.15
        github.com/gobwas/glob v0.0.0-20180208210656-5ccd90ef52e1
        github.com/gogo/protobuf v1.2.1
        github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
        github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef
        github.com/golang/mock v1.2.0
        github.com/golang/protobuf v1.3.1
        github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c
        github.com/google/gofuzz v0.0.0-20190408174445-f140a6486e52
        github.com/google/uuid v1.0.0
        github.com/googleapis/gnostic v0.2.0
        github.com/gophercloud/gophercloud v0.0.0-20190408160324-6c7ac67f8855
        github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc
        github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
        github.com/grpc-ecosystem/grpc-gateway v1.8.5
        github.com/hashicorp/golang-lru v0.5.0
        github.com/hashicorp/hcl v1.0.0
        github.com/huandu/xstrings v0.0.0-20180906145035-f02667b379e2
        github.com/iancoleman/strcase v0.0.0-20180726023541-3605ed457bf7
        github.com/imdario/mergo v0.3.6
        github.com/inconshreveable/mousetrap v1.0.0
        github.com/joho/godotenv v1.3.0
        github.com/json-iterator/go v1.1.6
        github.com/konsorten/go-windows-terminal-sequences v1.0.1
        github.com/magiconair/properties v1.8.0
        github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983
        github.com/markbates/inflect v1.0.4
        github.com/martinlindhe/base36 v0.0.0-20180729042928-5cda0030da17
        github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a
        github.com/matttproud/golang_protobuf_extensions v1.0.1
        github.com/mitchellh/go-homedir v0.0.0-20190127042135-af06845cf300
        github.com/mitchellh/go-wordwrap v0.0.0-20180828145344-9e67c67572bc
        github.com/mitchellh/mapstructure v1.1.2
        github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
        github.com/modern-go/reflect2 v1.0.1
        github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f
        github.com/opencontainers/go-digest v1.0.0-rc1
        github.com/opencontainers/image-spec v1.0.1 // indirect
        github.com/operator-framework/operator-lifecycle-manager v0.0.0-20190128024246-5eb7ae5bdb7a
        github.com/pborman/uuid v1.2.0
        github.com/pelletier/go-toml v1.2.0
        github.com/petar/GoLLRB v0.0.0-20130427215148-53be0d36a84c
        github.com/peterbourgon/diskv v2.0.1+incompatible
        github.com/pkg/errors v0.8.1
        github.com/pmezard/go-difflib v1.0.0
        github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829
        github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90
        github.com/prometheus/common v0.2.0
        github.com/prometheus/procfs v0.0.0-20190403104016-ea9eea638872
        github.com/rogpeppe/go-internal v1.2.2
        github.com/russross/blackfriday v0.0.0-20151117072312-300106c228d5
        github.com/sergi/go-diff v0.0.0-20171110110146-1744e2970ca5
        github.com/shurcooL/sanitized_anchor_name v0.0.0-20181226214907-7bfe4c7ecddb
        github.com/sirupsen/logrus v1.2.0
        github.com/spf13/afero v1.2.2
        github.com/spf13/cast v1.3.0
        github.com/spf13/cobra v0.0.3
        github.com/spf13/jwalterweatherman v1.0.0
        github.com/spf13/pflag v1.0.3
        github.com/spf13/viper v0.0.0-20190313092951-9e56dacc08fb
        github.com/stretchr/testify v1.3.0
        github.com/technosophos/moniker v0.0.0-20180509230615-a5dbd03a2245
        go.opencensus.io v0.20.0
        go.uber.org/atomic v1.3.2
        go.uber.org/multierr v1.1.0
        go.uber.org/zap v1.9.1
        golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5
        golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
        golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a
        golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6
        golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67
        golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2
        golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
        golang.org/x/tools v0.0.0-20190408170212-12dd9f86f350
        google.golang.org/api v0.3.0
        google.golang.org/appengine v1.4.0
        google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107
        google.golang.org/grpc v1.19.1
        gopkg.in/inf.v0 v0.9.1
        gopkg.in/square/go-jose.v2 v2.0.0-20190226005203-628223f44a71
        gopkg.in/yaml.v2 v2.2.2
        honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a // indirect
        k8s.io/api v0.0.0-20190313235455-40a48860b5ab
        k8s.io/apiextensions-apiserver v0.0.0-20190228180357-d002e88f6236
        k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1
        k8s.io/apiserver v0.0.0-20190228174905-79427f02047f
        k8s.io/cli-runtime v0.0.0-20190228180923-a9e421a79326
        k8s.io/client-go v11.0.0+incompatible
        k8s.io/code-generator v0.0.0-20181203235156-f8cba74510f3
        k8s.io/gengo v0.0.0-20190327210449-e17681d19d3a
        k8s.io/helm v0.0.0-20190321182622-618447cbf203
        k8s.io/klog v0.2.0
        k8s.io/kube-aggregator v0.0.0-20190228175259-3e0149950b0e
        k8s.io/kube-openapi v0.0.0-20190320154901-5e45bb682580
        k8s.io/kube-state-metrics v0.0.0-20190506093139-de19ed4f12d4
        k8s.io/kubernetes v1.11.8-beta.0.0.20190124204751-3a10094374f2
        k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7
        sigs.k8s.io/controller-runtime v0.0.0-20190606001414-f1eaba5087d6
        sigs.k8s.io/controller-tools v0.0.0-20190411181648-9d55346c2bde
        sigs.k8s.io/yaml v1.1.0
        vbom.ml/util v0.0.0-20180919145318-efcd4e0f9787
)
joelanford commented 5 years ago

@BIAOXYZ The SDK is still using dep with Gopkg.toml and Gopkg.lock, so you won't be able to build operator-sdk with go modules enabled.

Can you try setting export GO111MODULE=off and running make install again.

BIAOXYZ commented 5 years ago

@joelanford Thanks. I personally thought it had already been changed to be based on Go module. And after I turn off GO111MODULE, the compiling succeeds just as before (I have successfully compiled a former operator-sdk version several months ago, maybe before Golang 1.2.x?). This issue can be closed.

PS: Could we need some small changes in this page (developer_guide.md)? I mean, maybe explicitly indicate that it would be better to turn off GO111MODULE flag?

BIAOXYZ commented 5 years ago

Hi @joelanford, there is something new appears. In the same environment (two CentOS virtual machines with the same configuration), compiling operator-sdk succeeds in one machine (see my last post above) but fails in another. They are both in the same commit: d6903be02d4e8541e777b25af0498fe31e2e41e8.

To reproduce:

root@myopenshift:operator-sdk$ git reset --hard
HEAD is now at d6903be Makefile: remove test/ansible from ci-ansible (#1623)

root@myopenshift:operator-sdk$ git clean -df
Removing vendor/github.com/operator-framework/operator-sdk/

root@myopenshift:operator-sdk$ git status
# On branch dev-subtract-1
nothing to commit, working directory clean

root@myopenshift:operator-sdk$ git log --oneline | head
d6903be Makefile: remove test/ansible from ci-ansible (#1623)
5507e00 pkg/metrics: pass rest.Config to avoid flag issue in library (#1626)
907c4a7 cmd/operator-sdk/alpha/*,internal/olm: added alpha subcommands to manage OLM installation (#1577)
af139c3 CHANGELOG.md,doc/dev/release.md: get patch versions into main CHANGELOG, clarify release doc (#1621)
e0342c4 Upgrade the version of the dependency controller-runtime from `v0.1.10` to `v0.1.12` (#1612)
261d8d5 fix: Fix a link in README (#1617)
4d7b853 hack/tests,test/e2e: separate testing and scaffolding of E2E te… (#1586)
998ffb1 .travis.yml: don't run travis on release branches (#1616)
0fc5746 cmd/operator-sdk/olmcatalog: scaffold package.yaml for a set of… (#1364)
eedbe31 cmd/operator-sdk/new: make git init opt-in with --git-init flag (#1588)

root@myopenshift:operator-sdk$ make dep
# Gopkg.lock is out of sync with Gopkg.toml and project imports:
github.com/operator-framework/operator-sdk/cmd/operator-sdk/add: imported or required, but missing from Gopkg.lock's input-impo                           rts
github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha: imported or required, but missing from Gopkg.lock's input-im                           ports
github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/olm: imported or required, but missing from Gopkg.lock's inpu                           t-imports
github.com/operator-framework/operator-sdk/cmd/operator-sdk/build: imported or required, but missing from Gopkg.lock's input-im                           ports
github.com/operator-framework/operator-sdk/cmd/operator-sdk/completion: imported or required, but missing from Gopkg.lock's inp                           ut-imports
github.com/operator-framework/operator-sdk/cmd/operator-sdk/generate: imported or required, but missing from Gopkg.lock's input                           -imports
...
...
...
(22)      try github.com/operator-framework/operator-sdk@v0.8.1
(23)  ✗   github.com/operator-framework/operator-sdk at v0.8.1 has problem subpkg(s):
(23)            github.com/operator-framework/operator-sdk/internal/pkg/scorecard/plugins is missing; required by (root).       github.com/operator-framework/operator-sdk/pkg/kube-metrics is missing; required by (root).       github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha is missing; required by (root). github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/olm is missing; required by (root).   github.com/operator-framework/operator-sdk/internal/flags is missing; required by (root). github.com/operator-framework/operator-sdk/internal/flags/watch is missing; required by (root). github.com/operator-framework/operator-sdk/internal/olm is missing; required by (root).   github.com/operator-framework/operator-sdk/internal/pkg/scorecard/helpers is missing; required by (root).
(22)      try github.com/operator-framework/operator-sdk@v0.8.0
(23)  ✗   github.com/operator-framework/operator-sdk at v0.8.0 has problem subpkg(s):
(23)            github.com/operator-framework/operator-sdk/internal/flags/watch is missing; required by (root). github.com/operator-framework/operator-sdk/internal/olm is missing; required by (root).   github.com/operator-framework/operator-sdk/internal/pkg/scorecard/helpers is missing; required by (root).github.com/operator-framework/operator-sdk/internal/pkg/scorecard/plugins is missing; required by (root).        github.com/operator-framework/operator-sdk/pkg/kube-metrics is missing; required by (root).       github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha is missing; required by (root).github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/olm is missing; required by (root).    github.com/operator-framework/operator-sdk/internal/flags is missing; required by (root).
(22)      try github.com/operator-framework/operator-sdk@v0.7.1
(23)  ✗   github.com/operator-framework/operator-sdk at v0.7.1 has problem subpkg(s):
(23)            github.com/operator-framework/operator-sdk/internal/olm is missing; required by (root). github.com/operator-framework/operator-sdk/internal/pkg/scaffold/internal/testutil is missing; required by (root).        github.com/operator-framework/operator-sdk/pkg/kube-metrics is missing; required by (root).       github.com/operator-framework/operator-sdk/test/test-framework/pkg/controller/memcachedrs is missing; required by (root).       github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha is missing; required by (root). github.com/operator-framework/operator-sdk/internal/pkg/scaffold/internal/deps is missing; required by (root).    github.com/operator-framework/operator-sdk/pkg/restmapper is missing; required by (root).       github.com/operator-framework/operator-sdk/cmd/operator-sdk/alpha/olm is missing; required by (root).     github.com/operator-framework/operator-sdk/pkg/ansible/metrics is missing; required by (root).    github.com/operator-framework/operator-sdk/pkg/apis/scorecard/v1alpha1 is missing; required by (root).  github.com/operator-framework/operator-sdk/internal/pkg/scorecard/plugins is missing; required by (root). github.com/operator-framework/operator-sdk/internal/flags/watch is missing; required by (root).   github.com/operator-framework/operator-sdk/internal/pkg/scorecard is missing; required by (root).       github.com/operator-framework/operator-sdk/internal/pkg/scorecard/helpers is missing; required by (root). github.com/operator-framework/operator-sdk/internal/flags is missing; required by (root).
...
...
...
(134) ? attempt github.com/hashicorp/hcl with 2 pkgs; at least 1 versions to try
(191)     try github.com/hashicorp/hcl@v1.0.0
(191) ✓ select github.com/hashicorp/hcl@v1.0.0 w/10 pkgs
  ✓ found solution with 795 packages from 134 projects

Solver wall times by segment:
         b-list-pkgs: 29.830553551s
              b-gmal: 19.267843557s
  b-deduce-proj-root:   2.56594415s
     b-source-exists:  1.691998284s
         select-atom:  1.005807468s
             satisfy:  916.149689ms
     b-list-versions:  701.149145ms
    b-rev-present-in:  537.846479ms
            new-atom:    29.92888ms
            add-atom:    3.730054ms
         select-root:    3.652775ms
               other:    1.537902ms

  TOTAL: 56.556141934s

# Bringing vendor into sync
(1/1) Wrote github.com/operator-framework/operator-sdk@master: new project

root@myopenshift:operator-sdk$ make install
can't load package: package github.com/operator-framework/operator-sdk/cmd/operator-sdk: cannot find package "github.com/operator-framework/operator-sdk/cmd/operator-sdk" in any of:
        /usr/local/go/src/github.com/operator-framework/operator-sdk/cmd/operator-sdk (from $GOROOT)
        /root/go/src/github.com/operator-framework/operator-sdk/cmd/operator-sdk (from $GOPATH)
make: *** [install] Error 1

I then remember I forgot to install bzr and hg. But after installing the two, compiling can still not succeed.

lilic commented 5 years ago

@BIAOXYZ You seem to be on a branch # On branch dev-subtract-1 and not on master? What about your version of dep, what is it?

BIAOXYZ commented 5 years ago

@LiliC branch dev-subtract-1 is the same as the second latest master (you can see the commit numbers below). The reason why I reset back one commit in branch dev-subtract-1 is to keep the codebases in the two machines totally the same.

root@myopenshift:operator-sdk$ dep version
dep:
 version     : v0.5.4
 build date  : 2019-07-01
 git hash    : 1f7c19e
 go version  : go1.12.6
 go compiler : gc
 platform    : linux/amd64
 features    : ImportDuringSolve=false

root@myopenshift:operator-sdk$ echo $GO111MODULE
off

root@myopenshift:operator-sdk$ git log --oneline | wc -l
1284
root@myopenshift:operator-sdk$ git checkout master
Switched to branch 'master'
root@myopenshift:operator-sdk$ git log --oneline | wc -l
1285
estroz commented 5 years ago

@BIAOXYZ I tried reproducing your issue with no success. As you say, the build works on one machine and fails on the other. Therefore it appears your issue is indeed environmental, so I'm going to close this issue. I would check your vendored dependency's versions, make sure the code is in fact the same between machines, and check your dep version. If you can reliably recreate the dependency issues, feel free to open another ticket (since the original issue does not match the one now being discussed).

BIAOXYZ commented 5 years ago

@estroz OK, I will try again and find the reason.