Bug 1774630 - Incorrect CSV data causes grpc pod to panic
Summary: Incorrect CSV data causes grpc pod to panic
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: OLM
Version: 4.3.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 4.3.0
Assignee: Anik
QA Contact: Jian Zhang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-11-20 15:18 UTC by Anik
Modified: 2020-01-23 11:13 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-01-23 11:13:20 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github operator-framework operator-registry pull 128 0 'None' closed Bug 1774630: Fix panic caused by incorrect bundle data 2021-01-29 21:34:40 UTC
Github operator-framework operator-registry pull 129 0 'None' closed Bug 1774630: relocate test data 2021-01-29 21:34:40 UTC
Red Hat Product Errata RHBA-2020:0062 0 None None None 2020-01-23 11:13:36 UTC

Description Anik 2019-11-20 15:18:32 UTC
Description of problem:

When the CSV in the bundle has incorrect data, the grpc pod panics 

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x128 pc=0xcd0770]

goroutine 1 [running]:
github.com/operator-framework/operator-registry/pkg/registry.(*ClusterServiceVersion).GetReplaces(0x0, 0xc000115e80, 0xc000370980, 0x12, 0x0)
	/home/anik120/go/src/github.com/operator-framework/operator-registry/pkg/registry/csv.go:62 +0x40
github.com/operator-framework/operator-registry/pkg/sqlite.(*SQLLoader).updatePackageChannels(0xc0000d5d80, 0xc000115e80, 0xc000036d90, 0xc, 0xc000115d80, 0x1, 0x4, 0x0, 0x0, 0x0, ...)
	/home/anik120/go/src/github.com/operator-framework/operator-registry/pkg/sqlite/load.go:811 +0xa18
github.com/operator-framework/operator-registry/pkg/sqlite.(*SQLLoader).AddPackageChannels(0xc0000d5d80, 0xc000036d90, 0xc, 0xc000115d80, 0x1, 0x4, 0x0, 0x0, 0x0, 0x0)
	/home/anik120/go/src/github.com/operator-framework/operator-registry/pkg/sqlite/load.go:149 +0x2670
github.com/operator-framework/operator-registry/pkg/sqlite.(*DirectoryLoader).LoadPackagesWalkFunc(0xc0000d5e00, 0xc00004ba00, 0x77, 0x1102880, 0xc00019d6c0, 0x0, 0x0, 0x43e078, 0xc000000180)
	/home/anik120/go/src/github.com/operator-framework/operator-registry/pkg/sqlite/directory.go:170 +0x6db
github.com/operator-framework/operator-registry/pkg/sqlite.collectWalkErrs.func1(0xc00004ba00, 0x77, 0x1102880, 0xc00019d6c0, 0x0, 0x0, 0x4d52f9, 0xc00019d6c0)
	/home/anik120/go/src/github.com/operator-framework/operator-registry/pkg/sqlite/directory.go:59 +0x77
path/filepath.walk(0xc00004ba00, 0x77, 0x1102880, 0xc00019d6c0, 0xc0004a4700, 0x0, 0x0)
	/usr/bin/go/src/path/filepath/path.go:358 +0x425
path/filepath.walk(0xc0001d3500, 0x5d, 0x1102880, 0xc00019d2b0, 0xc0004a4700, 0x0, 0x0)
	/usr/bin/go/src/path/filepath/path.go:382 +0x2ff
path/filepath.walk(0xc0001d33e0, 0x57, 0x1102880, 0xc00019d1e0, 0xc0004a4700, 0x0, 0x0)
	/usr/bin/go/src/path/filepath/path.go:382 +0x2ff
path/filepath.walk(0xc000038730, 0x41, 0x1102880, 0xc00019d110, 0xc0004a4700, 0x0, 0x0)
	/usr/bin/go/src/path/filepath/path.go:382 +0x2ff
path/filepath.walk(0x7ffc4218d8ba, 0x35, 0x1102880, 0xc0004861a0, 0xc0004a4700, 0x0, 0xc000517bd8)
	/usr/bin/go/src/path/filepath/path.go:382 +0x2ff
path/filepath.Walk(0x7ffc4218d8ba, 0x35, 0xc0004a4700, 0x1, 0x1)
	/usr/bin/go/src/path/filepath/path.go:404 +0xff
github.com/operator-framework/operator-registry/pkg/sqlite.(*DirectoryLoader).Populate(0xc0000d5e00, 0xc0000d5e00, 0xc0000ca008)
	/home/anik120/go/src/github.com/operator-framework/operator-registry/pkg/sqlite/directory.go:49 +0x2b8
main.runCmdFunc(0x17491c0, 0xc0000d5c40, 0x0, 0x2, 0x0, 0x0)
	/home/anik120/go/src/github.com/operator-framework/operator-registry/cmd/initializer/main.go:73 +0x2a5
github.com/spf13/cobra.(*Command).execute(0x17491c0, 0xc0000c4160, 0x2, 0x2, 0x17491c0, 0xc0000c4160)
	/home/anik120/go/pkg/mod/github.com/spf13/cobra.5/command.go:826 +0x460
github.com/spf13/cobra.(*Command).ExecuteC(0x17491c0, 0x0, 0x0, 0xc0000b6058)
	/home/anik120/go/pkg/mod/github.com/spf13/cobra.5/command.go:914 +0x2fb
github.com/spf13/cobra.(*Command).Execute(...)
	/home/anik120/go/pkg/mod/github.com/spf13/cobra.5/command.go:864
main.main()
	/home/anik120/go/src/github.com/operator-framework/operator-registry/cmd/initializer/main.go:39 +0x2d 

```
Version-Release number of selected component (if applicable):


How reproducible:

Always

Steps to Reproduce:

1. clone the repository which has the example bundle with incorrect CSV data: https://github.com/anik120/test-manifests
2. `make build` operator-registry
3. ./bin/initializer -m test-manifests


Actual results:

operator-registry panics

Expected results:

operator-registry 

Additional info:

operator-registry logs an error message

Comment 2 Jian Zhang 2019-11-22 09:33:57 UTC
Git commit info:
mac:operator-registry jianzhang$ git branch
* master
mac:operator-registry jianzhang$ git log
commit fb1e512b62e95519df2010d8f6780d605e34d9d9 (HEAD -> master, origin/master, origin/HEAD)
Merge: 4a06281 8b0a98c
Author: OpenShift Merge Robot <openshift-merge-robot.github.com>
Date:   Fri Nov 22 01:05:17 2019 +0100

    Merge pull request #129 from anik120/bug-rearrange-dir
    
    Bug 1774630: relocate test data

mac:operator-registry jianzhang$ git clone git:anik120/test-manifests.git
Cloning into 'test-manifests'...
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 14 (delta 7), reused 14 (delta 7), pack-reused 0
Receiving objects: 100% (14/14), 23.55 KiB | 259.00 KiB/s, done.
Resolving deltas: 100% (7/7), done.

mac:operator-registry jianzhang$ make build
go build   -o bin/appregistry-server ./cmd/appregistry-server
go build   -o bin/configmap-server ./cmd/configmap-server
go build   -o bin/initializer ./cmd/initializer
go build   -o bin/opm ./cmd/opm
go build   -o bin/registry-server ./cmd/registry-server

No panic, LGTM, verify it.
mac:operator-registry jianzhang$ ./bin/initializer -m test-manifests
INFO[0000] loading Bundles                               dir=test-manifests
INFO[0000] directory                                     dir=test-manifests file=test-manifests load=bundles
INFO[0000] skipping hidden directory                     dir=test-manifests file=.git load=bundles
INFO[0000] directory                                     dir=test-manifests file=3scale-community-operator load=bundles
INFO[0000] directory                                     dir=test-manifests file=0.3.0 load=bundles
INFO[0000] loading Packages and Entries                  dir=test-manifests
INFO[0000] directory                                     dir=test-manifests file=test-manifests load=package
INFO[0000] skipping hidden directory                     dir=test-manifests file=.git load=package
INFO[0000] directory                                     dir=test-manifests file=3scale-community-operator load=package
INFO[0000] directory                                     dir=test-manifests file=0.3.0 load=package
FATA[0000] permissive mode disabled                      error="error loading manifests from directory: [could not decode contents of file test-manifests/3scale-community-operator/0.3.0/3scale-community-operator.v0.3.0.clusterserviceversion.yaml into package: error converting YAML to JSON: yaml: line 187: did not find expected key, error loading package into db: [FOREIGN KEY constraint failed, no default channel specified for 3scale-community-operator]]"

Comment 4 errata-xmlrpc 2020-01-23 11:13:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:0062


Note You need to log in before you can comment on or make changes to this bug.