Skip to content

Commit

Permalink
Merge pull request #298 from awgreene/bz-2080609
Browse files Browse the repository at this point in the history
[release-4.10] Bug 2080609: Fix GRPC CheckRegistryServer function (#2756)
  • Loading branch information
openshift-ci[bot] committed May 12, 2022
2 parents 1cb0c9a + 8dfb00a commit 1a99acb
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
Expand Up @@ -1039,6 +1039,7 @@ func TestSyncCatalogSources(t *testing.T) {
k8sObjs: []runtime.Object{
pod(*grpcCatalog),
service(grpcCatalog.GetName(), grpcCatalog.GetNamespace()),
serviceAccount(grpcCatalog.GetName(), grpcCatalog.GetNamespace(), "", objectReference("init secret")),
},
existingSources: []sourceAddress{
{
Expand Down
Expand Up @@ -146,6 +146,16 @@ func (c *GrpcRegistryReconciler) currentService(source grpcCatalogSourceDecorato
return service
}

func (c *GrpcRegistryReconciler) currentServiceAccount(source grpcCatalogSourceDecorator) *corev1.ServiceAccount {
serviceAccountName := source.ServiceAccount().GetName()
serviceAccount, err := c.Lister.CoreV1().ServiceAccountLister().ServiceAccounts(source.GetNamespace()).Get(serviceAccountName)
if err != nil {
logrus.WithField("serviceAccount", serviceAccount).Debug("couldn't find serviceAccount in cache")
return nil
}
return serviceAccount
}

func (c *GrpcRegistryReconciler) currentPods(source grpcCatalogSourceDecorator) []*corev1.Pod {
pods, err := c.Lister.CoreV1().PodLister().Pods(source.GetNamespace()).List(source.Selector())
if err != nil {
Expand Down Expand Up @@ -441,7 +451,7 @@ func (c *GrpcRegistryReconciler) CheckRegistryServer(catalogSource *v1alpha1.Cat
// Check on registry resources
// TODO: add gRPC health check
if len(c.currentPodsWithCorrectImageAndSpec(source, source.ServiceAccount().GetName())) < 1 ||
c.currentService(source) == nil {
c.currentService(source) == nil || c.currentServiceAccount(source) == nil {
healthy = false
return
}
Expand Down
Expand Up @@ -485,6 +485,18 @@ func TestGrpcRegistryChecker(t *testing.T) {
healthy: false,
},
},
{
testName: "Grpc/ExistingRegistry/Image/BadServiceAccount",
in: in{
cluster: cluster{
k8sObjs: modifyObjName(objectsForCatalogSource(validGrpcCatalogSource("test-img", "")), &corev1.ServiceAccount{}, "badName"),
},
catsrc: validGrpcCatalogSource("test-img", ""),
},
out: out{
healthy: false,
},
},
{
testName: "Grpc/ExistingRegistry/Image/BadPod",
in: in{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1a99acb

Please sign in to comment.