Skip to content

Commit 063ef26

Browse files
ecordellnjhale
authored andcommitted
feat(catalogsource): allow grpc source types that don't require an image
instead, they provide an address directly. OLM will not have visibility into the resources required for running the grpc catalog for this case, but will still connect and health check.
1 parent f7fcf65 commit 063ef26

File tree

19 files changed

+448
-135
lines changed

19 files changed

+448
-135
lines changed

cmd/catalog/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,3 @@ func main() {
9999
_, done := catalogOperator.Run(stopCh)
100100
<-done
101101
}
102-

deploy/chart/templates/0000_50_olm_05-catalogsource.crd.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ spec:
6262
type: string
6363
description: The name of a ConfigMap that holds the entries for an in-memory catalog.
6464

65+
address:
66+
type: string
67+
description: An optional address. When set, directs OLM to connect to use a pre-existing registry server at this address.
68+
6569
image:
6670
type: string
67-
description: An image that serves a grpc registry. Only valid for `grpc` sourceType.
71+
description: An image that serves a grpc registry. Only valid for `grpc` sourceType. If both image and address are set, OLM does not use the address field.
6872

6973
displayName:
7074
type: string

deploy/ocp/manifests/0.8.1/0000_50_olm_05-catalogsource.crd.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ spec:
6464
type: string
6565
description: The name of a ConfigMap that holds the entries for an in-memory catalog.
6666

67+
address:
68+
type: string
69+
description: An optional address. When set, directs OLM to connect to use a pre-existing registry server at this address.
70+
6771
image:
6872
type: string
69-
description: An image that serves a grpc registry. Only valid for `grpc` sourceType.
73+
description: An image that serves a grpc registry. Only valid for `grpc` sourceType. If both image and address are set, OLM does not use the address field.
7074

7175
displayName:
7276
type: string

deploy/okd/manifests/0.8.1/0000_50_olm_05-catalogsource.crd.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ spec:
6464
type: string
6565
description: The name of a ConfigMap that holds the entries for an in-memory catalog.
6666

67+
address:
68+
type: string
69+
description: An optional address. When set, directs OLM to connect to use a pre-existing registry server at this address.
70+
6771
image:
6872
type: string
69-
description: An image that serves a grpc registry. Only valid for `grpc` sourceType.
73+
description: An image that serves a grpc registry. Only valid for `grpc` sourceType. If both image and address are set, OLM does not use the address field.
7074

7175
displayName:
7276
type: string

deploy/upstream/manifests/0.8.1/0000_50_olm_05-catalogsource.crd.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ spec:
6464
type: string
6565
description: The name of a ConfigMap that holds the entries for an in-memory catalog.
6666

67+
address:
68+
type: string
69+
description: An optional address. When set, directs OLM to connect to use a pre-existing registry server at this address.
70+
6771
image:
6872
type: string
69-
description: An image that serves a grpc registry. Only valid for `grpc` sourceType.
73+
description: An image that serves a grpc registry. Only valid for `grpc` sourceType. If both image and address are set, OLM does not use the address field.
7074

7175
displayName:
7276
type: string

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ require (
4141
k8s.io/klog v0.2.0 // indirect
4242
k8s.io/kube-aggregator v0.0.0-20181204002017-122bac39d429
4343
k8s.io/kube-openapi v0.0.0-20181031203759-72693cb1fadd
44-
k8s.io/kubernetes v1.11.8-beta.0.0.20190208223919-e6f6fa1f2dd1
44+
k8s.io/kubernetes v1.11.8-beta.0.0.20190214232326-4e0b35876724
4545
)

go.sum

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ github.com/coreos/bbolt v1.3.2 h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s=
2222
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
2323
github.com/coreos/etcd v3.3.9+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
2424
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
25-
github.com/coreos/etcd v3.3.11+incompatible h1:0gCnqKsq7XxMi69JsnbmMc1o+RJH3XH64sV9aiTTYko=
25+
github.com/coreos/etcd v3.3.11+incompatible h1:U0wJghY374q+UrjOM2mfROHSwEspsQVkCACB1PGka1g=
2626
github.com/coreos/etcd v3.3.11+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
2727
github.com/coreos/go-semver v0.2.0 h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY=
2828
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
@@ -112,7 +112,7 @@ github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoA
112112
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
113113
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f h1:ShTPMJQes6tubcjzGMODIVG5hlrCeImaBnZzKF2N8SM=
114114
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
115-
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:Iju5GlWwrvL6UBg4zJJt3btmonfrMlCDdsejg4CZE7c=
115+
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:BWIsLfhgKhV5g/oF34aRjniBHLTZe5DNekSjbAjIS6c=
116116
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
117117
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
118118
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
@@ -297,6 +297,7 @@ k8s.io/apimachinery v0.0.0-20181203235515-3d8ee2261517/go.mod h1:ccL7Eh7zubPUSh9
297297
k8s.io/apimachinery v0.0.0-20190118094746-1525e4dadd2d/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
298298
k8s.io/apimachinery v0.0.0-20190208202428-1a579f8a7b42 h1:ju2lLx7i6XE8A9QLtwxlQngelP8SosMIjK4IYE/TLFI=
299299
k8s.io/apimachinery v0.0.0-20190208202428-1a579f8a7b42/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
300+
k8s.io/apimachinery v0.0.0-20190213190008-5eb658cbe970 h1:alS6VCwjuZxqOAhOnpSY/TbMvwVRAOWSTeE63v5Iz+M=
300301
k8s.io/apiserver v0.0.0-20181026151315-13cfe3978170 h1:CqI85nZvPaV+7JFono0nAOGOx2brocqefcOhDPVhHKI=
301302
k8s.io/apiserver v0.0.0-20181026151315-13cfe3978170/go.mod h1:6bqaTSOSJavUIXUtfaR9Os9JtTCm8ZqH2SUl2S60C4w=
302303
k8s.io/client-go v0.0.0-20180718001006-59698c7d9724/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
@@ -318,5 +319,5 @@ k8s.io/kube-openapi v0.0.0-20181031203759-72693cb1fadd h1:ggv/Vfza0i5xuhUZyYyxcc
318319
k8s.io/kube-openapi v0.0.0-20181031203759-72693cb1fadd/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc=
319320
k8s.io/kubernetes v1.11.7-beta.0.0.20181219023948-b875d52ea96d/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
320321
k8s.io/kubernetes v1.11.8-beta.0.0.20190124204751-3a10094374f2/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
321-
k8s.io/kubernetes v1.11.8-beta.0.0.20190208223919-e6f6fa1f2dd1 h1:KXhECItYGlIqgwjGvb46A8eZ4qB3WgTmunAcEecVsE8=
322-
k8s.io/kubernetes v1.11.8-beta.0.0.20190208223919-e6f6fa1f2dd1/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
322+
k8s.io/kubernetes v1.11.8-beta.0.0.20190214232326-4e0b35876724 h1:THwYErr8LUBf1Je2gh9lzarMPzLxN6SsdtuiLLZMtoQ=
323+
k8s.io/kubernetes v1.11.8-beta.0.0.20190214232326-4e0b35876724/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=

manifests/0000_50_olm_05-catalogsource.crd.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ spec:
6262
type: string
6363
description: The name of a ConfigMap that holds the entries for an in-memory catalog.
6464

65+
address:
66+
type: string
67+
description: An optional address. When set, directs OLM to connect to use a pre-existing registry server at this address.
68+
6569
image:
6670
type: string
67-
description: An image that serves a grpc registry. Only valid for `grpc` sourceType.
71+
description: An image that serves a grpc registry. Only valid for `grpc` sourceType. If both image and address are set, OLM does not use the address field.
6872

6973
displayName:
7074
type: string

pkg/api/apis/operators/v1alpha1/catalogsource_types.go

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,43 @@ const (
1818
type SourceType string
1919

2020
const (
21-
SourceTypeInternal SourceType = "internal"
21+
// SourceTypeInternal (deprecated) specifies a CatalogSource of type SourceTypeConfigmap
22+
SourceTypeInternal SourceType = "internal"
23+
24+
// SourceTypeConfigmap specifies a CatalogSource that generates a configmap-server registry
2225
SourceTypeConfigmap SourceType = "configmap"
23-
SourceTypeGrpc SourceType = "grpc"
26+
27+
// SourceTypeGrpc specifies a CatalogSource that can use an operator registry image to generate a
28+
// registry-server or connect to a pre-existing registry at an address.
29+
SourceTypeGrpc SourceType = "grpc"
2430
)
2531

2632
type CatalogSourceSpec struct {
33+
// SourceType is the type of source
2734
SourceType SourceType `json:"sourceType"`
28-
ConfigMap string `json:"configMap,omitempty"`
29-
Image string `json:"image,omitempty"`
30-
Secrets []string `json:"secrets,omitempty"`
35+
36+
// ConfigMap is the name of the ConfigMap to be used to back a configmap-server registry.
37+
// Only used when SourceType = SourceTypeConfigmap or SourceTypeInternal.
38+
// +Optional
39+
ConfigMap string `json:"configMap,omitempty"`
40+
41+
// Address is a host that OLM can use to connect to a pre-existing registry.
42+
// Format: <registry-host or ip>:<port>
43+
// Only used when SourceType = SourceTypeGrpc.
44+
// Ignored when the Image field is set.
45+
// +Optional
46+
Address string `json:"address,omitempty"`
47+
48+
// Image is an operator-registry container image to instantiate a registry-server with.
49+
// Only used when SourceType = SourceTypeGrpc.
50+
// If present, the address field is ignored.
51+
// +Optional
52+
Image string `json:"image,omitempty"`
53+
54+
// Secrets represent set of secrets that can be used to access the contents of the catalog.
55+
// It is best to keep this list small, since each will need to be tried for every catalog entry.
56+
// +Optional
57+
Secrets []string `json:"secrets,omitempty"`
3158

3259
// Metadata
3360
DisplayName string `json:"displayName,omitempty"`
@@ -53,6 +80,7 @@ type CatalogSourceStatus struct {
5380
RegistryServiceStatus *RegistryServiceStatus `json:"registryService,omitempty"`
5481
LastSync metav1.Time `json:"lastSync,omitempty"`
5582
}
83+
5684
type ConfigMapResourceReference struct {
5785
Name string `json:"name"`
5886
Namespace string `json:"namespace"`
@@ -71,6 +99,13 @@ type CatalogSource struct {
7199
Status CatalogSourceStatus `json:"status"`
72100
}
73101

102+
func (c *CatalogSource) Address() string {
103+
if c.Spec.Address != "" {
104+
return c.Spec.Address
105+
}
106+
return c.Status.RegistryServiceStatus.Address()
107+
}
108+
74109
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
75110
type CatalogSourceList struct {
76111
metav1.TypeMeta `json:",inline"`

pkg/controller/operators/catalog/operator.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func NewOperator(kubeconfigPath string, logger *logrus.Logger, wakeupInterval ti
7777
watchedNamespaces = []string{metav1.NamespaceAll}
7878
}
7979

80-
// Create a new client for ALM types (CRs)
80+
// Create a new client for OLM types (CRs)
8181
crClient, err := client.NewClient(kubeconfigPath)
8282
if err != nil {
8383
return nil, err
@@ -381,24 +381,26 @@ func (o *Operator) syncCatalogSources(obj interface{}) (syncError error) {
381381

382382
return nil
383383
}
384+
385+
logger.Debug("catsrc configmap state good, checking registry pod")
384386
}
385387

386-
reconciler := o.reconciler.ReconcilerForSourceType(catsrc.Spec.SourceType)
388+
reconciler := o.reconciler.ReconcilerForSource(catsrc)
387389
if reconciler == nil {
390+
// TODO: Add failure status on catalogsource and remove from sources
388391
return fmt.Errorf("no reconciler for source type %s", catsrc.Spec.SourceType)
389392
}
390393

391-
logger.Debug("catsrc configmap state good, checking registry pod")
392394

393395
// if registry pod hasn't been created or hasn't been updated since the last configmap update, recreate it
394396
if catsrc.Status.RegistryServiceStatus == nil || catsrc.Status.RegistryServiceStatus.CreatedAt.Before(&catsrc.Status.LastSync) {
395-
logger.Debug("registry pod scheduled for recheck")
397+
logger.Debug("registry server scheduled recheck")
396398

397399
if err := reconciler.EnsureRegistryServer(out); err != nil {
398400
logger.WithError(err).Warn("couldn't ensure registry server")
399401
return err
400402
}
401-
logger.Debug("ensured registry pod")
403+
logger.Debug("ensured registry server")
402404

403405
out.Status.RegistryServiceStatus.CreatedAt = timeNow()
404406
out.Status.LastSync = timeNow()
@@ -410,18 +412,18 @@ func (o *Operator) syncCatalogSources(obj interface{}) (syncError error) {
410412
}
411413

412414
o.sourcesLastUpdate = timeNow()
413-
logger.Debug("registry pod recreated")
415+
logger.Debug("registry server recreated")
414416

415417
return nil
416418
}
417-
logger.Debug("registry pod state good")
419+
logger.Debug("registry state good")
418420

419421
// update operator's view of sources
420422
sourcesUpdated := false
421423
func() {
422424
o.sourcesLock.Lock()
423425
defer o.sourcesLock.Unlock()
424-
address := catsrc.Status.RegistryServiceStatus.Address()
426+
address := catsrc.Address()
425427
currentSource, ok := o.sources[sourceKey]
426428
logger = logger.WithField("currentSource", sourceKey)
427429
if !ok || currentSource.Address != address || catsrc.Status.LastSync.After(currentSource.LastConnect.Time) {
@@ -664,7 +666,7 @@ func (o *Operator) ensureResolverSources(logger *logrus.Entry, namespace string)
664666
logger.WithField("clientState", client.Conn.GetState()).Debug("source")
665667
if client.Conn.GetState() == connectivity.TransientFailure {
666668
logger.WithField("clientState", client.Conn.GetState()).Debug("waiting for connection")
667-
ctx, _ := context.WithTimeout(context.TODO(), 5*time.Second)
669+
ctx, _ := context.WithTimeout(context.TODO(), 2*time.Second)
668670
changed := client.Conn.WaitForStateChange(ctx, connectivity.TransientFailure)
669671
if !changed {
670672
logger.WithField("clientState", client.Conn.GetState()).Debug("source in transient failure and didn't recover")

0 commit comments

Comments
 (0)