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

operator-sdk does not copy the configs from the given index image #6505

Closed
iamniting opened this issue Jul 21, 2023 · 2 comments · Fixed by #6512
Closed

operator-sdk does not copy the configs from the given index image #6505

iamniting opened this issue Jul 21, 2023 · 2 comments · Fixed by #6512
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.
Milestone

Comments

@iamniting
Copy link
Contributor

Bug Report

What did you do?

I am using operator-sdk to install the operator with the below command and expect the new catalog to have the dependent operators as I am passing the index image which has the dependent operators inside it under the configs directory.

operator-sdk run bundle quay.io/nigoyal/odf-operator-bundle:latest --timeout=10m --security-context-config restricted -n openshift-storage --index-image quay.io/nigoyal/odf-operator-catalog:odf-deps

What did you expect to see?

I am expecting my operator to get installed with the dependencies but it is stuck as it can not resolve the deps. Because the new catalog does not copy the configs directory into the odf-operator-catalog-configs

What did you see instead? Under which circumstances?

$ bin/operator-sdk run bundle quay.io/nigoyal/odf-operator-bundle:latest --timeout=10m --security-context-config restricted -n openshift-storage --index-image quay.io/nigoyal/odf-operator-catalog:odf-deps
INFO[0015] Creating a File-Based Catalog of the bundle "quay.io/nigoyal/odf-operator-bundle:latest" 
INFO[0018] Rendering a File-Based Catalog of the Index Image "quay.io/nigoyal/odf-operator-catalog:odf-deps" to verify if bundle "odf-operator.v4.14.0" is present 
INFO[0028] Generated the extra FBC for the bundle image "odf-operator.v4.14.0" 
INFO[0028] Generated a valid File-Based Catalog         
INFO[0037] Created registry pod: quay-io-nigoyal-odf-operator-bundle-latest 
INFO[0037] Created CatalogSource: odf-operator-catalog  
INFO[0038] OperatorGroup "operator-sdk-og" created      
INFO[0039] Created Subscription: odf-operator-v4-14-0-sub 
FATA[0602] Failed to run bundle: install plan is not available for the subscription odf-operator-v4-14-0-sub: timed out waiting for the condition


$ oc exec quay-io-nigoyal-odf-operator-bundle-latest -- ls -lhR odf-operator-catalog-configs
Defaulted container "registry-grpc" out of: registry-grpc, registry-grpc-init (init)
odf-operator-catalog-configs:
total 0      
drwxrwsrwx    2 root     10006200      27 Jul 21 06:11 odf-operator-catalog-configmap-partition-1

odf-operator-catalog-configs/odf-operator-catalog-configmap-partition-1:
total 8K     
-rw-r--r--    1 10006200 10006200    7.3K Jul 21 06:11 extraFBC.yaml


$ oc exec quay-io-nigoyal-odf-operator-bundle-latest -- ls -lhR configs
Defaulted container "registry-grpc" out of: registry-grpc, registry-grpc-init (init)
configs:
total 1M     
-rw-r--r--    1 root     root       58.6K Jul 20 07:10 csiaddons.yaml
-rw-r--r--    1 root     root      142.9K Jul 20 07:10 ibm.yaml
-rw-r--r--    1 root     root         704 Jul 20 07:07 index.yaml
-rw-r--r--    1 root     root      214.6K Jul 20 07:10 noobaa.yaml
-rw-r--r--    1 root     root      693.0K Jul 20 07:10 ocs.yaml

Environment

Operator type:

Kubernetes cluster type:

$ operator-sdk version

operator-sdk version
operator-sdk version: "v1.30.0", commit: "b794fe909abc1affa1f28cfb75ceaf3bf79187e6", kubernetes version: "1.26.0", go version: "go1.19.10", GOOS: "linux", GOARCH: "amd64"

$ go version (if language is Go)

go version
go version go1.20.5 linux/amd64

$ kubectl version

$ oc version
Client Version: 4.10.9
Server Version: 4.14.0-0.nightly-2023-07-20-215234
Kubernetes Version: v1.27.3+4aaeaec

Possible Solution

Possible solution would be to create the new directory which operator-sdk creates under the configs itself and serve from configs or copy the configs data inside new directory.

Additional context

slact thread: https://redhat-internal.slack.com/archives/C3VS0LV41/p1689838697181879

@rashmigottipati rashmigottipati added this to the Backlog milestone Jul 24, 2023
@rashmigottipati rashmigottipati added the kind/bug Categorizes issue or PR as related to a bug. label Jul 24, 2023
@everettraven
Copy link
Contributor

A workaround for now would be to create another CatalogSource using your index image which should spin up a registry pod that is serving the catalog contents that contains the dependencies.

I think the bug lies somewhere in here:

func generateExtraFBC(ctx context.Context, indexImage string, bundleDeclConfig fbcutil.BundleDeclcfg, skipTLSVerify bool, useHTTP bool) (*declarativeconfig.DeclarativeConfig, error) {
log.Infof("Rendering a File-Based Catalog of the Index Image %q to verify if bundle %q is present", indexImage, bundleDeclConfig.Bundle.Name)
imageDeclConfig, err := fbcutil.RenderRefs(ctx, []string{indexImage}, skipTLSVerify, useHTTP)
if err != nil {
return nil, err
}
for _, bundle := range imageDeclConfig.Bundles {
if bundle.Name == bundleDeclConfig.Bundle.Name && bundle.Package == bundleDeclConfig.Bundle.Package {
return nil, fmt.Errorf("bundle %q already exists in the index image: %s", bundleDeclConfig.Bundle.Name, indexImage)
}
}
for _, channel := range imageDeclConfig.Channels {
if channel.Name == bundleDeclConfig.Channel.Name && channel.Package == bundleDeclConfig.Bundle.Package {
return nil, fmt.Errorf("channel %q already exists in the index image: %s", bundleDeclConfig.Channel.Name, indexImage)
}
}
var isPackagePresent bool
for _, pkg := range imageDeclConfig.Packages {
if pkg.Name == bundleDeclConfig.Package.Name {
isPackagePresent = true
break
}
}
extraDeclConfig := &declarativeconfig.DeclarativeConfig{
Bundles: []declarativeconfig.Bundle{bundleDeclConfig.Bundle},
Channels: []declarativeconfig.Channel{bundleDeclConfig.Channel},
}
if !isPackagePresent {
extraDeclConfig.Packages = []declarativeconfig.Package{bundleDeclConfig.Package}
}
log.Infof("Generated the extra FBC for the bundle image %q", bundleDeclConfig.Bundle.Name)
return extraDeclConfig, nil
}

It looks like we are only returning the "extra" FBC contents instead of returning the "extra" + index FBC content

@iamniting
Copy link
Contributor Author

Thanks @everettraven for pointing this out. I tried to fix it and it did work well in my testing. I will raise a PR.

iamniting added a commit to iamniting/operator-sdk that referenced this issue Jul 25, 2023
copy the FBC of index-image as well if --index-image is passed to the
operator-sdk run bundle command

Fixes operator-framework#6505

Signed-off-by: Nitin Goyal <nigoyal@redhat.com>
iamniting added a commit to iamniting/operator-sdk that referenced this issue Jul 25, 2023
copy the FBC of index-image as well if --index-image is passed to the
operator-sdk run bundle command

Fixes operator-framework#6505

Signed-off-by: Nitin Goyal <nigoyal@redhat.com>
rashmigottipati pushed a commit that referenced this issue Jul 25, 2023
)

copy the FBC of index-image as well if --index-image is passed to the operator-sdk run bundle command

Fixes #6505

Signed-off-by: Nitin Goyal <nigoyal@redhat.com>
@rashmigottipati rashmigottipati modified the milestones: Backlog, v1.31.0 Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants