@@ -173,20 +173,36 @@ protected boolean forceChange(HasMetadata requiredResource, StackGresCluster con
173173 return true ;
174174 }
175175 final OwnerReference clusterOwnerReference = ResourceUtil .getOwnerReference (config );
176- final boolean anyPodOrPvcWithMissingOwner = deployedResourcesCache
176+ final boolean anyPodWithMissingOwner = deployedResourcesCache
177177 .stream ()
178178 .map (DeployedResource ::foundDeployed )
179- .filter (this ::isPodOrPvc )
179+ .filter (this ::isPod )
180+ .filter (foundDeployedResource -> hasLabels (clusterPodsLabels , foundDeployedResource ))
181+ .anyMatch (foundDeployedResource -> isMissingOwner (
182+ foundDeployedResource , clusterOwnerReference ));
183+ if (anyPodWithMissingOwner && LOGGER .isDebugEnabled ()) {
184+ LOGGER .debug ("Will force StatefulSet reconciliation since a pod is"
185+ + " missing owner reference for SGCluster {}.{}" ,
186+ config .getMetadata ().getNamespace (),
187+ config .getMetadata ().getName ());
188+ }
189+ if (anyPodWithMissingOwner ) {
190+ return true ;
191+ }
192+ final boolean anyPvcWithMissingOwner = deployedResourcesCache
193+ .stream ()
194+ .map (DeployedResource ::foundDeployed )
195+ .filter (this ::isPvc )
180196 .filter (foundDeployedResource -> hasLabels (genericLabels , foundDeployedResource ))
181197 .anyMatch (foundDeployedResource -> isMissingOwner (
182198 foundDeployedResource , clusterOwnerReference ));
183- if (anyPodOrPvcWithMissingOwner && LOGGER .isDebugEnabled ()) {
184- LOGGER .debug ("Will force StatefulSet reconciliation since a pod or pvc is"
199+ if (anyPvcWithMissingOwner && LOGGER .isDebugEnabled ()) {
200+ LOGGER .debug ("Will force StatefulSet reconciliation since a pvc is"
185201 + " missing owner reference for SGCluster {}.{}" ,
186202 config .getMetadata ().getNamespace (),
187203 config .getMetadata ().getName ());
188204 }
189- if (anyPodOrPvcWithMissingOwner ) {
205+ if (anyPvcWithMissingOwner ) {
190206 return true ;
191207 }
192208 }
@@ -225,7 +241,12 @@ private boolean isPodWithWrongOrMissingRole(
225241 .isPresent ();
226242 }
227243
228- private boolean isPodOrPvc (HasMetadata foundDeployedResource ) {
244+ private boolean isPod (HasMetadata foundDeployedResource ) {
245+ return foundDeployedResource instanceof Pod
246+ || foundDeployedResource instanceof PersistentVolumeClaim ;
247+ }
248+
249+ private boolean isPvc (HasMetadata foundDeployedResource ) {
229250 return foundDeployedResource instanceof Pod
230251 || foundDeployedResource instanceof PersistentVolumeClaim ;
231252 }
0 commit comments