Skip to content

Commit ee40fd9

Browse files
committed
Filter secret names for registry pod's sa
During the registry server sync the image pull secrets from the catalogsource's spec.secrets are passed unfiltered to the serviceaccount for the registry pod. Passing an empty string in the secrets list breaks serverside apply for the registry pod with the following error: failed to convert new object (/v1, Kind=Pod) to smd typed: .spec.imagePullSecrets: element 0: associative list with keys has an element that omits key field "name" (and doesn't have default value) This prevents the registry pod from being promoted via the SSA client when there is an update to the index image. To fix this, the image pull secrets list is filtered for empty strings before being set on the serviceaccount. Signed-off-by: Haseeb Tariq <[email protected]>
1 parent 9053ec3 commit ee40fd9

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pkg/controller/registry/reconciler/grpc.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ func (s *grpcCatalogSourceDecorator) ServiceAccount() *corev1.ServiceAccount {
9898
blockOwnerDeletion := true
9999
isController := true
100100
for _, secretName := range s.CatalogSource.Spec.Secrets {
101+
if secretName == "" {
102+
continue
103+
}
101104
secrets = append(secrets, corev1.LocalObjectReference{Name: secretName})
102105
}
103106
return &corev1.ServiceAccount{

pkg/controller/registry/reconciler/grpc_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func validGrpcCatalogSource(image, address string) *v1alpha1.CatalogSource {
3333
}
3434
}
3535

36-
func grpcCatalogSourceWithSecret(secretName string) *v1alpha1.CatalogSource {
36+
func grpcCatalogSourceWithSecret(secretNames []string) *v1alpha1.CatalogSource {
3737
return &v1alpha1.CatalogSource{
3838
ObjectMeta: metav1.ObjectMeta{
3939
Name: "private-catalog",
@@ -45,7 +45,7 @@ func grpcCatalogSourceWithSecret(secretName string) *v1alpha1.CatalogSource {
4545
Image: "private-image",
4646
Address: "",
4747
SourceType: v1alpha1.SourceTypeGrpc,
48-
Secrets: []string{secretName},
48+
Secrets: secretNames,
4949
},
5050
}
5151
}
@@ -61,6 +61,10 @@ func TestGrpcRegistryReconciler(t *testing.T) {
6161
blockOwnerDeletion := true
6262
isController := true
6363

64+
// We expect the empty string secret name should not be set
65+
// on the service account
66+
testSecrets := []string{"test-secret", ""}
67+
6468
type cluster struct {
6569
k8sObjs []runtime.Object
6670
}
@@ -225,7 +229,7 @@ func TestGrpcRegistryReconciler(t *testing.T) {
225229
},
226230
},
227231
},
228-
catsrc: grpcCatalogSourceWithSecret("test-secret"),
232+
catsrc: grpcCatalogSourceWithSecret(testSecrets),
229233
},
230234
out: out{
231235
status: &v1alpha1.RegistryServiceStatus{

0 commit comments

Comments
 (0)