Skip to content

Bug 2074612: Fix GRPC CheckRegistryServer function (#2756) #294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,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
Original file line number Diff line number Diff line change
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("service", serviceAccount).Debug("couldn't find service in cache")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to pull in the #297 commit as well here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disregard - wrong PR (:laughing:)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #298

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
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,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.