Bug 2113981

Summary: BMAC reconcile loop never stops after changes
Product: Red Hat Advanced Cluster Management for Kubernetes Reporter: OpenShift BugZilla Robot <openshift-bugzilla-robot>
Component: Infrastructure OperatorAssignee: Mat Kowalski <mko>
Status: ON_QA --- QA Contact: Chad Crum <ccrum>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rhacm-2.5CC: ccrum, trwest, yfirst
Target Milestone: ---   
Target Release: rhacm-2.4.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2112817    
Bug Blocks:    

Description OpenShift BugZilla Robot 2022-08-02 13:35:38 UTC
+++ This bug was initially created as a clone of Bug #2112817 +++

+++ This bug was initially created as a clone of Bug #2112321 +++

In multiple places inside BMAC we are changing state of the CR and mark the result as `dirty: true`. This is later handled by 2 following approaches

1) reconcileComplete{dirty: true}
2) reconcileComplete{dirty: true, stop: true}

Given that we should be stopping reconcile loop after every change made, in order to avoid errors like

```
Operation cannot be fulfilled on baremetalhosts.metal3.io [...]: the object has been modified; please apply your changes to the latest version and try again
```

we should only use `dirty: true` together with `stop: true`. Currently using (1) leads to some unexpected races when objects are modified (or not) multiple times in the same loop.