Skip to content

Commit

Permalink
test(registry): add checks for registry pods
Browse files Browse the repository at this point in the history
  • Loading branch information
ecordell committed Dec 12, 2018
1 parent 34313e4 commit 67dbf8f
Show file tree
Hide file tree
Showing 24 changed files with 2,193 additions and 135 deletions.
16 changes: 2 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,18 @@ require (
github.com/go-openapi/spec v0.17.2
github.com/go-openapi/strfmt v0.17.2 // indirect
github.com/go-openapi/validate v0.17.2 // indirect
github.com/gogo/protobuf v1.1.1 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff // indirect
github.com/golang/mock v1.1.1
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect
github.com/googleapis/gnostic v0.2.0 // indirect
github.com/gorilla/websocket v1.4.0 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.5.1 // indirect
github.com/hashicorp/golang-lru v0.5.0 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jonboulle/clockwork v0.1.0 // indirect
github.com/json-iterator/go v1.1.5 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/maxbrunsfeld/counterfeiter v0.0.0-20181017030959-1aadac120687
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/operator-framework/operator-registry v1.0.1
github.com/pkg/errors v0.8.0
github.com/prometheus/client_golang v0.8.0
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 // indirect
Expand All @@ -51,21 +41,19 @@ require (
github.com/sirupsen/logrus v1.1.1
github.com/soheilhy/cmux v0.1.4 // indirect
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3 // indirect
github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50 // indirect
github.com/stretchr/testify v1.2.2
github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6 // indirect
github.com/ugorji/go v1.1.1 // indirect
github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 // indirect
golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e // indirect
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519 // indirect
golang.org/x/oauth2 v0.0.0-20181105165119-ca4130e427c7 // indirect
golang.org/x/sys v0.0.0-20181023152157-44b849a8bc13 // indirect
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect
golang.org/x/tools v0.0.0-20181207222222-4c874b978acb // indirect
google.golang.org/genproto v0.0.0-20181016170114-94acd270e44e // indirect
google.golang.org/grpc v1.16.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
google.golang.org/grpc v1.16.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0-20170531160350-a96e63847dc3 // indirect
k8s.io/api v0.0.0-20181203235848-2dd39edadc55
k8s.io/apiextensions-apiserver v0.0.0-20181204003618-e419c5771cdc
Expand Down
48 changes: 17 additions & 31 deletions go.sum

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion pkg/api/apis/operators/v1alpha1/catalogsource_types.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package v1alpha1

import (
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators"
"fmt"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators"
)

const (
Expand Down Expand Up @@ -39,6 +42,10 @@ type RegistryServiceStatus struct {
CreatedAt metav1.Time `json:"createdAt,omitempty"`
}

func (s *RegistryServiceStatus) Address() string {
return fmt.Sprintf("%s.%s.svc.cluster.local:%s", s.ServiceName, s.ServiceNamespace, s.Port)
}

type CatalogSourceStatus struct {
ConfigMapResource *ConfigMapResourceReference `json:"configMapReference,omitempty"`
RegistryServiceStatus *RegistryServiceStatus `json:"registryService,omitempty"`
Expand Down
31 changes: 16 additions & 15 deletions pkg/controller/operators/catalog/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ import (
"time"

"github.com/sirupsen/logrus"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorlister"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/informers"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
v1beta1ext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/informers"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"

"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorlister"

"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1"
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client"
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
Expand Down Expand Up @@ -182,12 +183,12 @@ func NewOperator(kubeconfigPath string, logger *logrus.Logger, wakeupInterval ti
configMapInformer := informerFactory.Core().V1().ConfigMaps()

queueInformers := []*queueinformer.QueueInformer{
queueinformer.NewInformer(roleQueue, roleInformer.Informer(), op.syncObject, handleDelete, "role", metrics.NewMetricsNil()),
queueinformer.NewInformer(roleBindingQueue, roleBindingInformer.Informer(), op.syncObject, handleDelete, "rolebinding", metrics.NewMetricsNil()),
queueinformer.NewInformer(serviceAccountQueue, serviceAccountInformer.Informer(), op.syncObject, handleDelete, "serviceaccount", metrics.NewMetricsNil()),
queueinformer.NewInformer(serviceQueue, serviceInformer.Informer(), op.syncObject, handleDelete, "service", metrics.NewMetricsNil()),
queueinformer.NewInformer(podQueue, podInformer.Informer(), op.syncObject, handleDelete, "pod", metrics.NewMetricsNil()),
queueinformer.NewInformer(configmapQueue, configMapInformer.Informer(), op.syncObject, handleDelete, "configmap", metrics.NewMetricsNil()),
queueinformer.NewInformer(roleQueue, roleInformer.Informer(), op.syncObject, handleDelete, "role", metrics.NewMetricsNil(), logger),
queueinformer.NewInformer(roleBindingQueue, roleBindingInformer.Informer(), op.syncObject, handleDelete, "rolebinding", metrics.NewMetricsNil(), logger),
queueinformer.NewInformer(serviceAccountQueue, serviceAccountInformer.Informer(), op.syncObject, handleDelete, "serviceaccount", metrics.NewMetricsNil(), logger),
queueinformer.NewInformer(serviceQueue, serviceInformer.Informer(), op.syncObject, handleDelete, "service", metrics.NewMetricsNil(), logger),
queueinformer.NewInformer(podQueue, podInformer.Informer(), op.syncObject, handleDelete, "pod", metrics.NewMetricsNil(), logger),
queueinformer.NewInformer(configmapQueue, configMapInformer.Informer(), op.syncObject, handleDelete, "configmap", metrics.NewMetricsNil(), logger),
}
for _, q := range queueInformers {
op.RegisterQueueInformer(q)
Expand All @@ -213,12 +214,12 @@ func (o *Operator) syncObject(obj interface{}) (syncError error) {
runtimeObj, ok := obj.(runtime.Object)
if !ok {
syncError = errors.New("object sync: casting to runtime.Object failed")
log.Warn(syncError.Error())
o.Log.Warn(syncError.Error())
return
}

gvk := runtimeObj.GetObjectKind().GroupVersionKind()
logger := log.WithFields(log.Fields{
logger := o.Log.WithFields(logrus.Fields{
"group": gvk.Group,
"version": gvk.Version,
"kind": gvk.Kind,
Expand All @@ -231,7 +232,7 @@ func (o *Operator) syncObject(obj interface{}) (syncError error) {
logger.Warn(syncError.Error())
return
}
logger = logger.WithFields(log.Fields{
logger = logger.WithFields(logrus.Fields{
"name": metaObj.GetName(),
"namespace": metaObj.GetNamespace(),
})
Expand Down Expand Up @@ -276,12 +277,12 @@ func (o *Operator) syncCatalogSources(obj interface{}) (syncError error) {
return fmt.Errorf("casting CatalogSource failed")
}

logger := log.WithFields(log.Fields{
logger := o.Log.WithFields(logrus.Fields{
"source": catsrc.GetName(),
})

if catsrc.Spec.SourceType == v1alpha1.SourceTypeInternal || catsrc.Spec.SourceType == v1alpha1.SourceTypeConfigmap {
return o.syncConfigMapSource(logger, catsrc)
return o.syncConfigMapSource(logger.Logger, catsrc)
}

logger.WithField("sourceType", catsrc.Spec.SourceType).Warn("unknown source type")
Expand All @@ -291,7 +292,7 @@ func (o *Operator) syncCatalogSources(obj interface{}) (syncError error) {
return nil
}

func (o *Operator) syncConfigMapSource(logger *log.Entry, catsrc *v1alpha1.CatalogSource) (syncError error) {
func (o *Operator) syncConfigMapSource(logger *logrus.Logger, catsrc *v1alpha1.CatalogSource) (syncError error) {

// Get the catalog source's config map
configMap, err := o.lister.CoreV1().ConfigMapLister().ConfigMaps(catsrc.GetNamespace()).Get(catsrc.Spec.ConfigMap)
Expand Down
7 changes: 1 addition & 6 deletions pkg/controller/operators/catalog/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import (
"testing"
"time"

"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorlister"
"k8s.io/client-go/informers"
"k8s.io/client-go/tools/cache"

"github.com/ghodss/yaml"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
Expand All @@ -19,11 +15,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/informers"
k8sfake "k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/tools/cache"
apiregistrationfake "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/fake"
"k8s.io/client-go/informers"
"k8s.io/client-go/tools/cache"

"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators/v1alpha1"
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned/fake"
Expand Down
Loading

0 comments on commit 67dbf8f

Please sign in to comment.