janhoy opened a new pull request, #905:
URL: https://github.com/apache/solr-operator/pull/905
🤖 AI assisted 🤖
Fixes #872
The SolrCloud, SolrBackup and SolrPrometheusExporter reconcilers wrote their
defaults back with a full `Update`, and the SolrCloud storage finalizer was
added and removed the same way. The object goes through the Go types on the
way, which writes fields the client never set, such as an empty `resources: {}`
on every init container. The API server counts those as changes made by the
operator, so the operator became the owner of them, and of the whole of any
atomic list they sit in. Helm 4 applies server-side by default, and from the
second `helm upgrade` on it failed with:
```
Apply failed with 1 conflict: conflict with "solr-operator" using
solr.apache.org/v1beta1: .spec.customSolrKubeOptions.podOptions.initContainers
```
### Fix
These writes now use a merge patch computed from the object as it was read,
with an optimistic lock to keep the conflict detection that `Update` had. The
Go round trip happens on both sides of the diff and cancels out, so only the
fields the operator actually changed reach the API server, and the operator
owns only those.
### Not covered
A field the operator did default is still owned by it. A server-side apply
of the same value is fine, but a different value still conflicts. For example,
a chart that leaves out `image.pullPolicy` gets it defaulted, and setting
`pullPolicy: Always` later fails on that field. `--force-conflicts` is the
right answer there, since Helm should take the field over. Removing this
entirely means the operator giving up ownership of its defaults, either by
moving them into the CRD schema as `+kubebuilder:default` markers or by
dropping its `managedFields` entry after writing them. That is left for a
follow-up.
### Testing
A new envtest spec applies a SolrCloud server-side as `helm` with an init
container, waits for the operator to default it, and applies it again without
forcing conflicts. It fails with the error above before this change and passes
after. `make test` and `make lint` pass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]