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

Image build fails with "operator-sdk build" command #3080

Closed
demonCoder95 opened this issue May 21, 2020 · 8 comments · Fixed by #3122
Closed

Image build fails with "operator-sdk build" command #3080

demonCoder95 opened this issue May 21, 2020 · 8 comments · Fixed by #3122
Labels
kind/documentation Categorizes issue or PR as related to documentation.
Milestone

Comments

@demonCoder95
Copy link
Contributor

Bug Report

What did you do?
While following the Getting Started guide, everything worked fine till the image building step.

$ operator-sdk build quay.io/<user>/memcached-operator:v0.0.1

What did you expect to see?
Expected to see a successful building of image

What did you see instead? Under which circumstances?
A failure with the following terminal output

# github.com/example-inc/memcached-operator/pkg/apis/cache/v1alpha1
pkg/apis/cache/v1alpha1/memcached_types.go:42:25: cannot use &Memcached literal (type *Memcached) as type runtime.Object in argument to SchemeBuilder.Register:
	*Memcached does not implement runtime.Object (missing DeepCopyObject method)
pkg/apis/cache/v1alpha1/memcached_types.go:42:39: cannot use &MemcachedList literal (type *MemcachedList) as type runtime.Object in argument to SchemeBuilder.Register:
	*MemcachedList does not implement runtime.Object (missing DeepCopyObject method)
Error: failed to build operator binary: failed to exec []string{"go", "build", "-o", "/home/noor/go/src/github.com/example-inc/memcached-operator/build/_output/bin/memcached-operator", "-gcflags", "all=-trimpath=/home/noor/go/src/github.com/example-inc", "-asmflags", "all=-trimpath=/home/noor/go/src/github.com/example-inc", "-mod=vendor", "github.com/example-inc/memcached-operator/cmd/manager"}: exit status 2
Usage:
  operator-sdk build <image> [flags]

Flags:
      --go-build-args string      Extra Go build arguments as one string such as "-ldflags -X=main.xyz=abc"
  -h, --help                      help for build
      --image-build-args string   Extra image build arguments as one string such as "--build-arg https_proxy=$https_proxy"
      --image-builder string      Tool to build OCI images. One of: [docker, podman, buildah] (default "docker")

Global Flags:
      --verbose   Enable verbose logging

Environment

  • operator-sdk version:

operator-sdk version: "v0.15.0", commit: "21a93ca379b887ab2303b0d148a399bf205c3231"

  • go version:

go version: "go1.13.5 linux/amd64"

  • Kubernetes version information:
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.3", GitCommit:"b3cbbae08ec52a7fc73d334838e18d17e8512749", GitTreeState:"clean", BuildDate:"2019-11-13T11:23:11Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", BuildDate:"2019-10-15T19:09:08Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}
  • Kubernetes cluster kind: minikube

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

go

Possible Solution
I don't have a workaround for this.

Additional context
I've tried googling and found existing issues regarding the go mod vendor command. However, I've noticed that all of those issue listings were for older operator-sdk versions, and this version doesn't invoke go mod vendor when running operator-sdk new command. Therefore, those fixes were not applicable.

@estroz
Copy link
Member

estroz commented May 22, 2020

@demonCoder95 have you tried running operator-sdk generate k8s?

/triage support

@openshift-ci-robot openshift-ci-robot added the triage/support Indicates an issue that is a support question. label May 22, 2020
@demonCoder95
Copy link
Contributor Author

Yes, I did. It gives me the following output:

INFO[0000] Running deepcopy code-generation for Custom Resource group versions: [cache:[v1alpha1], ] 
F0523 01:18:27.122034    5157 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from github.com/example-inc/memcached-operator/pkg/apis/cache/v1alpha1.Memcached

I'm unsure as to if this unsupported type error is of any significance. I haven't done anything other than what the guide was suggesting.
After running this, and running the operator-sdk build <link> command I get the same error as listed above.

@estroz
Copy link
Member

estroz commented May 22, 2020

Ah yes, see #1854 (comment). The methods necessary for your types to implement the Object interface are not being generated for that reason.

@demonCoder95
Copy link
Contributor Author

Exporting GOROOT fixed the operator-sdk generate k8s issue, the generation is successful! I'm having some issues with docker when trying to build the image now, let me fix those, and let's see if I can build the image now.
Also, I think we should add this exporting gotcha in the getting-started guide, avoiding such problems in the future.

@demonCoder95
Copy link
Contributor Author

I suggest we add an "expected command output" after the operator-sdk generate k8s command in the doc. And below that expected output, we add this note to use the export in case the generation fails. I can send a patch to the doc for this pretty quick.

@demonCoder95
Copy link
Contributor Author

I've been able to achieve a successful build. However, I think the documentation update should be done before we close this issue. What do you think? @estroz

@estroz
Copy link
Member

estroz commented May 26, 2020

We should add the underlying issue to the FAQ. Feel free to submit a PR if you have time @demonCoder95.

/kind documentation
/remove-triage support

@openshift-ci-robot openshift-ci-robot added kind/documentation Categorizes issue or PR as related to documentation. and removed triage/support Indicates an issue that is a support question. labels May 26, 2020
@estroz estroz added this to the Backlog milestone May 26, 2020
@demonCoder95
Copy link
Contributor Author

Okay, I'll send a patch to the FAQ and reference this issue so that it can be closed upon merge. Thanks!

demonCoder95 added a commit to demonCoder95/operator-sdk that referenced this issue May 27, 2020
When following the Getting Started guide, not setting the GOROOT
env variable can fail image builds of memcached operator. This
adds an FAQ in the docs, to allow users to troubleshoot the problem.

Fixes operator-framework#3080
demonCoder95 added a commit to demonCoder95/operator-sdk that referenced this issue May 27, 2020
Generalize the description to remove instance of Getting Started
guide

Fixes operator-framework#3080
demonCoder95 added a commit to demonCoder95/operator-sdk that referenced this issue May 27, 2020
Generalize the description to remove instance of Getting Started
guide

Fixes operator-framework#3080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/documentation Categorizes issue or PR as related to documentation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants