K8s charm add-unit failure


I’m using 2.8-beta1-focal-amd64 and testing out charms on k8s, and came across an oddity (which is most likely my misunderstanding of how k8s charms work) with my charm and running “add-unit”. It’s failing with:

raise ModelError(‘cannot set a pod spec as this unit is not a leader’)

Looking at containers in the relevant namespace I see two “application” pods and one “operator” pod. I’m confused about where the pod spec is being set - isn’t that on the operator pod, and if so, why is it failing in this way?

Thanks, Tom

The operator pod runs as many instances of the unit agent as there are units - just like for non-k8s models. The difference is that for k8s models, these unit agents all run in the same pod.

It sounds like there may be a bug in the charm. The charm should not attempt to set pod spec unless it is the leader, and also it seems it is unnecessarily running set pod spec when it doesn’t need to. But that’s just a guess.

Ping me on irc and I can help further.