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

0.11.0 - operator-sdk test fails due to redefined flags #2167

Closed
patelajayp opened this issue Nov 6, 2019 · 16 comments
Closed

0.11.0 - operator-sdk test fails due to redefined flags #2167

patelajayp opened this issue Nov 6, 2019 · 16 comments
Assignees
Labels
triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@patelajayp
Copy link

Bug Report

What did you do?
Ran operator-sdk test local ./test/e2e/ --no-setup --namespace sdktest to test operator locally

What did you expect to see?
Tests to run and pass

What did you see instead? Under which circumstances?
Failed with the following error:

INFO[0000] Testing operator locally.                    
/var/folders/80/9gfhhzsj62x3xt6gm81hpz6n015xt2/T/go-build638281781/b001/e2e.test flag redefined: kubeconfig
panic: /var/folders/80/9gfhhzsj62x3xt6gm81hpz6n015xt2/T/go-build638281781/b001/e2e.test flag redefined: kubeconfig

goroutine 1 [running]:
flag.(*FlagSet).Var(0xc0000ce0c0, 0x2591da0, 0xc000416b30, 0x2360c39, 0xa, 0x23799e8, 0x12)
	/usr/local/Cellar/go/1.13.1/libexec/src/flag/flag.go:848 +0x4ae
flag.(*FlagSet).StringVar(...)
	/usr/local/Cellar/go/1.13.1/libexec/src/flag/flag.go:751
flag.(*FlagSet).String(0xc0000ce0c0, 0x2360c39, 0xa, 0x0, 0x0, 0x23799e8, 0x12, 0xc000416b20)
	/usr/local/Cellar/go/1.13.1/libexec/src/flag/flag.go:764 +0xa0
flag.String(...)
	/usr/local/Cellar/go/1.13.1/libexec/src/flag/flag.go:771
github.com/operator-framework/operator-sdk/pkg/test.MainEntry(0xc00051e480)
	/Users/user/go/pkg/mod/github.com/operator-framework/operator-sdk@v0.11.0/pkg/test/main_entry.go:51 +0xc4
gitlab.com/repository/test/e2e.TestMain(...)
	/path/to/project/test/e2e/main_test.go:10
main.main()
	_testmain.go:42 +0x136
FAIL	gitlab.com/repository/test/e2e	0.047s
FAIL
Error: failed to build test binary: (failed to exec []string{"go", "test", "./test/e2e//...", "-namespacedMan", "deploy/test/empty.yaml", "-globalMan", "deploy/test/empty.yaml", "-root", "/Users/user/project", "-singleNamespace", "-parallel=1"}: exit status 1)

Environment

  • operator-sdk version: "v0.11.0", commit: "39c65c36159a9c249e5f3c178205cc6e86c16f8d", go version: "go1.12.7 darwin/amd64"
  • go version: go version go1.13.1 darwin/amd64
  • Kubernetes version information:
    Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.2", GitCommit:"f6278300bebbb750328ac16ee6dd3aa7d3549568", GitTreeState:"clean", BuildDate:"2019-08-05T16:54:35Z", GoVersion:"go1.12.7", Compiler:"gc", Platform:"darwin/amd64"} Server Version: version.Info{Major:"1", Minor:"13+", GitVersion:"v1.13.11-eks-5876d6", GitCommit:"5876d6b7429820450950ade17fe7b4bf5ccada7f", GitTreeState:"clean", BuildDate:"2019-09-24T20:54:25Z", GoVersion:"go1.11.13", Compiler:"gc", Platform:"linux/amd64"}
  • Are you writing your operator in ansible, helm, or go?
    Go
@camilamacedo86
Copy link
Contributor

Hi @patelajayp,

Note that the v0.11.0 is not supporting the go version 1.13+. Could you try to use the latest release of the SDK(0.12) and let us know if you still facing any issue with?

@camilamacedo86 camilamacedo86 added triage/support Indicates an issue that is a support question. test-framework triage/needs-information Indicates an issue needs more information in order to work on it. and removed triage/support Indicates an issue that is a support question. labels Nov 6, 2019
@patelajayp
Copy link
Author

I upgraded my operator-sdk version to:

"v0.12.0", commit: "2445fcda834ca4b7cf0d6c38fba6317fb219b469", go version: "go1.13.3 darwin/amd64"

and am still having the same issue.

@camilamacedo86
Copy link
Contributor

Hi @patelajayp,

Following some tips that I hope that help you to solve it.

  • Use ./test/e2e instead of ./test/e2e/. See the error "./test/e2e//..."
  • Use --namespace=${NAMESPACE} intead of --namespace X
  • Ensure that the k8s cluster is up and running
  • Ensure that all is applied in the cluster since you are using --no-setup

If you still facing the issue try to use --debug and --verbose to get further information and add the error here.

@AlexNPavel you have more knowledge over the test-framework. Could you give a hand here?

@robbie-demuth
Copy link

@camilamacedo86 - As Ajay mentioned, we've updated our project to 0.12.0 and are still hitting the same issue. It looks like two dependencies are declaring the same flag, but I'm unsure how to tell which ones they both are. We've also validated and/or tried all of your tips. Here's the output with --debug and --verbose

$ operator-sdk test local ./test/e2e --go-test-flags "-timeout=0" --no-setup --namespace operator-sdk-0-12-0 --debug --verbose
DEBU[0000] Debug logging is set
INFO[0000] Testing operator locally.
DEBU[0000] Running []string{"go", "test", "./test/e2e/...", "-namespacedMan", "deploy/test/empty.yaml", "-globalMan", "deploy/test/empty.yaml", "-root", "/Users/robbie.demuth/repo/my-operator", "-timeout=0", "-singleNamespace", "-parallel=1"}
/var/folders/j5/774djqhj6v9_6v_s5g3_v0zw4mwwjp/T/go-build074198978/b001/e2e.test flag redefined: kubeconfig
panic: /var/folders/j5/774djqhj6v9_6v_s5g3_v0zw4mwwjp/T/go-build074198978/b001/e2e.test flag redefined: kubeconfig

goroutine 1 [running]:
flag.(*FlagSet).Var(0xc0000ec060, 0x24b7180, 0xc00015d970, 0x2297ac7, 0xa, 0x22af22d, 0x12)
	/usr/local/Cellar/go/1.13.1/libexec/src/flag/flag.go:848 +0x4ae
flag.(*FlagSet).StringVar(...)
	/usr/local/Cellar/go/1.13.1/libexec/src/flag/flag.go:751
flag.(*FlagSet).String(0xc0000ec060, 0x2297ac7, 0xa, 0x0, 0x0, 0x22af22d, 0x12, 0xc00015d960)
	/usr/local/Cellar/go/1.13.1/libexec/src/flag/flag.go:764 +0xa0
flag.String(...)
	/usr/local/Cellar/go/1.13.1/libexec/src/flag/flag.go:771
github.com/operator-framework/operator-sdk/pkg/test.MainEntry(0xc00061b880)
	/Users/robbie.demuth/go/pkg/mod/github.com/operator-framework/operator-sdk@v0.12.0/pkg/test/main_entry.go:51 +0xc4
gitlab.com/my-operator/test/e2e.TestMain(...)
	/Users/robbie.demuth/repo/my-operator/test/e2e/main_test.go:10
main.main()
	_testmain.go:42 +0x136
FAIL	gitlab.com/my-operator/test/e2e	0.042s
FAIL
Error: failed to build test binary: (failed to exec []string{"go", "test", "./test/e2e/...", "-namespacedMan", "deploy/test/empty.yaml", "-globalMan", "deploy/test/empty.yaml", "-root", "/Users/robbie.demuth/repo/my-operator", "-timeout=0", "-singleNamespace", "-parallel=1"}: exit status 1)
Usage:
  operator-sdk test local <path to tests directory> [flags]

Flags:
      --debug                         Enable debug-level logging
      --global-manifest string        Path to manifest for Global resources (e.g. CRD manifests)
      --go-test-flags string          Additional flags to pass to go test
  -h, --help                          help for local
      --image string                  Use a different operator image from the one specified in the namespaced manifest
      --kubeconfig string             Kubeconfig path
      --local-operator-flags string   The flags that the operator needs (while using --up-local). Example: "--flag1 value1 --flag2=value2"
      --molecule-test-flags string    Additional flags to pass to molecule test
      --namespace string              If non-empty, single namespace to run tests in
      --namespaced-manifest string    Path to manifest for per-test, namespaced resources (e.g. RBAC and Operator manifest)
      --no-setup                      Disable test resource creation
      --up-local                      Enable running operator locally with go run instead of as an image in the cluster

Global Flags:
      --verbose   Enable verbose logging

@robbie-demuth
Copy link

robbie-demuth commented Nov 11, 2019

@camilamacedo86 - So I did a bit more digging and was finally able to debug the end-to-end tests in Goland. It looks like there's a package in controller-runtime that defines the kubeconfig flag in its init function, which conflicts with the similarly named flag in the Operator SDK

controller-runtime
https://github.com/kubernetes-sigs/controller-runtime/blob/v0.3.0/pkg/client/config/config.go#L38-L40

operator-sdk
https://github.com/operator-framework/operator-sdk/blob/v0.12.0/pkg/test/main_entry.go#L51

I'd imagine that this must be causing a problem for all 0.12.0 projects since they use controller-runtime v0.3.0, no? For what it's worth, the flag is also in controller-runtime 0.2.0 as well

@joelanford
Copy link
Member

Hmm. We have e2e tests in our CI system that run the e2e framework and those tests are still passing. So something funky is going on here. Thanks for raising this issue! I'll dig into this.

@joelanford joelanford self-assigned this Nov 11, 2019
@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci-robot openshift-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 10, 2020
@thebithead
Copy link

/remove-lifecycle stale

@openshift-ci-robot openshift-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 20, 2020
@thebithead
Copy link

thebithead commented Feb 20, 2020

I have run into this as well.

tgates@tgu19:~/gopath/src/github.com/nuodb/nuodb-operator$ operator-sdk test local ./ntest/e2e --namespace $OPERATOR_NAMESPACE --verbose --kubeconfig ~/.kube/config --image $NUODB_OP_IMAGE --debug --verbose
DEBU[0000] Debug logging is set                         
INFO[0000] Testing operator locally.                    
DEBU[0000] Running []string{"go", "test", "./ntest/e2e/...", "-namespacedMan", "/tmp/namespaced-manifest.yaml320222523", "-globalMan", "/tmp/global-manifest.yaml917165918", "-root", "/home/tgates/gopath/src/github.com/nuodb/nuodb-operator", "-kubeconfig", "/home/tgates/.kube/config", "-singleNamespace", "-parallel=1"} 
/tmp/go-build637475276/b001/e2e.test flag redefined: kubeconfig
panic: /tmp/go-build637475276/b001/e2e.test flag redefined: kubeconfig

goroutine 1 [running]:
flag.(*FlagSet).Var(0xc0000521e0, 0x1cc2ba0, 0xc0002f5f00, 0x1a65c0a, 0xa, 0x1a7e830, 0x12)
	/usr/local/go/src/flag/flag.go:848 +0x4ae
flag.(*FlagSet).StringVar(...)
	/usr/local/go/src/flag/flag.go:751
flag.(*FlagSet).String(0xc0000521e0, 0x1a65c0a, 0xa, 0x0, 0x0, 0x1a7e830, 0x12, 0xc0002f5ed0)
	/usr/local/go/src/flag/flag.go:764 +0xa0
flag.String(...)
	/usr/local/go/src/flag/flag.go:771
github.com/operator-framework/operator-sdk/pkg/test.MainEntry(0xc000671d00)
	/home/tgates/gopath/pkg/mod/github.com/operator-framework/operator-sdk@v0.9.0/pkg/test/main_entry.go:51 +0xc4
nuodb/nuodb-operator/ntest/e2e.TestMain(...)
	/home/tgates/gopath/src/github.com/nuodb/nuodb-operator/ntest/e2e/main_test.go:10
main.main()
	_testmain.go:50 +0x136
FAIL	nuodb/nuodb-operator/ntest/e2e	0.029s
?   	nuodb/nuodb-operator/ntest/e2e/util	[no test files]
FAIL
Error: failed to build test binary: (failed to exec []string{"go", "test", "./ntest/e2e/...", "-namespacedMan", "/tmp/namespaced-manifest.yaml320222523", "-globalMan", "/tmp/global-manifest.yaml917165918", "-root", "/home/tgates/gopath/src/github.com/nuodb/nuodb-operator", "-kubeconfig", "/home/tgates/.kube/config", "-singleNamespace", "-parallel=1"}: exit status 1)
Usage:
  operator-sdk test local <path to tests directory> [flags]

Flags:
      --debug                         Enable debug-level logging
      --global-manifest string        Path to manifest for Global resources (e.g. CRD manifests)
      --go-test-flags string          Additional flags to pass to go test
  -h, --help                          help for local
      --image string                  Use a different operator image from the one specified in the namespaced manifest
      --kubeconfig string             Kubeconfig path
      --local-operator-flags string   The flags that the operator needs (while using --up-local). Example: "--flag1 value1 --flag2=value2"
      --molecule-test-flags string    Additional flags to pass to molecule test
      --namespace string              If non-empty, single namespace to run tests in
      --namespaced-manifest string    Path to manifest for per-test, namespaced resources (e.g. RBAC and Operator manifest)
      --no-setup                      Disable test resource creation
      --up-local                      Enable running operator locally with go run instead of as an image in the cluster

Global Flags:
      --verbose   Enable verbose logging

Environment

operator-sdk version: "operator-sdk version: v0.9.0, commit: 560208d"

go version: "go version go1.13.5 linux/amd64"

Kubernetes version information:"Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.1", GitCommit:"b7394102d6ef778017f2ca4046abbaa23b88c290", GitTreeState:"clean", BuildDate:"2019-04-08T17:11:31Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}"
"Server Version: version.Info{Major:"1", Minor:"14+", GitVersion:"v1.14.6+32dc4a0", GitCommit:"32dc4a0", GitTreeState:"clean", BuildDate:"2019-12-10T07:52:29Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}"

Are you writing your operator in ansible, helm, or go?
Go

@camilamacedo86
Copy link
Contributor

Hi @thebithead,

Note that the version 0.9.0 is not compatible with the Go 1.13+. Could you please check it with the latest version of SDK.

@asmacdo
Copy link
Member

asmacdo commented Mar 9, 2020

If this is still an issue, please reopen.

@asmacdo asmacdo closed this as completed Mar 9, 2020
@camilamacedo86
Copy link
Contributor

Hi @thebithead,

Just to let you know we discussed it in the bug triaged and we decide to close since shows that the same will no be faced if you are using the 1.13+ go version and the latest version of SDK. However, if you still facing this issue please let us know for we are able to re-open this one and please provide the data regards your latest test/check as well.

@thebithead
Copy link

thebithead commented Mar 9, 2020 via email

@camilamacedo86
Copy link
Contributor

Hi @thebithead the Go version 1.12. is not supportable with the latest version. Then, issue can really occur with if you are using Go version 1.12. So, I understand that all is fine when you are using the go 1.13+ and the latest, Am I right?

@thebithead
Copy link

thebithead commented Mar 9, 2020 via email

@robbie-demuth
Copy link

FWIW, I think this is now solved by #2731

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

No branches or pull requests

8 participants