Per discussion this morning with Gustavo, Jon, Ian, we'd like to make open-port and close-port on K8s sidechar charms work on any unit (not just the leader) with as similar behaviour to machine charms as possible. Specifically:
* Allow open-port to happen from any unit, and Juju would open the ports (in the K8s service definition) that are the union of all ports that any unit has opened. So if unit/1 opened port 8080 and unit/2 opened port 4000, we'd tell K8s to open both. This would be unusual but supported.
* Kind of the opposite for close-port: Juju would only close the port in the K8s service definition once all units had asked for that port to be closed.
* Remove the check for is-leader.
In the Python Operator Framework, charms would call (for example) Unit.open_port('tcp', 8080) without an is-leader check, and this would work as expected for both K8s sidecar and machine charms. (Good thinking forward to universal charms.)
This supersedes our previous idea to add an --app / --application arg to open-port for K8s sidecar charms: https://bugs.launchpad.net/juju/+bug/2006672
https:/ /github. com/juju/ juju/pull/ 15225