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

Creating bundle for a multigroup operator with groups at different levels fails #4231

Closed
kraman opened this issue Nov 13, 2020 · 4 comments
Closed
Assignees
Labels
language/go Issue is related to a Go operator project olm-integration Issue relates to the OLM integration
Milestone

Comments

@kraman
Copy link

kraman commented Nov 13, 2020

Bug Report

What did you do?

$ cd test-operator                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
$ go mod init github.com/kraman/test-operator
$ operator-sdk init
$ vim PROJECT

domain: krishnaraman.net
layout: go.kubebuilder.io/v2
multigroup: true
projectName: test-operator
repo: github.com/kraman/test-operator
version: 3-alpha
plugins:
  go.sdk.operatorframework.io/v2-alpha: {}

$ operator-sdk create api --group subsystem.product --kind Subsystem --version v1beta1
$ operator-sdk create api --group product --kind ProductCluster --version v1beta1
$ make bundle

What did you expect to see?

No warnings or errors and Subsystem and ProductCluster are in CSV

What did you see instead? Under which circumstances?

/Users/kraman/go/bin/controller-gen "crd:trivialVersions=true" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
operator-sdk generate kustomize manifests -q
WARN[0000] Skipping CSV annotation parsing for API subsystem.product.krishnaraman.net/v1beta1, Kind=Subsystem: directory does not exist 
WARN[0000] Skipping CSV annotation parsing for API subsystem.product.krishnaraman.net/v1beta1, Kind=Subsystem: type Subsystem not found 
cd config/manager && /usr/local/bin/kustomize edit set image controller=controller:latest
/usr/local/bin/kustomize build config/manifests | operator-sdk generate bundle -q --overwrite --version 0.0.1  
INFO[0000] Building annotations.yaml                    
INFO[0000] Writing annotations.yaml in /Users/kraman/test-operator/bundle/metadata 
INFO[0000] Building Dockerfile                          
INFO[0000] Writing bundle.Dockerfile in /Users/kraman/test-operator 
operator-sdk bundle validate ./bundle
INFO[0000] Found annotations file                        bundle-dir=bundle container-tool=docker
INFO[0000] Could not find optional dependencies file     bundle-dir=bundle container-tool=docker
INFO[0000] All validation tests have completed successfully 

Environment

Operator type:
/language go

Kubernetes cluster type:

Kind cluster

$ operator-sdk version

operator-sdk version: "v1.1.0", commit: "9d27e224efac78fcc9354ece4e43a50eb30ea968", kubernetes version: "v1.18.2", go version: "go1.15.2 darwin/amd64", GOOS: "darwin", GOARCH: "amd64"

$ go version (if language is Go)

go version go1.15.3 darwin/amd64

$ kubectl version

Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.3", GitCommit:"1e11e4a2108024935ecfcb2912226cedeafd99df", GitTreeState:"clean", BuildDate:"2020-10-14T18:49:28Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", GitCommit:"e19964183377d0ec2052d1f1fa930c4d7575bd50", GitTreeState:"clean", BuildDate:"2020-08-28T22:11:08Z", GoVersion:"go1.15", Compiler:"gc", Platform:"linux/amd64"}

Possible Solution

// internal/generate/clusterserviceversion/bases/definitions/crd.go

// MakeGroupFromFullGroup returns the first element of an API group, ex. "foo" of "foo.example.com".
func MakeGroupFromFullGroup(group string) string {
	config, err := projutil.ReadConfig()
	if err != nil || !strings.HasSuffix(group, config.Domain) {
		return getHalfBySep(group, ".", 0)
	}
	return group[:len(group)-(len(config.Domain)+1)]
}

Additional context

@openshift-ci-robot openshift-ci-robot added the language/go Issue is related to a Go operator project label Nov 13, 2020
@camilamacedo86 camilamacedo86 added the olm-integration Issue relates to the OLM integration label Nov 13, 2020
@camilamacedo86
Copy link
Contributor

camilamacedo86 commented Nov 13, 2020

It shows a bug. The command /usr/local/bin/kustomize build config/manifests | operator-sdk generate bundle -q --overwrite --version 0.0.1 shows be unable to work with multigroup layout.

c/c @estroz

@kraman
Copy link
Author

kraman commented Nov 13, 2020

@camilamacedo86 multgroup projects are working IF the domain of the project is immediate parent of the API group.
Eg: Project domain foo.com with a group of something.foo.com and somethingelse.foo.com works fine.
But a project domain of foo.com with group of bar.something.foo.com would fail.

My fix above takes the project domain into account when calculating the directory to look in for the api types.go files.

@estroz
Copy link
Member

estroz commented Nov 14, 2020

/assign

@estroz estroz added this to the v1.4.0 milestone Nov 16, 2020
@estroz
Copy link
Member

estroz commented Feb 4, 2021

This was fixed indirectly by #4445

@estroz estroz closed this as completed Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language/go Issue is related to a Go operator project olm-integration Issue relates to the OLM integration
Projects
None yet
Development

No branches or pull requests

4 participants