Order guarantees for how children are handled
Does metacontroller offer any ordering guarantees for how children returned by a CompositeController are created/sync'd?
In my use case, I have my controller produce a combination of PVs, PVCs, and StatefulSets. I would like to ensure the PVC resources have been created ahead of StatefulSets.
Does order of listing child resource types in the composite controller spec determine processing order?
Currently the way we would recommend to achieve ordering like this is to include the StatefulSet in the list of desired children only if (a) the StatefulSet was already observed, or (b) the necessary PVCs were already observed. In other words, keep the StatefulSet if it already exists; if it doesn't exist, wait until the PVCs are ready before creating the StatefulSet.
In the future, it might make sense to offer an easier way to specify ordering, but my original intuition was that the hook is in the best position to decide when it makes sense to create something, since there are many different ways you might make that decision (e.g. looking at specific status conditions, not just existence).
Thanks -- perhaps it makes sense to track this as a potential feature?
For the very specific use-case, I think we might be able to get-by with creating pre-claimed PVs and pre-bound PVCs alongside with the StatefulSet, but need to see if that holds up over continued use, i.e. when StatefulSet creates PVCs, it doesn't override the binding information.
Including @barney-s as fyi
Just to make sure my earlier comment was clear:
It's already possible to get order guarantees for children, so you can ensure that the StatefulSet doesn't get created until after the PVCs are fully bound, if that's what you want. I was only talking about a future enhancement that would perform this logic for you automatically on the server side.
For example, your hook could have logic like this pseudocode:
desired_children = []
# PVs and PVCs don't depend on anything, so always return them.
desired_children.extend(make_pvs())
desired_children.extend(make_pvcs())
# Only return StatefulSet if it was already observed (so we don't delete it),
# or if we observe our PVCs are ready.
if 'my-statefulset' in observed_children['StatefulSet.apps/v1']
or all_exist_and_bound(observed_children['PersistentVolumeClaim.v1']):
desired_children.append(make_sts())
Yes... that definitely makes sense. Thanks for outlining further.