Patching a service is always going to be racy, as Juju's role is "here is a model, modify the world to make this so". You can get lucky to change things while Juju isn't looking, but generally when it thinks it needs to double check if everything is consistent, it is going to evaluate the state of the world and how that differs from its internal model.
The real answer is to change the juju<->charm interaction so the charm is updating juju's model so that it is enforcing what you need. In the short term, you need to exercise diligence because something like 'add-unit' could easily cause Juju to re-evaluate the state of the world and see that it doesn't match expectations.
Juju *doesn't* follow the terraform model of tracking a 'these are the things that I applied relative to the current plan', and ignoring any other changes.
I don't know the specifics of why we are looking at the service definition and changing it, but in the general sense we are always trying to make the world match our model.
Patching a service is always going to be racy, as Juju's role is "here is a model, modify the world to make this so". You can get lucky to change things while Juju isn't looking, but generally when it thinks it needs to double check if everything is consistent, it is going to evaluate the state of the world and how that differs from its internal model.
The real answer is to change the juju<->charm interaction so the charm is updating juju's model so that it is enforcing what you need. In the short term, you need to exercise diligence because something like 'add-unit' could easily cause Juju to re-evaluate the state of the world and see that it doesn't match expectations.
Juju *doesn't* follow the terraform model of tracking a 'these are the things that I applied relative to the current plan', and ignoring any other changes.
I don't know the specifics of why we are looking at the service definition and changing it, but in the general sense we are always trying to make the world match our model.