Skip to content

Commit

Permalink
feat(operatorgroups): don't process CSVs that aren't in an operatorgroup
Browse files Browse the repository at this point in the history
this commit also moves the copying / rbac logic into the CSV loop, so
that we don't have to requeue operatorgroups frequently
  • Loading branch information
ecordell committed Dec 11, 2018
1 parent 8cdb2cc commit 85a6c8a
Show file tree
Hide file tree
Showing 24 changed files with 505 additions and 224 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ setup-bare:
. ./scripts/install_bare.sh $(shell cat ./e2e.namespace) test/e2e/resources

e2e:
go test -v -timeout 20m ./test/e2e/... -namespace=default -kubeconfig=${KUBECONFIG} -olmNamespace=openshift-operator-lifecycle-manager
go test -v -timeout 30m ./test/e2e/... -namespace=openshift-operators -kubeconfig=${KUBECONFIG} -olmNamespace=openshift-operator-lifecycle-manager

e2e-local:
. ./scripts/build_local.sh
Expand Down
12 changes: 7 additions & 5 deletions cmd/catalog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ func main() {
os.Exit(0)
}

if *debug {
log.SetLevel(log.DebugLevel)
}

// `namespaces` will always contain at least one entry: if `*watchedNamespaces` is
// the empty string, the resulting array will be `[]string{""}`.
namespaces := strings.Split(*watchedNamespaces, ",")
Expand All @@ -75,8 +71,14 @@ func main() {
})
go http.ListenAndServe(":8080", nil)

logger := log.New()
if *debug {
logger.SetLevel(log.DebugLevel)
}
logger.Infof("log level %s", logger.Level)

// Create a new instance of the operator.
catalogOperator, err := catalog.NewOperator(*kubeConfigPath, log.New(), *wakeupInterval, *catalogNamespace, namespaces...)
catalogOperator, err := catalog.NewOperator(*kubeConfigPath, logger, *wakeupInterval, *catalogNamespace, namespaces...)
if err != nil {
log.Panicf("error configuring operator: %s", err.Error())
}
Expand Down
11 changes: 6 additions & 5 deletions cmd/olm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ func main() {
os.Exit(0)
}

// Set log level to debug if `debug` flag set
if *debug {
log.SetLevel(log.DebugLevel)
}

// `namespaces` will always contain at least one entry: if `*watchedNamespaces` is
// the empty string, the resulting array will be `[]string{""}`.
namespaces := strings.Split(*watchedNamespaces, ",")
Expand All @@ -86,6 +81,12 @@ func main() {

logger := log.New()

// Set log level to debug if `debug` flag set
if *debug {
logger.SetLevel(log.DebugLevel)
}
logger.Infof("log level %s", logger.Level)

opClient := operatorclient.NewClientFromConfig(*kubeConfigPath, logger)

// Create a new instance of the operator.
Expand Down
1 change: 1 addition & 0 deletions deploy/chart/templates/0000_30_00-namespace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: {{ .Values.namespace }}
labels:
openshift.io/run-level: "1"
olm.components: "global"
---
apiVersion: v1
kind: Namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ spec:
- name: olm-operator
command:
- /bin/olm
args:
{{- if .Values.watchedNamespaces }}
- -watchedNamespaces
- {{ .Values.watchedNamespaces }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ spec:
- name: catalog-operator
command:
- /bin/catalog
args:
{{- if .Values.watchedNamespaces }}
- -watchedNamespaces
- {{ .Values.watchedNamespaces }}
Expand Down
12 changes: 11 additions & 1 deletion deploy/chart/templates/0000_30_16-operatorgroup-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,14 @@ apiVersion: operators.coreos.com/v1alpha2
kind: OperatorGroup
metadata:
name: global-operators
namespace: {{ .Values.operator_namespace }}
namespace: {{ .Values.operator_namespace }}
---
apiVersion: operators.coreos.com/v1alpha2
kind: OperatorGroup
metadata:
name: olm-operators
namespace: {{ .Values.namespace }}
spec:
selector:
matchLabels:
olm.components: "global"
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ require (
google.golang.org/grpc v1.16.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0-20170531160350-a96e63847dc3 // indirect
k8s.io/api v0.0.0-20180904230853-4e7be11eab3f
k8s.io/apiextensions-apiserver v0.0.0-20180905004947-16750353bf97
k8s.io/apimachinery v0.0.0-20181126123124-70adfbae261e
k8s.io/api v0.0.0-20181203235848-2dd39edadc55
k8s.io/apiextensions-apiserver v0.0.0-20181204003618-e419c5771cdc
k8s.io/apimachinery v0.0.0-20181203235515-3d8ee2261517
k8s.io/apiserver v0.0.0-20181026151315-13cfe3978170
k8s.io/client-go v8.0.0+incompatible
k8s.io/code-generator v0.0.0-20180904193909-8c97d6ab64da
k8s.io/code-generator v0.0.0-20181203235156-f8cba74510f3
k8s.io/gengo v0.0.0-20181106084056-51747d6e00da // indirect
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92 // indirect
k8s.io/kube-aggregator v0.0.0-20181201191901-6466d3c7f6e4
k8s.io/kube-aggregator v0.0.0-20181204002017-122bac39d429
k8s.io/kube-openapi v0.0.0-20181031203759-72693cb1fadd
k8s.io/kubernetes v1.11.6-beta.0.0.20181126160157-5933b9771b71
k8s.io/kubernetes v1.11.6-beta.0.0.20181207014600-4600add36de5
)
28 changes: 13 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -212,27 +212,25 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
k8s.io/api v0.0.0-20180904230853-4e7be11eab3f h1:DLRkv8Ps4Sdx8Srj+UtGisj4whV7v/HezlHx6QqiZqE=
k8s.io/api v0.0.0-20180904230853-4e7be11eab3f/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
k8s.io/apiextensions-apiserver v0.0.0-20180905004947-16750353bf97 h1:s4lWWs6JN5kWVzk5bztddkr5kgO/cGIbqTDP+QttUeQ=
k8s.io/apiextensions-apiserver v0.0.0-20180905004947-16750353bf97/go.mod h1:IxkesAMoaCRoLrPJdZNZUQp9NfZnzqaVzLhb2VEQzXE=
k8s.io/apimachinery v0.0.0-20181126123124-70adfbae261e h1:aoIs4wbKOxWFPPOoMSWC9V4b5+kp7c70tAD8LLByFQY=
k8s.io/apimachinery v0.0.0-20181126123124-70adfbae261e/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
k8s.io/api v0.0.0-20181203235848-2dd39edadc55 h1:FmAMYGd999iHkN+swot+oART9AumJiAvH0idpIZ3Ozo=
k8s.io/api v0.0.0-20181203235848-2dd39edadc55/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
k8s.io/apiextensions-apiserver v0.0.0-20181204003618-e419c5771cdc h1:IOukeE9HtTwpLslbujLDfRpfFU6tsjq28yO0fjnl/hk=
k8s.io/apiextensions-apiserver v0.0.0-20181204003618-e419c5771cdc/go.mod h1:IxkesAMoaCRoLrPJdZNZUQp9NfZnzqaVzLhb2VEQzXE=
k8s.io/apimachinery v0.0.0-20181203235515-3d8ee2261517 h1:p6GEgV1/cc7H0AT6XfjHwHNIypirOprIB09oKp2DQ/M=
k8s.io/apimachinery v0.0.0-20181203235515-3d8ee2261517/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
k8s.io/apiserver v0.0.0-20181026151315-13cfe3978170 h1:CqI85nZvPaV+7JFono0nAOGOx2brocqefcOhDPVhHKI=
k8s.io/apiserver v0.0.0-20181026151315-13cfe3978170/go.mod h1:6bqaTSOSJavUIXUtfaR9Os9JtTCm8ZqH2SUl2S60C4w=
k8s.io/client-go v8.0.0+incompatible h1:tTI4hRmb1DRMl4fG6Vclfdi6nTM82oIrTT7HfitmxC4=
k8s.io/client-go v8.0.0+incompatible h1:2pUaSg2x6iEHr8cia6zmWhoCXG1EDG9TCx9s//Aq7HY=
k8s.io/client-go v8.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
k8s.io/code-generator v0.0.0-20180904193909-8c97d6ab64da h1:L6YB6ObZIbZlYikTQcCjzZGilwS3OVyQBA2esULs8VM=
k8s.io/code-generator v0.0.0-20180904193909-8c97d6ab64da/go.mod h1:MYiN+ZJZ9HkETbgVZdWw2AsuAi9PZ4V80cwfuf2axe8=
k8s.io/code-generator v0.0.0-20181203235156-f8cba74510f3 h1:f/Aa24HPnPEDWia884BCF94E1b29KYjOTVTHcBzvT2Q=
k8s.io/code-generator v0.0.0-20181203235156-f8cba74510f3/go.mod h1:MYiN+ZJZ9HkETbgVZdWw2AsuAi9PZ4V80cwfuf2axe8=
k8s.io/gengo v0.0.0-20181106084056-51747d6e00da h1:ZMvcXtMVbhUCtCuiSEzBV+Eur4swzfdxx6ZyX3qT6dk=
k8s.io/gengo v0.0.0-20181106084056-51747d6e00da/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92 h1:PgoMI/L1Nu5Vmvgm+vGheLuxKST8h6FMOqggyAFtHPc=
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/kube-aggregator v0.0.0-20180905000155-efa32eb095fe h1:LM48rywzVEPRg+Os2oUL9/vsztPQGoxmiD3m5VySchw=
k8s.io/kube-aggregator v0.0.0-20180905000155-efa32eb095fe/go.mod h1:8sbzT4QQKDEmSCIbfqjV0sd97GpUT7A4W626sBiYJmU=
k8s.io/kube-aggregator v0.0.0-20181201191901-6466d3c7f6e4 h1:fPcE8vd9K1N42jDQEFOdf8phjgi6d+zeIb2Ya7qNFuM=
k8s.io/kube-aggregator v0.0.0-20181201191901-6466d3c7f6e4/go.mod h1:8sbzT4QQKDEmSCIbfqjV0sd97GpUT7A4W626sBiYJmU=
k8s.io/kube-aggregator v0.0.0-20181204002017-122bac39d429 h1:wIDPKpRuwEfyt+ImBaP6wSEZeAR5gYJl/Mlg74L0hHI=
k8s.io/kube-aggregator v0.0.0-20181204002017-122bac39d429/go.mod h1:8sbzT4QQKDEmSCIbfqjV0sd97GpUT7A4W626sBiYJmU=
k8s.io/kube-openapi v0.0.0-20181031203759-72693cb1fadd h1:ggv/Vfza0i5xuhUZyYyxcc25AmQvHY8Zi1C2m8WgBvA=
k8s.io/kube-openapi v0.0.0-20181031203759-72693cb1fadd/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc=
k8s.io/kubernetes v1.11.6-beta.0.0.20181126160157-5933b9771b71 h1:ZiDzUVY+KNDO1sbcG0hHZokQsNIhjCCCsy06Z4Ck4JA=
k8s.io/kubernetes v1.11.6-beta.0.0.20181126160157-5933b9771b71/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
k8s.io/kubernetes v1.11.6-beta.0.0.20181207014600-4600add36de5 h1:+oToqFCSumcTuKDfnGBfGDTufqPJK3JmI0+ItcYB2tg=
k8s.io/kubernetes v1.11.6-beta.0.0.20181207014600-4600add36de5/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
8 changes: 7 additions & 1 deletion manifests/0000_30_16-operatorgroup-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ apiVersion: operators.coreos.com/v1alpha2
kind: OperatorGroup
metadata:
name: global-operators
namespace: openshift-operators
namespace: openshift-operators
---
apiVersion: operators.coreos.com/v1alpha2
kind: OperatorGroup
metadata:
name: olm-operators
namespace: openshift-operator-lifecycle-manager
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ const (
CSVPhaseReplacing ClusterServiceVersionPhase = "Replacing"
// CSVPhaseDeleting means that a CSV has been replaced by a new one and will be checked for safety before being deleted
CSVPhaseDeleting ClusterServiceVersionPhase = "Deleting"
// CSVPhaseAny matches all other phases in CSV queries
CSVPhaseAny ClusterServiceVersionPhase = ""
)

// ConditionReason is a camelcased reason for the state transition
Expand Down
20 changes: 8 additions & 12 deletions pkg/controller/install/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ import (
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/ownerutil"
)

var (
Controller = false
BlockOwnerDeletion = false
)

func testDeployment(name, namespace string, mockOwner ownerutil.Owner) appsv1.Deployment {
testDeploymentLabels := map[string]string{"olm.owner": mockOwner.GetName(), "olm.owner.namespace": mockOwner.GetNamespace()}

Expand All @@ -34,8 +29,8 @@ func testDeployment(name, namespace string, mockOwner ownerutil.Owner) appsv1.De
Kind: v1alpha1.ClusterServiceVersionKind,
Name: mockOwner.GetName(),
UID: mockOwner.GetUID(),
Controller: &Controller,
BlockOwnerDeletion: &BlockOwnerDeletion,
Controller: &ownerutil.NotController,
BlockOwnerDeletion: &ownerutil.DontBlockOwnerDeletion,
},
},
Labels: testDeploymentLabels,
Expand All @@ -53,8 +48,8 @@ func testServiceAccount(name string, mockOwner ownerutil.Owner) *corev1.ServiceA
Kind: v1alpha1.ClusterServiceVersionKind,
Name: mockOwner.GetName(),
UID: mockOwner.GetUID(),
Controller: &Controller,
BlockOwnerDeletion: &BlockOwnerDeletion,
Controller: &ownerutil.NotController,
BlockOwnerDeletion: &ownerutil.DontBlockOwnerDeletion,
},
})
return serviceAccount
Expand Down Expand Up @@ -102,8 +97,8 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
Kind: v1alpha1.ClusterServiceVersionKind,
Name: mockOwner.GetName(),
UID: mockOwner.UID,
Controller: &Controller,
BlockOwnerDeletion: &BlockOwnerDeletion,
Controller: &ownerutil.NotController,
BlockOwnerDeletion: &ownerutil.DontBlockOwnerDeletion,
}}
)

Expand Down Expand Up @@ -236,7 +231,8 @@ func TestInstallStrategyDeploymentInstallDeployments(t *testing.T) {
fakeClient.CreateDeploymentReturns(nil, m.returnError)
defer func(i int, expectedDeployment appsv1.Deployment) {
dep := fakeClient.CreateOrUpdateDeploymentArgsForCall(i)
assert.Equal(t, expectedDeployment, *dep)
expectedDeployment.Spec.Template.Annotations = map[string]string{}
require.Equal(t, expectedDeployment.OwnerReferences, dep.OwnerReferences)
}(i, m.expectedDeployment)
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/operators/catalog/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"testing"
"time"

"github.com/sirupsen/logrus"

"github.com/ghodss/yaml"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
Expand Down
Loading

0 comments on commit 85a6c8a

Please sign in to comment.