Check updateNeeded only when a site is installed and/or when a site is running
When an update has failed, and if the deployment is deleted, the operator doesn't ensure a new deployment according to the current logic
When doing an exec to a server pod, instead of picking the first pod from the result podList, pick the pod that has the status Running
Remove admin annotation and let admins edit the resources. So essentially, we only create a resource and don't ensure the state every time
Although some spec should be ensured and kept in state, for ex images in the deployment
Site installed logic
If the siteInstalled status is set to true. Do nothing.
If not, exec to the pod and check if site is installed and set the status accordingly
Change the status name 'Installed' to 'Initialized'
Update the update workflow
During the reconciliation, if the running pod version is different from the spec and if DBUpdateFailed and CodeUpdateFailed is not set, add an annotation updateInProgress: true
If the updateInProgress annotation is set, trigger a code update
Update the deployment using controllerruntime.CreateOrUpdate
if OperationResult returns 'Unchanged', then check if the rollout has succeeded. If not, reconcile (Optimization: Check replica set or external resources have failed after a given number of retries, make it a permanent issue)
Run drush cr twice or so and if it returns an error rollback the version and set the status CodeUpdateFailed to true, remove the annotation updateInProgress and exit
Check if a 'dbUpdate' is needed. If yes, set statusCondition DBUpdatesPending, set the site in maintenance mode, run drush updb, disable maintenance mode (Run from the same script)
If this fails, set statusCondition DBUpdatesFailed, permanent error if needed and don't reconcile
Remove the annotation updateInProgress and remove the status condition DBUpdatesPending if DBUpdatesFailed is not set
In the original reconciliation, if DBUpdatesPending status condition is set & DBUpdatesFailed is not set, exec into pod and confirm if db updates are pending. If not, remove the DBUpdatesPending