Skip to content

Commit eb1026a

Browse files
Merge pull request #326 from awgreene/disabled-copied-csv-console-bug
Support Global Operators in Console
2 parents a2b7b9a + c2ec825 commit eb1026a

File tree

12 files changed

+455
-169
lines changed

12 files changed

+455
-169
lines changed

Diff for: manifests/0000_50_olm_07-olm-operator.deployment.ibm-cloud-managed.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ spec:
5353
- /srv-cert/tls.key
5454
- --client-ca
5555
- /profile-collector-cert/tls.crt
56+
- --protectedCopiedCSVNamespaces
57+
- openshift
5658
image: quay.io/operator-framework/olm@sha256:de396b540b82219812061d0d753440d5655250c621c753ed1dc67d6154741607
5759
imagePullPolicy: IfNotPresent
5860
ports:

Diff for: manifests/0000_50_olm_07-olm-operator.deployment.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ spec:
5353
- /srv-cert/tls.key
5454
- --client-ca
5555
- /profile-collector-cert/tls.crt
56+
- --protectedCopiedCSVNamespaces
57+
- openshift
5658
image: quay.io/operator-framework/olm@sha256:de396b540b82219812061d0d753440d5655250c621c753ed1dc67d6154741607
5759
imagePullPolicy: IfNotPresent
5860
ports:

Diff for: manifests/0000_50_olm_15-csv-viewer.rbac.yaml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
annotations:
5+
rbac.authorization.kubernetes.io/autoupdate: "true"
6+
include.release.openshift.io/ibm-cloud-managed: "true"
7+
include.release.openshift.io/self-managed-high-availability: "true"
8+
name: copied-csv-viewer
9+
namespace: openshift
10+
rules:
11+
- apiGroups:
12+
- "operators.coreos.com"
13+
resources:
14+
- "clusterserviceversions"
15+
verbs:
16+
- get
17+
- list
18+
- watch
19+
---
20+
apiVersion: rbac.authorization.k8s.io/v1
21+
kind: RoleBinding
22+
metadata:
23+
annotations:
24+
rbac.authorization.kubernetes.io/autoupdate: "true"
25+
include.release.openshift.io/ibm-cloud-managed: "true"
26+
include.release.openshift.io/self-managed-high-availability: "true"
27+
name: copied-csv-viewers
28+
namespace: openshift
29+
roleRef:
30+
apiGroup: rbac.authorization.k8s.io
31+
kind: Role
32+
name: copied-csv-viewer
33+
subjects:
34+
- apiGroup: rbac.authorization.k8s.io
35+
kind: Group
36+
name: system:authenticated

Diff for: scripts/generate_crds_manifests.sh

+35
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,41 @@ metadata:
363363
release.openshift.io/delete: "true"
364364
EOF
365365

366+
cat << EOF > manifests/0000_50_olm_15-csv-viewer.rbac.yaml
367+
apiVersion: rbac.authorization.k8s.io/v1
368+
kind: Role
369+
metadata:
370+
annotations:
371+
rbac.authorization.kubernetes.io/autoupdate: "true"
372+
name: copied-csv-viewer
373+
namespace: openshift
374+
rules:
375+
- apiGroups:
376+
- "operators.coreos.com"
377+
resources:
378+
- "clusterserviceversions"
379+
verbs:
380+
- get
381+
- list
382+
- watch
383+
---
384+
apiVersion: rbac.authorization.k8s.io/v1
385+
kind: RoleBinding
386+
metadata:
387+
annotations:
388+
rbac.authorization.kubernetes.io/autoupdate: "true"
389+
name: copied-csv-viewers
390+
namespace: openshift
391+
roleRef:
392+
apiGroup: rbac.authorization.k8s.io
393+
kind: Role
394+
name: copied-csv-viewer
395+
subjects:
396+
- apiGroup: rbac.authorization.k8s.io
397+
kind: Group
398+
name: system:authenticated
399+
EOF
400+
366401
add_ibm_managed_cloud_annotations "${ROOT_DIR}/manifests"
367402

368403
find "${ROOT_DIR}/manifests" -type f -exec $SED -i "/^#/d" {} \;

Diff for: scripts/olm-deployment.patch.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
value:
1010
name: RELEASE_VERSION
1111
value: "0.0.1-snapshot"
12+
- command: update
13+
path: spec.template.spec.containers[0].args[+]
14+
value:
15+
--protectedCopiedCSVNamespaces
16+
- command: update
17+
path: spec.template.spec.containers[0].args[+]
18+
value:
19+
openshift
1220
- command: update
1321
path: spec.template.spec.containers[*].securityContext
1422
value:

Diff for: staging/operator-lifecycle-manager/cmd/olm/main.go

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ var (
6060
tlsKeyPath = pflag.String(
6161
"tls-key", "", "Path to use for private key (requires tls-cert)")
6262

63+
protectedCopiedCSVNamespaces = pflag.String("protectedCopiedCSVNamespaces",
64+
"", "A comma-delimited set of namespaces where global Copied CSVs will always appear, even if Copied CSVs are disabled")
65+
6366
tlsCertPath = pflag.String(
6467
"tls-cert", "", "Path to use for certificate key (requires tls-key)")
6568

@@ -162,6 +165,7 @@ func main() {
162165
olm.WithOperatorClient(opClient),
163166
olm.WithRestConfig(config),
164167
olm.WithConfigClient(versionedConfigClient),
168+
olm.WithProtectedCopiedCSVNamespaces(*protectedCopiedCSVNamespaces),
165169
)
166170
if err != nil {
167171
logger.WithError(err).Fatal("error configuring operator")

Diff for: staging/operator-lifecycle-manager/pkg/controller/operators/olm/config.go

+35-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package olm
22

33
import (
4+
"strings"
45
"time"
56

67
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/queueinformer"
@@ -21,18 +22,19 @@ import (
2122
type OperatorOption func(*operatorConfig)
2223

2324
type operatorConfig struct {
24-
resyncPeriod func() time.Duration
25-
operatorNamespace string
26-
watchedNamespaces []string
27-
clock utilclock.Clock
28-
logger *logrus.Logger
29-
operatorClient operatorclient.ClientInterface
30-
externalClient versioned.Interface
31-
strategyResolver install.StrategyResolverInterface
32-
apiReconciler APIIntersectionReconciler
33-
apiLabeler labeler.Labeler
34-
restConfig *rest.Config
35-
configClient configv1client.Interface
25+
protectedCopiedCSVNamespaces map[string]struct{}
26+
resyncPeriod func() time.Duration
27+
operatorNamespace string
28+
watchedNamespaces []string
29+
clock utilclock.Clock
30+
logger *logrus.Logger
31+
operatorClient operatorclient.ClientInterface
32+
externalClient versioned.Interface
33+
strategyResolver install.StrategyResolverInterface
34+
apiReconciler APIIntersectionReconciler
35+
apiLabeler labeler.Labeler
36+
restConfig *rest.Config
37+
configClient configv1client.Interface
3638
}
3739

3840
func (o *operatorConfig) apply(options []OperatorOption) {
@@ -77,14 +79,15 @@ func (o *operatorConfig) validate() (err error) {
7779

7880
func defaultOperatorConfig() *operatorConfig {
7981
return &operatorConfig{
80-
resyncPeriod: queueinformer.ResyncWithJitter(30*time.Second, 0.2),
81-
operatorNamespace: "default",
82-
watchedNamespaces: []string{metav1.NamespaceAll},
83-
clock: utilclock.RealClock{},
84-
logger: logrus.New(),
85-
strategyResolver: &install.StrategyResolver{},
86-
apiReconciler: APIIntersectionReconcileFunc(ReconcileAPIIntersection),
87-
apiLabeler: labeler.Func(LabelSetsFor),
82+
resyncPeriod: queueinformer.ResyncWithJitter(30*time.Second, 0.2),
83+
operatorNamespace: "default",
84+
watchedNamespaces: []string{metav1.NamespaceAll},
85+
clock: utilclock.RealClock{},
86+
logger: logrus.New(),
87+
strategyResolver: &install.StrategyResolver{},
88+
apiReconciler: APIIntersectionReconcileFunc(ReconcileAPIIntersection),
89+
apiLabeler: labeler.Func(LabelSetsFor),
90+
protectedCopiedCSVNamespaces: map[string]struct{}{},
8891
}
8992
}
9093

@@ -112,6 +115,18 @@ func WithLogger(logger *logrus.Logger) OperatorOption {
112115
}
113116
}
114117

118+
func WithProtectedCopiedCSVNamespaces(namespaces string) OperatorOption {
119+
return func(config *operatorConfig) {
120+
if namespaces == "" {
121+
return
122+
}
123+
124+
for _, ns := range strings.Split(namespaces, ",") {
125+
config.protectedCopiedCSVNamespaces[ns] = struct{}{}
126+
}
127+
}
128+
}
129+
115130
func WithClock(clock utilclock.Clock) OperatorOption {
116131
return func(config *operatorConfig) {
117132
config.clock = clock

0 commit comments

Comments
 (0)