Skip to content

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

@kraman

Description

@kraman

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

Metadata

Metadata

Assignees

Labels

language/goIssue is related to a Go operator projectolm-integrationIssue relates to the OLM integration

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions