Skip to content

Commit 89dee1d

Browse files
authoredMar 3, 2021
Merge branch 'master' into patch-1
2 parents a696a50 + 92a4c92 commit 89dee1d

File tree

15 files changed

+92
-264
lines changed

15 files changed

+92
-264
lines changed
 

‎.github/workflows/test.yml

+17-9
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@ jobs:
2424
file: coverage.out
2525
fail_ci_if_error: false
2626
e2e-minikube:
27-
runs-on: ubuntu-latest
27+
runs-on: ubuntu-20.04
2828
steps:
2929
- uses: actions/checkout@v2
3030
- run: |
31-
sudo apt-get -y update
32-
sudo apt-get -y upgrade
33-
sudo apt-get -y install conntrack
34-
podman version
31+
sudo apt-get update \
32+
&& sudo apt-get remove buildah podman -y \
33+
&& sudo apt-get autoremove -y \
34+
&& sudo apt-get upgrade \
35+
&& sudo apt-get install podman dbus-x11 conntrack -y \
36+
&& podman version
37+
- run: |
3538
curl -sLo minikube "$(curl -sL https://api.github.com/repos/kubernetes/minikube/releases/latest | jq -r '[.assets[] | select(.name == "minikube-linux-amd64")] | first | .browser_download_url')"
3639
chmod +x minikube
3740
sudo mv minikube /bin/
@@ -54,14 +57,19 @@ jobs:
5457
export DOCKER_REGISTRY_HOST=localhost:443
5558
- run: |
5659
KUBECONFIG="$HOME/.kube/config" DOCKER_REGISTRY_HOST=localhost:443 make build e2e
60+
5761
e2e-kind:
58-
runs-on: ubuntu-latest
62+
runs-on: ubuntu-20.04
5963
steps:
6064
- uses: actions/checkout@v2
6165
- run: |
62-
sudo apt-get -y update
63-
sudo apt-get -y upgrade
64-
podman version
66+
sudo apt-get update \
67+
&& sudo apt-get remove buildah podman -y \
68+
&& sudo apt-get autoremove -y \
69+
&& sudo apt-get upgrade \
70+
&& sudo apt-get -y install podman dbus-x11 \
71+
&& podman version
72+
- run: |
6573
curl -sLo kind "$(curl -sL https://api.github.com/repos/kubernetes-sigs/kind/releases/latest | jq -r '[.assets[] | select(.name == "kind-linux-amd64")] | first | .browser_download_url')"
6674
chmod +x kind
6775
sudo mv kind /bin/

‎Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ image-upstream:
6666

6767
.PHONY: vendor
6868
vendor:
69+
$(GO) mod tidy
6970
$(GO) mod vendor
71+
$(GO) mod verify
7072

7173
.PHONY: codegen
7274
codegen:

‎OWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ reviewers:
1515
- anik120
1616
- exdx
1717
- awgreene
18-
- Bowenislandsong
1918
- benluddy
2019
- hasbro17
2120
- ankitathomas
2221
- estroz
2322
- joelanford
2423
- jmrodri
24+
- timflannagan
2525
# Bugzilla component
2626
component: "OLM"

‎README.md

+25-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[![Build Status](https://travis-ci.com/operator-framework/operator-registry.svg?branch=master)](https://travis-ci.com/operator-framework/operator-registry)
2+
23
# operator-registry
34

4-
Operator Registry runs in a Kubernetes or OpenShift cluster to provide operator catalog data to [Operator Lifecycle Manager](https://github.com/operator-framework/operator-lifecycle-manager).
5+
Operator Registry runs in a Kubernetes or OpenShift cluster to provide operator catalog data to [Operator Lifecycle Manager](https://github.com/operator-framework/operator-lifecycle-manager).
56

67
# Overview
78

@@ -13,23 +14,23 @@ This project provides the following binaries:
1314
* `registry-server`, which takes a sqlite database loaded with manifests, and exposes a gRPC interface to it.
1415
* Deprecated - use `opm registry serve` instead
1516
* `configmap-server`, which takes a kubeconfig and a configmap reference, and parses the configmap into the sqlite database before exposing it via the same interface as `registry-server`.
16-
17+
1718
And libraries:
18-
19-
* `pkg/client` - providing a high-level client interface for the gRPC api.
20-
* `pkg/api` - providing low-level client libraries for the gRPC interface exposed by `registry-server`.
21-
* `pkg/registry` - providing basic registry types like Packages, Channels, and Bundles.
22-
* `pkg/sqlite` - providing interfaces for building sqlite manifest databases from `ConfigMap`s or directories, and for querying an existing sqlite database.
23-
* `pkg/lib` - providing external interfaces for interacting with this project as an api that defines a set of standards for operator bundles and indexes.
24-
* `pkg/containertools` - providing an interface to interact with and shell out to common container tooling binaries (if installed on the environment)
19+
20+
* `pkg/client` - providing a high-level client interface for the gRPC api.
21+
* `pkg/api` - providing low-level client libraries for the gRPC interface exposed by `registry-server`.
22+
* `pkg/registry` - providing basic registry types like Packages, Channels, and Bundles.
23+
* `pkg/sqlite` - providing interfaces for building sqlite manifest databases from `ConfigMap`s or directories, and for querying an existing sqlite database.
24+
* `pkg/lib` - providing external interfaces for interacting with this project as an api that defines a set of standards for operator bundles and indexes.
25+
* `pkg/containertools` - providing an interface to interact with and shell out to common container tooling binaries (if installed on the environment)
2526

2627
**NOTE:** The purpose of `opm` tool is to help who needs to manage index catalogues for OLM instances. However, if you are looking for a tool to help you to integrate your operator project with OLM then you should use [Operator-SDK](https://github.com/operator-framework/operator-sdk).
2728

2829
# Manifest format
2930

3031
We refer to a directory of files with one ClusterServiceVersion as a "bundle". A bundle typically includes a ClusterServiceVersion and the CRDs that define the owned APIs of the CSV in its manifest directory, though additional objects may be included. It also includes an annotations file in its metadata folder which defines some higher level aggregate data that helps to describe the format and package information about how the bundle should be added into an index of bundles.
3132

32-
```
33+
```bash
3334
# example bundle
3435
etcd
3536
├── manifests
@@ -41,19 +42,18 @@ We refer to a directory of files with one ClusterServiceVersion as a "bundle". A
4142

4243
When loading manifests into the database, the following invariants are validated:
4344

44-
* The bundle must have at least one channel defined in the annotations.
45-
* Every bundle has exactly one ClusterServiceVersion.
46-
* If a ClusterServiceVersion `owns` a CRD, that CRD must exist in the bundle.
45+
* The bundle must have at least one channel defined in the annotations.
46+
* Every bundle has exactly one ClusterServiceVersion.
47+
* If a ClusterServiceVersion `owns` a CRD, that CRD must exist in the bundle.
4748

4849
Bundle directories are identified solely by the fact that they contain a ClusterServiceVersion, which provides an amount of freedom for layout of manifests.
4950

50-
Check out the [operator bundle design](docs/design/operator-bundle.md) for more detail on the bundle format.
51+
Check out the [operator bundle design](docs/design/operator-bundle.md) for more detail on the bundle format.
5152

5253
# Bundle images
5354

5455
Using [OCI spec](https://github.com/opencontainers/image-spec/blob/master/spec.md) container images as a method of storing the manifest and metadata contents of individual bundles, `opm` interacts directly with these images to generate and incrementally update the database. Once you have your [manifests defined](https://operator-framework.github.io/olm-book/docs/packaging-an-operator.html#writing-your-operator-manifests) and have created a directory in the format defined above, building the image is as simple as defining a [Dockerfile](docs/design/operator-bundle.md#Bundle-Dockerfile) and building that image:
5556

56-
5757
```sh
5858
podman build -t quay.io/my-container-registry-namespace/my-manifest-bundle:latest -f bundle.Dockerfile .
5959
```
@@ -139,7 +139,7 @@ apiVersion: operators.coreos.com/v1alpha1
139139
kind: Subscription
140140
metadata:
141141
name: etcd-subscription
142-
namespace: default
142+
namespace: default
143143
spec:
144144
channel: alpha
145145
name: etcd
@@ -152,7 +152,7 @@ spec:
152152
After starting a catalog locally:
153153

154154
```sh
155-
$ docker run --rm -p 50051:50051 <index image>
155+
docker run --rm -p 50051:50051 <index image>
156156
```
157157

158158
[grpcurl](https://github.com/fullstorydev/grpcurl) is a useful tool for interacting with the api:
@@ -171,8 +171,9 @@ ListPackages
171171
```
172172

173173
```sh
174-
$ grpcurl -plaintext localhost:50051 api.Registry/ListPackages
174+
grpcurl -plaintext localhost:50051 api.Registry/ListPackages
175175
```
176+
176177
```json
177178
{
178179
"name": "etcd"
@@ -183,8 +184,9 @@ $ grpcurl -plaintext localhost:50051 api.Registry/ListPackages
183184
```
184185

185186
```sh
186-
$ grpcurl -plaintext -d '{"name":"etcd"}' localhost:50051 api.Registry/GetPackage
187+
grpcurl -plaintext -d '{"name":"etcd"}' localhost:50051 api.Registry/GetPackage
187188
```
189+
188190
```json
189191
{
190192
"name": "etcd",
@@ -202,6 +204,7 @@ $ grpcurl -plaintext -d '{"name":"etcd"}' localhost:50051 api.Registry/GetPackag
202204
$ grpcurl localhost:50051 describe api.Registry.GetBundleForChannel
203205
api.Registry.GetBundleForChannel is a method:
204206
```
207+
205208
```json
206209
{
207210
"name": "GetBundleForChannel",
@@ -216,6 +219,7 @@ api.Registry.GetBundleForChannel is a method:
216219
$ grpcurl localhost:50051 describe api.GetBundleInChannelRequest
217220
api.GetBundleInChannelRequest is a message:
218221
```
222+
219223
```json
220224
{
221225
"name": "GetBundleInChannelRequest",
@@ -248,8 +252,9 @@ api.GetBundleInChannelRequest is a message:
248252
```
249253

250254
```sh
251-
$ grpcurl -plaintext -d '{"pkgName":"etcd","channelName":"alpha"}' localhost:50051 api.Registry/GetBundleForChannel
255+
grpcurl -plaintext -d '{"pkgName":"etcd","channelName":"alpha"}' localhost:50051 api.Registry/GetBundleForChannel
252256
```
257+
253258
```json
254259
{
255260
"csvName": "etcdoperator.v0.9.2",

‎cmd/opm/index/add.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,8 @@ func getContainerTools(cmd *cobra.Command) (string, string, error) {
195195
if containerTool != "" {
196196
if pullTool == "" && buildTool == "" {
197197
return containerTool, containerTool, nil
198-
} else {
199-
return "", "", fmt.Errorf("container-tool cannot be set alongside pull-tool or build-tool")
200198
}
199+
return "", "", fmt.Errorf("container-tool cannot be set alongside pull-tool or build-tool")
201200
}
202201

203202
// Check for defaults, then return

‎go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ require (
5555
k8s.io/api v0.20.0
5656
k8s.io/apiextensions-apiserver v0.20.0
5757
k8s.io/apimachinery v0.20.0
58-
k8s.io/apiserver v0.20.0
5958
k8s.io/client-go v0.20.0
6059
k8s.io/klog v1.0.0
6160
k8s.io/kubectl v0.20.0

‎go.sum

-123
Large diffs are not rendered by default.

‎pkg/lib/bundle/utils_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ func clearDir(dir string) {
7070
for _, item := range items {
7171
if item.IsDir() {
7272
continue
73-
} else {
74-
os.Remove(filepath.Join(dir, item.Name()))
7573
}
74+
os.Remove(filepath.Join(dir, item.Name()))
7675
}
7776
}

‎pkg/lib/registry/registry.go

+37-38
Original file line numberDiff line numberDiff line change
@@ -150,46 +150,45 @@ func populate(ctx context.Context, loader registry.Load, graphLoader registry.Gr
150150
}
151151
return err
152152
}
153-
if overwritten != "" {
154-
// get all bundle paths for that package - we will re-add these to regenerate the graph
155-
bundles, err := querier.GetBundlesForPackage(ctx, img.Bundle.Package)
156-
if err != nil {
157-
return err
158-
}
159-
type unpackedImage struct {
160-
to image.Reference
161-
from string
162-
cleanup func()
163-
err error
164-
}
165-
unpacked := make(chan unpackedImage)
166-
for bundle := range bundles {
167-
// parallelize image pulls
168-
go func(bundle registry.BundleKey, img *registry.ImageInput) {
169-
if bundle.CsvName != img.Bundle.Name {
170-
to, from, cleanup, err := unpackImage(ctx, reg, image.SimpleReference(bundle.BundlePath))
171-
unpacked <- unpackedImage{to: to, from: from, cleanup: cleanup, err: err}
172-
} else {
173-
unpacked <- unpackedImage{to: to, from: from, cleanup: func() { return }, err: nil}
174-
}
175-
}(bundle, img)
176-
}
177-
if _, ok := overwriteImageMap[img.Bundle.Package]; !ok {
178-
overwriteImageMap[img.Bundle.Package] = make(map[image.Reference]string, 0)
179-
}
180-
for i := 0; i < len(bundles); i++ {
181-
unpack := <-unpacked
182-
if unpack.err != nil {
183-
return unpack.err
184-
}
185-
overwriteImageMap[img.Bundle.Package][unpack.to] = unpack.from
186-
if _, ok := unpackedImageMap[unpack.to]; ok {
187-
delete(unpackedImageMap, unpack.to)
153+
if overwritten == "" {
154+
return fmt.Errorf("index add --overwrite-latest is only supported when using bundle images")
155+
}
156+
// get all bundle paths for that package - we will re-add these to regenerate the graph
157+
bundles, err := querier.GetBundlesForPackage(ctx, img.Bundle.Package)
158+
if err != nil {
159+
return err
160+
}
161+
type unpackedImage struct {
162+
to image.Reference
163+
from string
164+
cleanup func()
165+
err error
166+
}
167+
unpacked := make(chan unpackedImage)
168+
for bundle := range bundles {
169+
// parallelize image pulls
170+
go func(bundle registry.BundleKey, img *registry.ImageInput) {
171+
if bundle.CsvName != img.Bundle.Name {
172+
to, from, cleanup, err := unpackImage(ctx, reg, image.SimpleReference(bundle.BundlePath))
173+
unpacked <- unpackedImage{to: to, from: from, cleanup: cleanup, err: err}
174+
} else {
175+
unpacked <- unpackedImage{to: to, from: from, cleanup: func() { return }, err: nil}
188176
}
189-
defer unpack.cleanup()
177+
}(bundle, img)
178+
}
179+
if _, ok := overwriteImageMap[img.Bundle.Package]; !ok {
180+
overwriteImageMap[img.Bundle.Package] = make(map[image.Reference]string, 0)
181+
}
182+
for i := 0; i < len(bundles); i++ {
183+
unpack := <-unpacked
184+
if unpack.err != nil {
185+
return unpack.err
190186
}
191-
} else {
192-
return fmt.Errorf("index add --overwrite-latest is only supported when using bundle images")
187+
overwriteImageMap[img.Bundle.Package][unpack.to] = unpack.from
188+
if _, ok := unpackedImageMap[unpack.to]; ok {
189+
delete(unpackedImageMap, unpack.to)
190+
}
191+
defer unpack.cleanup()
193192
}
194193
}
195194
}

‎pkg/lib/validation/bundle.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ func validateOwnedCRDs(bundle *registry.Bundle, csv *registry.ClusterServiceVers
5656
for _, ownedKey := range ownedKeys {
5757
if _, ok := keySet[*ownedKey]; !ok {
5858
result.Add(errors.ErrInvalidBundle(fmt.Sprintf("owned CRD %s not found in bundle %q", keyToString(*ownedKey), bundle.Name), *ownedKey))
59-
} else {
60-
delete(keySet, *ownedKey)
59+
continue
6160
}
61+
delete(keySet, *ownedKey)
6262
}
6363
// CRDs not defined in the CSV present in the bundle
6464
for key := range keySet {

‎pkg/registry/bundlegraphloader.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,10 @@ func (g *BundleGraphLoader) AddBundleToGraph(bundle *Bundle, graph *Package, ann
4242

4343
if graph.DefaultChannel == "" {
4444
// Infer default channel from channel list
45-
if annotations.SelectDefaultChannel() != "" {
46-
graph.DefaultChannel = annotations.SelectDefaultChannel()
47-
} else {
45+
if annotations.SelectDefaultChannel() == "" {
4846
return nil, fmt.Errorf("Default channel is missing and can't be inferred")
4947
}
48+
graph.DefaultChannel = annotations.SelectDefaultChannel()
5049
}
5150

5251
// generate the DAG for each channel the new bundle is being insert into

‎pkg/sqlite/query.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ func (s *SQLQuerier) GetApisForEntry(ctx context.Context, entryID int64) (provid
645645
kinds := map[string]struct{}{}
646646
versions := map[string]struct{}{}
647647

648-
providedQuery := `SELECT properties.value FROM properties
648+
providedQuery := `SELECT properties.value FROM properties
649649
INNER JOIN channel_entry ON channel_entry.operatorbundle_name = properties.operatorbundle_name
650650
WHERE properties.type=? AND channel_entry.entry_id=?`
651651

@@ -821,11 +821,10 @@ func (s *SQLQuerier) GetBundlePathsForPackage(ctx context.Context, pkgName strin
821821
if err := rows.Scan(&imgName); err != nil {
822822
return nil, err
823823
}
824-
if imgName.Valid && imgName.String != "" {
825-
images = append(images, imgName.String)
826-
} else {
824+
if imgName.Valid && imgName.String == "" {
827825
return nil, fmt.Errorf("Index malformed: cannot find paths to bundle images")
828826
}
827+
images = append(images, imgName.String)
829828
}
830829
return images, nil
831830
}
@@ -1173,7 +1172,7 @@ func (s *SQLQuerier) GetDependenciesForBundle(ctx context.Context, name, version
11731172
}
11741173

11751174
func (s *SQLQuerier) GetPropertiesForBundle(ctx context.Context, name, version, path string) (properties []*api.Property, err error) {
1176-
propQuery := `SELECT DISTINCT type, value FROM properties
1175+
propQuery := `SELECT DISTINCT type, value FROM properties
11771176
WHERE operatorbundle_name=?
11781177
AND (operatorbundle_version=? OR operatorbundle_version is NULL)
11791178
AND (operatorbundle_path=? OR operatorbundle_path is NULL)`

‎test/e2e/opm_test.go

-2
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,6 @@ var _ = Describe("opm", func() {
493493
})
494494

495495
Context("using podman", func() {
496-
//FIXME skip podman tests due to failed to add podman to systemd sandbox cgroup
497-
return
498496
if err := exec.Command("podman", "info").Run(); err != nil {
499497
GinkgoT().Log("container tool podman not found - skipping podman-based opm e2e tests: %s", err)
500498
return

‎vendor/k8s.io/apiserver/pkg/storage/names/generate.go

-54
This file was deleted.

‎vendor/modules.txt

-2
Original file line numberDiff line numberDiff line change
@@ -717,15 +717,13 @@ k8s.io/apimachinery/third_party/forked/golang/json
717717
k8s.io/apimachinery/third_party/forked/golang/netutil
718718
k8s.io/apimachinery/third_party/forked/golang/reflect
719719
# k8s.io/apiserver v0.20.0
720-
## explicit
721720
k8s.io/apiserver/pkg/apis/apiserver
722721
k8s.io/apiserver/pkg/apis/apiserver/install
723722
k8s.io/apiserver/pkg/apis/apiserver/v1
724723
k8s.io/apiserver/pkg/apis/apiserver/v1alpha1
725724
k8s.io/apiserver/pkg/apis/apiserver/v1beta1
726725
k8s.io/apiserver/pkg/server/egressselector
727726
k8s.io/apiserver/pkg/server/egressselector/metrics
728-
k8s.io/apiserver/pkg/storage/names
729727
k8s.io/apiserver/pkg/util/webhook
730728
# k8s.io/client-go v0.20.0
731729
## explicit

0 commit comments

Comments
 (0)
Please sign in to comment.