@@ -12,6 +12,7 @@ import (
1212
1313 "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
1414 controllerclient "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/controller-runtime/client"
15+ "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/image"
1516 hashutil "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/kubernetes/pkg/util/hash"
1617 "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
1718 "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorlister"
@@ -39,7 +40,6 @@ type grpcCatalogSourceDecorator struct {
3940 * v1alpha1.CatalogSource
4041 createPodAsUser int64
4142 opmImage string
42- utilImage string
4343}
4444
4545type UpdateNotReadyErr struct {
@@ -144,7 +144,7 @@ func (s *grpcCatalogSourceDecorator) ServiceAccount() *corev1.ServiceAccount {
144144}
145145
146146func (s * grpcCatalogSourceDecorator ) Pod (serviceAccount * corev1.ServiceAccount , defaultPodSecurityConfig v1alpha1.SecurityConfig ) (* corev1.Pod , error ) {
147- pod , err := Pod (s .CatalogSource , "registry-server" , s .opmImage , s .utilImage , s . Spec .Image , serviceAccount , s .Labels (), s .Annotations (), 5 , 10 , s .createPodAsUser , defaultPodSecurityConfig )
147+ pod , err := Pod (s .CatalogSource , "registry-server" , s .opmImage , s .Spec .Image , serviceAccount , s .Labels (), s .Annotations (), 5 , 10 , s .createPodAsUser , defaultPodSecurityConfig )
148148 if err != nil {
149149 return nil , err
150150 }
@@ -159,7 +159,6 @@ type GrpcRegistryReconciler struct {
159159 SSAClient * controllerclient.ServerSideApplier
160160 createPodAsUser int64
161161 opmImage string
162- utilImage string
163162}
164163
165164var _ RegistryReconciler = & GrpcRegistryReconciler {}
@@ -262,23 +261,27 @@ func (c *GrpcRegistryReconciler) currentPodsWithCorrectImageAndSpec(logger *logr
262261}
263262
264263func correctImages (source grpcCatalogSourceDecorator , pod * corev1.Pod ) bool {
264+ if len (pod .Spec .InitContainers ) != 0 || len (pod .Spec .Containers ) != 1 {
265+ return false
266+ }
267+ if pod .Spec .Containers [0 ].Image != source .CatalogSource .Spec .Image {
268+ return false
269+ }
265270 if source .CatalogSource .Spec .GrpcPodConfig != nil && source .CatalogSource .Spec .GrpcPodConfig .ExtractContent != nil {
266- if len (pod .Spec .InitContainers ) != 2 {
271+ if len (pod .Spec .Volumes ) == 0 {
267272 return false
268273 }
269- if len (pod .Spec .Containers ) != 1 {
270- return false
271- }
272- return pod .Spec .InitContainers [0 ].Image == source .utilImage &&
273- pod .Spec .InitContainers [1 ].Image == source .CatalogSource .Spec .Image &&
274- pod .Spec .Containers [0 ].Image == source .opmImage
274+ return pod .Spec .Volumes [0 ].Name == opmVolumeName &&
275+ pod .Spec .Volumes [0 ].VolumeSource .Image != nil &&
276+ pod .Spec .Volumes [0 ].VolumeSource .Image .Reference == source .opmImage &&
277+ pod .Spec .Volumes [0 ].VolumeSource .Image .PullPolicy == image .InferImagePullPolicy (source .opmImage )
275278 }
276- return pod . Spec . Containers [ 0 ]. Image == source . CatalogSource . Spec . Image
279+ return true
277280}
278281
279282// EnsureRegistryServer ensures that all components of registry server are up to date.
280283func (c * GrpcRegistryReconciler ) EnsureRegistryServer (logger * logrus.Entry , catalogSource * v1alpha1.CatalogSource ) error {
281- source := grpcCatalogSourceDecorator {CatalogSource : catalogSource , createPodAsUser : c .createPodAsUser , opmImage : c .opmImage , utilImage : c . utilImage }
284+ source := grpcCatalogSourceDecorator {CatalogSource : catalogSource , createPodAsUser : c .createPodAsUser , opmImage : c .opmImage }
282285
283286 // if service status is nil, we force create every object to ensure they're created the first time
284287 valid , err := isRegistryServiceStatusValid (& source )
@@ -618,21 +621,16 @@ func isPodDead(pod *corev1.Pod) bool {
618621 return false
619622}
620623
621- // imageID returns the ImageID of the primary catalog source container or an empty string if the image ID isn't available yet.
624+ // imageID returns the ImageID of the catalog source container or an empty string if the image ID isn't available yet.
622625// Note: the pod must be running and the container in a ready status to return a valid ImageID.
623626func imageID (pod * corev1.Pod ) string {
624- if len (pod .Status .InitContainerStatuses ) == 2 && len (pod .Status .ContainerStatuses ) == 1 {
625- // spec.grpcPodConfig.extractContent mode was used for this pod
626- return pod .Status .InitContainerStatuses [1 ].ImageID
627- }
628- if len (pod .Status .InitContainerStatuses ) == 0 && len (pod .Status .ContainerStatuses ) == 1 {
629- // spec.grpcPodConfig.extractContent mode was NOT used for this pod (i.e. we're just running the catalog image directly)
627+ if len (pod .Status .ContainerStatuses ) == 1 {
630628 return pod .Status .ContainerStatuses [0 ].ImageID
631629 }
632- if len (pod .Status .InitContainerStatuses ) == 0 && len ( pod . Status . ContainerStatuses ) == 0 {
633- logrus .WithField ("CatalogSource" , pod .GetName ()).Warn ("pod status unknown; pod has not yet populated initContainer and container status" )
630+ if len (pod .Status .ContainerStatuses ) == 0 {
631+ logrus .WithField ("CatalogSource" , pod .GetName ()).Warn ("pod status unknown; pod has not yet populated container status" )
634632 } else {
635- logrus .WithField ("CatalogSource" , pod .GetName ()).Warn ("pod status unknown; pod contains unexpected initContainer and container configuration" )
633+ logrus .WithField ("CatalogSource" , pod .GetName ()).Warn ("pod status unknown; pod contains unexpected container configuration" )
636634 }
637635 return ""
638636}
@@ -648,7 +646,7 @@ func (c *GrpcRegistryReconciler) removePods(pods []*corev1.Pod, namespace string
648646
649647// CheckRegistryServer returns true if the given CatalogSource is considered healthy; false otherwise.
650648func (c * GrpcRegistryReconciler ) CheckRegistryServer (logger * logrus.Entry , catalogSource * v1alpha1.CatalogSource ) (bool , error ) {
651- source := grpcCatalogSourceDecorator {CatalogSource : catalogSource , createPodAsUser : c .createPodAsUser , opmImage : c .opmImage , utilImage : c . utilImage }
649+ source := grpcCatalogSourceDecorator {CatalogSource : catalogSource , createPodAsUser : c .createPodAsUser , opmImage : c .opmImage }
652650
653651 // The CheckRegistryServer function is called by the CatalogSoruce controller before the registry resources are created,
654652 // returning a IsNotFound error will cause the controller to exit and never create the resources, so we should
0 commit comments