janhoy opened a new issue, #913:
URL: https://github.com/apache/solr-operator/issues/913
🤖 AI assisted 🤖
### Summary
After upgrading the operator from 0.9.x to 0.10.0 (which includes #905), a
SolrCloud managed with server-side apply (Helm 4, or ArgoCD with
`ServerSideApply=true`) can end up with fields that no field manager owns.
Omitting such a field from a later apply does not remove it, which can leave
the SolrCloud spec inconsistent and block the rolling update.
### How it happens
1. Operator 0.9.x wrote its defaults back to the SolrCloud with a full
`Update`. Because the object went through the Go types, fields the user never
set were written as well, e.g. `resources: {}` on every container. The API
server saw these as changes and made the operator the owner of them.
`podOptions.initContainers` and `podOptions.sidecarContainers` have no
`x-kubernetes-list-type`, so they are atomic, and the operator took ownership
of the whole list away from the applier. This is the conflict reported in #872.
2. #905 fixes the conflict by deleting the operator's `managedFields` entry
(`releaseFieldOwnership` in `controllers/common.go`). On a SolrCloud last
written by 0.9.x, the fields that only the operator owned are now owned by no
one.
3. Server-side apply only removes fields that the applier owns. If the first
apply after the operator upgrade leaves out such a field, it stays on the
object.
### Example
A SolrCloud is installed with the `solr` Helm chart, with an init container
in `podOptions.initContainers` that mounts a volume from `podOptions.volumes`.
After the operator is upgraded from 0.9.x to 0.10.0, both values are removed
and the chart is upgraded with Helm 4. The chart leaves out both fields when
they are empty. Helm owns the volume, so it is removed. Nobody owns the init
container list, so it stays. The operator's StatefulSet update is then rejected
with `volumeMounts[0].name: Not found: "<volume>"`, the pods stay on the old
spec, and the SolrCloud reports `UpToDateNodes: 0`.
### When it applies
All of these must hold:
- the SolrCloud was created or last updated by operator 0.9.x
- it is applied server-side (Helm 3's client-side apply is not affected)
- the first server-side apply after the operator upgrade omits a field that
0.9.x took over
An apply that still includes the field takes ownership of it again, so the
problem is limited to that first apply. It is most likely when the operator and
the SolrCloud are upgraded together. A SolrCloud created on 0.10.0 does not get
into this state.
Fields at risk are the lists of containers, which pick up empty fields in
the Go round-trip: `podOptions.initContainers`, `podOptions.sidecarContainers`,
and the ZooKeeper pod policy's `initContainers` and `containers`. Defaulted
fields such as `solrImage.tag` are also left without an owner, but that is
harmless, since no applier ever set them.
### Workaround
Remove the field once, either by applying an explicit empty value
(`initContainers: []`) or by hand:
kubectl patch solrcloud <name> --type=json -p
'[{"op":"remove","path":"/spec/customSolrKubeOptions/podOptions/initContainers"}]'
### Proposed fix
The fields that 0.9.x took over by accident are a fixed set, because they
come from 0.9.x code that will not change. The ones that matter are atomic
lists, since the operator took over each of them as a whole. Inside maps it
only took the empty sub-fields it added, which are harmless to leave unowned.
Before `releaseFieldOwnership` drops the operator's entry, it should hand
these lists back to the applier:
- For each known path (`podOptions.initContainers` and
`podOptions.sidecarContainers` on SolrCloud and SolrPrometheusExporter, and the
ZooKeeper pod policy's `initContainers` and `containers`), if the operator is
the only owner and the object has exactly one `Apply` manager, move the path
into that manager's field set.
- Otherwise drop the entry as today.
Leaving defaulted fields unowned stays as it is. Handing those to the
applier would be unsafe, because the applier's next apply would remove them and
the operator would re-default them with its current defaults, e.g. a newer Solr
version than the one the cloud was created with.
A test that writes a SolrCloud the way 0.9.x did and checks that no list is
left without an owner would catch any path missing from the list, e.g.
`podOptions.volumes` with ephemeral volumes, whose claim template also picks up
`resources: {}`.
In addition, add a short note about this to the v0.10.0 upgrade notes, with
the workaround above, for the cases the fix does not cover.
Since #905 is in the 0.10.0 release branch, this should ideally land before
0.10.0 is released.
--
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]