@@ -354,6 +354,14 @@ func (r *OpenStackReconciler) countDeployments(ctx context.Context, instance *op
354354 return count , nil
355355}
356356
357+ // containerImageMatch - returns true if the deployedContainerImage matches the operatorImage
358+ func containerImageMatch (instance * operatorv1beta1.OpenStack ) bool {
359+ if instance .Status .ContainerImage != nil && * instance .Status .ContainerImage == operatorImage {
360+ return true
361+ }
362+ return false
363+ }
364+
357365func isWebhookEndpoint (name string ) bool {
358366 // NOTE: this is a static list for all operators with webhooks enabled
359367 endpointNames := []string {"openstack-operator-webhook-service" , "infra-operator-webhook-service" , "openstack-baremetal-operator-webhook-service" }
@@ -402,15 +410,19 @@ func (r *OpenStackReconciler) checkServiceEndpoints(ctx context.Context, instanc
402410}
403411
404412func (r * OpenStackReconciler ) applyManifests (ctx context.Context , instance * operatorv1beta1.OpenStack ) error {
405- if err := r .applyCRDs (ctx , instance ); err != nil {
406- log .Log .Error (err , "failed applying CRD manifests" )
407- return err
408- }
413+ // only apply CRDs and RBAC once per each containerImage change
414+ if ! containerImageMatch (instance ) {
415+ if err := r .applyCRDs (ctx , instance ); err != nil {
416+ log .Log .Error (err , "failed applying CRD manifests" )
417+ return err
418+ }
409419
410- if err := r .applyRBAC (ctx , instance ); err != nil {
411- log .Log .Error (err , "failed applying RBAC manifests" )
412- return err
420+ if err := r .applyRBAC (ctx , instance ); err != nil {
421+ log .Log .Error (err , "failed applying RBAC manifests" )
422+ return err
423+ }
413424 }
425+ instance .Status .ContainerImage = & operatorImage
414426
415427 if err := r .applyOperator (ctx , instance ); err != nil {
416428 log .Log .Error (err , "failed applying Operator manifests" )
0 commit comments