Skip to content

Do not override CGO_ENABLED=1 in "operator-sdk build" #1404

@chenmin1992

Description

@chenmin1992

Type of question

Are you asking about community best practices, how to implement a specific feature, or about general context and help around the operator-sdk?

Question

What did you do?

export CGO_ENABLED=1
operator-sdk build my project

What did you expect to see?
build successfully

What did you see instead? Under which circumstances?

export CGO_ENABLED=1
operator-sdk build harbor.haodai.net/db/codis-operator:v0.0.1
# g.haodai.net/chenmin/codis-operator/vendor/github.com/CodisLabs/codis/pkg/utils/unsafe2
vendor/github.com/CodisLabs/codis/pkg/utils/unsafe2/cgo_slice.go:31:7: undefined: cgo_malloc
vendor/github.com/CodisLabs/codis/pkg/utils/unsafe2/cgo_slice.go:58:2: undefined: cgo_free
# g.haodai.net/chenmin/codis-operator/vendor/github.com/CodisLabs/codis/pkg/utils
vendor/github.com/CodisLabs/codis/pkg/utils/usage.go:8:43: undefined: Usage
vendor/github.com/CodisLabs/codis/pkg/utils/usage.go:10:12: undefined: GetUsage
vendor/github.com/CodisLabs/codis/pkg/utils/usage.go:15:12: undefined: GetUsage
Error: failed to build operator binary: (failed to exec []string{"go", "build", "-gcflags", "all=-trimpath=${GOPATH}", "-asmflags", "all=-trimpath=${GOPATH}", "-o", "/Users/klutz/go/src/g.haodai.net/chenmin/codis-operator/build/_output/bin/codis-operator", "g.haodai.net/chenmin/codis-operator/cmd/manager"}: exit status 2)
Usage:
  operator-sdk build <image> [flags]

Flags:
      --docker-build-args string     Extra docker build arguments as one string such as "--build-arg https_proxy=$https_proxy"
      --enable-tests                 Enable in-cluster testing by adding test binary to the image
  -h, --help                         help for build
      --namespaced-manifest string   Path of namespaced resources manifest for tests (default "deploy/operator.yaml")
      --test-location string         Location of tests (default "./test/e2e")

Environment

  • operator-sdk version:

    operator-sdk version v0.5.0+git

  • Kubernetes version information:

Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.6", GitCommit:"ab91afd7062d4240e95e51ac00a18bd58fddd365", GitTreeState:"clean", BuildDate:"2019-02-26T12:59:46Z", GoVersion:"go1.10.8", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.2", GitCommit:"cff46ab41ff0bb44d8584413b598ad8360ec1def", GitTreeState:"clean", BuildDate:"2019-01-10T23:28:14Z", GoVersion:"go1.11.4", Compiler:"gc", Platform:"linux/amd64"}
  • Kubernetes cluster kind:
    minikube version: v0.33.1

Additional context
I have tested, when export CGO_ENABLED=1, "operator-sdk up local" is fine, but
when export CGO_ENABLED=0, "operator-sdk up local" will failed.
github.com/CodisLabs/codis depends on github.com/spinlock/jemalloc-go
and my project depends on github.com/CodisLabs/codis, so CGO_ENABLED must be opened.Thanks.
Sorry my poor English.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions