Skip to content

Commit 5a4031b

Browse files
authored
Merge pull request #638 from ecordell/new-resolver
feat(resolver): take all subscriptions into account when resolving
2 parents 75e95a0 + 431a700 commit 5a4031b

File tree

246 files changed

+19344
-11114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+19344
-11114
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Dependency Resolution and Upgrades
2+
3+
OLM manages the dependency resolution and upgrade lifecycle of running operators. In many ways, thes problems OLM faces are similar to other OS pacakge managers like `apt`/`dkpg` and `yum`/`rpm`.
4+
5+
However, there is one constraint that similar systems don't generally have that OLM does: because operators are always running, OLM attempts to ensure that at no point in time are you left with a set of operators that do not work with each other.
6+
7+
This means that OLM needs to never:
8+
9+
- install a set of operators that require APIs that can't be provided
10+
- update an operator in a way that breaks another that depends upon it
11+
12+
The following examples motivate why OLM's dependency resolution and upgrade strategy works as it does, followed by a description of the current algorithm.
13+
14+
# Example: Deprecate dependant API
15+
16+
A and B are APIs (e.g. CRDs)
17+
18+
* A's provider depends on B
19+
* B’s provider has a Subscription
20+
* B’s provider updates to provide C but deprecates B
21+
22+
This results in:
23+
24+
* B no longer has a provider
25+
* A no longer works
26+
27+
This is a case we prevent with OLM's upgrade strategy.
28+
29+
30+
# Example: Version deadlock
31+
32+
A and B are APIs
33+
34+
* A's provider requires B
35+
* B's provider requires A
36+
* A's provider updates to (provide A2, require B2) and deprecate A
37+
* B's provider updates to (provide B2, require A2) and deprecate B
38+
39+
If we attempt to update A without simultaneously updating B, or vice-versa, we won't be able to progress to new versions of the operators, even though a new compatible set can be found.
40+
41+
This is another case we prevent with OLM's upgrade strategy.
42+
43+
44+
# Dependency resolution
45+
46+
A Provider is an operator which "Owns" a CRD or APIService.
47+
48+
This algorithm will result in a successful update of a generation (in which as many operators which can be updated have been):
49+
50+
```
51+
Consider the set of operators defined by running operators in a namespace:
52+
53+
For each subscription in the namespace:
54+
if the subscription hasn't been checked before, find the latest CSV in the source/package/channel
55+
provisionally add the operator to the generation
56+
else
57+
check for a replacement in the source/package/channel
58+
59+
// Generation resolution
60+
For each required API with no provider in gen:
61+
search through prioritized sources to pick a provider
62+
provisionally add any new operators found to the generation, this could also add to the required APIs without providers
63+
64+
// Downgrade
65+
if there are still required APIs that can't be satisfied by sources:
66+
downgrade the operator(s) that require the APIs that can't be satisfied
67+
68+
// Apply
69+
for each new operator required, install it into the cluster. Any newly resolved operator will be given a subscription to the channel/package/source it was discovered in.
70+
```
71+
72+
The operator expansion loop is bounded by the total number of provided apis across sources (because a generation may not have multiple providers)
73+
74+
The downgrade loop will eventually stop, though it may contract back down to the original generation in the namespace. Downgrading an operator means it was in the previous generation. By definition, either its required apis are satisfied, or will be satisfied by the downgrade of another operator.

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ setup-bare: clean e2e.namespace
7979
. ./scripts/install_bare.sh $(shell cat ./e2e.namespace) test/e2e/resources
8080

8181
e2e:
82-
go test -v -timeout 30m ./test/e2e/... -namespace=openshift-operators -kubeconfig=${KUBECONFIG} -olmNamespace=openshift-operator-lifecycle-manager
82+
go test -v -timeout 50m ./test/e2e/... -namespace=openshift-operators -kubeconfig=${KUBECONFIG} -olmNamespace=openshift-operator-lifecycle-manager
8383

8484
e2e-local:
8585
. ./scripts/build_local.sh
@@ -108,6 +108,11 @@ vendor: $(KUBE_DEPS)
108108
container:
109109
docker build -t $(IMAGE_REPO):$(IMAGE_TAG) .
110110

111+
clean-e2e:
112+
kubectl delete crds --all
113+
kubectl delete apiservices.apiregistration.k8s.io v1alpha1.packages.apps.redhat.com
114+
kubectl delete -f test/e2e/resources/0000_30_00-namespace.yaml
115+
111116
clean:
112117
@rm -rf cover.out
113118
@rm -rf bin
@@ -156,7 +161,6 @@ verify-codegen: codegen
156161
git diff --exit-code
157162

158163
verify-catalog: schema-check
159-
go test $(MOD_FLAGS) -v ./test/schema/catalog_versions_test.go
160164

161165
generate-mock-client:
162166
$(MOCKGEN)

deploy/chart/templates/0000_30_00-namespace.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ metadata:
44
name: {{ .Values.namespace }}
55
labels:
66
openshift.io/run-level: "1"
7-
olm.components: "global"
87
---
98
apiVersion: v1
109
kind: Namespace

deploy/chart/templates/0000_30_13-operatorgroup.crd.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ spec:
6666
pattern: ^\S+$
6767
serviceAccountName:
6868
type: string
69-
required:
70-
- selector
7169
type: object
7270
status:
7371
properties:

deploy/chart/templates/0000_30_16-operatorgroup-default.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ metadata:
1010
name: olm-operators
1111
namespace: {{ .Values.namespace }}
1212
spec:
13-
selector:
14-
matchLabels:
15-
olm.components: "global"
13+
targetNamespaces:
14+
- {{ .Values.namespace }}

go.mod

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,56 @@
11
module github.com/operator-framework/operator-lifecycle-manager
22

33
require (
4-
bitbucket.org/ww/goautoneg v0.0.0-20120707110453-75cd24fc2f2c // indirect
5-
github.com/BurntSushi/toml v0.3.1 // indirect
6-
github.com/NYTimes/gziphandler v1.0.1 // indirect
7-
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect
8-
github.com/boltdb/bolt v1.3.1 // indirect
9-
github.com/coreos/bbolt v1.3.0 // indirect
10-
github.com/coreos/etcd v3.3.9+incompatible // indirect
4+
github.com/coreos/etcd v3.3.10+incompatible // indirect
115
github.com/coreos/go-semver v0.2.0
12-
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7 // indirect
13-
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
14-
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
15-
github.com/docker/distribution v2.6.2+incompatible // indirect
16-
github.com/elazarl/go-bindata-assetfs v1.0.0 // indirect
17-
github.com/emicklei/go-restful v2.8.0+incompatible // indirect
18-
github.com/emicklei/go-restful-swagger12 v0.0.0-20170926063155-7524189396c6 // indirect
19-
github.com/evanphx/json-patch v3.0.0+incompatible // indirect
6+
github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 // indirect
7+
github.com/docker/distribution v2.7.0+incompatible // indirect
8+
github.com/evanphx/json-patch v4.1.0+incompatible // indirect
209
github.com/ghodss/yaml v1.0.0
2110
github.com/go-openapi/spec v0.17.2
22-
github.com/go-openapi/strfmt v0.17.2 // indirect
23-
github.com/go-openapi/validate v0.17.2 // indirect
11+
github.com/go-openapi/strfmt v0.18.0 // indirect
12+
github.com/go-openapi/validate v0.18.0 // indirect
2413
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
25-
github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff // indirect
2614
github.com/golang/mock v1.1.1
27-
github.com/gorilla/websocket v1.4.0 // indirect
28-
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
29-
github.com/grpc-ecosystem/grpc-gateway v1.5.1 // indirect
30-
github.com/hashicorp/golang-lru v0.5.0 // indirect
31-
github.com/jonboulle/clockwork v0.1.0 // indirect
32-
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
15+
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect
16+
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect
17+
github.com/googleapis/gnostic v0.2.0 // indirect
18+
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 // indirect
19+
github.com/grpc-ecosystem/grpc-gateway v1.6.3 // indirect
20+
github.com/imdario/mergo v0.3.6 // indirect
21+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
22+
github.com/json-iterator/go v1.1.5 // indirect
3323
github.com/maxbrunsfeld/counterfeiter v0.0.0-20181017030959-1aadac120687
34-
github.com/modern-go/reflect2 v1.0.1 // indirect
35-
github.com/operator-framework/operator-registry v1.0.1
24+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
25+
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
26+
github.com/operator-framework/operator-registry v1.0.3
27+
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
3628
github.com/pkg/errors v0.8.0
37-
github.com/prometheus/client_golang v0.8.0
38-
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 // indirect
39-
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e // indirect
40-
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273 // indirect
41-
github.com/sirupsen/logrus v1.1.1
42-
github.com/soheilhy/cmux v0.1.4 // indirect
29+
github.com/prometheus/client_golang v0.9.1
30+
github.com/prometheus/common v0.0.0-20190104105734-b1c43a6df3ae // indirect
31+
github.com/prometheus/procfs v0.0.0-20190104112138-b1a0a9a36d74 // indirect
32+
github.com/sirupsen/logrus v1.2.0
4333
github.com/spf13/cobra v0.0.3
44-
github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50 // indirect
34+
github.com/spf13/pflag v1.0.3 // indirect
4535
github.com/stretchr/testify v1.2.2
46-
github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6 // indirect
47-
github.com/ugorji/go v1.1.1 // indirect
48-
github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 // indirect
49-
golang.org/x/oauth2 v0.0.0-20181105165119-ca4130e427c7 // indirect
50-
golang.org/x/tools v0.0.0-20181207222222-4c874b978acb // indirect
51-
gopkg.in/natefinch/lumberjack.v2 v2.0.0-20170531160350-a96e63847dc3 // indirect
36+
github.com/ugorji/go/codec v0.0.0-20181209151446-772ced7fd4c2 // indirect
37+
go.uber.org/atomic v1.3.2 // indirect
38+
go.uber.org/multierr v1.1.0 // indirect
39+
go.uber.org/zap v1.9.1 // indirect
40+
golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e // indirect
41+
google.golang.org/genproto v0.0.0-20181016170114-94acd270e44e // indirect
42+
google.golang.org/grpc v1.16.0
43+
gopkg.in/inf.v0 v0.9.1 // indirect
44+
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
5245
k8s.io/api v0.0.0-20181203235848-2dd39edadc55
5346
k8s.io/apiextensions-apiserver v0.0.0-20181204003618-e419c5771cdc
5447
k8s.io/apimachinery v0.0.0-20181203235515-3d8ee2261517
5548
k8s.io/apiserver v0.0.0-20181026151315-13cfe3978170
5649
k8s.io/client-go v8.0.0+incompatible
5750
k8s.io/code-generator v0.0.0-20181203235156-f8cba74510f3
58-
k8s.io/gengo v0.0.0-20181106084056-51747d6e00da // indirect
59-
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92 // indirect
51+
k8s.io/gengo v0.0.0-20181113154421-fd15ee9cc2f7 // indirect
52+
k8s.io/klog v0.1.0 // indirect
6053
k8s.io/kube-aggregator v0.0.0-20181204002017-122bac39d429
6154
k8s.io/kube-openapi v0.0.0-20181031203759-72693cb1fadd
62-
k8s.io/kubernetes v1.11.7-beta.0.0.20181219023948-b875d52ea96d
55+
k8s.io/kubernetes v1.11.7-beta.0.0.20190105100524-8bc0774147c7
6356
)

0 commit comments

Comments
 (0)