Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request juju#18735 from jack-w-shaw/JUJU-7148_remove_port_…
…run_atomic juju#18735 RunAtomic is an anti-pattern. We recently decided to remove it. One of the places RunAtomic was used was in the unit ports domain. We had the admirable aim of isolating the business logic, specifically how juju interacts with the wildcard endpoint, away from persistence logic. So removing RunAtomic meant moving all this logic out of the service layer and into the state layer. UpdateUnitPorts is now very complex. Move all the logic surrounding UpdateUnitPorts into it's own file. Do the same for tests. This was pretty much a 1-to-1 migration. However, there was one marginal change. I discovered a bug with GetEndpointOpenedPorts, a method designed to get the opened ports for a specific endpoint. The wildcard is a special case endpoint, which broke this method. But it turned out, now the method is private, we only need this method to query the wildcard endpoint. Rewire this method slightly to be specialised for the wildcard endpoint. ## QA steps ### Prepare ``` $ juju bootstrap lxd lxd $ juju add-model m ``` Download and modify the `ubuntu` charm archive such that it's metadata.yaml reads: ``` ... summary: A pristine Ubuntu Server provides: ep1: interface: ep1 ep2: interface: ep2 ep3: interface: ep3 ``` And continue: ``` $ juju deploy ./ubuntu.charm (wait until active) ``` In another terminal: ``` $ juju ssh -m controller 0 $ sudo /var/lib/juju/tools/machine-0/jujud db-repl --machine-id 0 repl (controller)> .switch model-m ``` ### Tests ``` $ juju exec --unit ubuntu/0 "open-port --endpoints ep1 1000/tcp" repl (model-m)> SELECT prdesc FROM v_port_range uuid from_port to_port unit_uuid unit_name protocol endpoint bda33dda-852e-45ee-8505-1481d509f8a2 1000 1000 7e7414c1-71a7-4350-89d3-081118304afc ubuntu/0 tcp ep1 ``` ``` $ juju exec --unit ubuntu/0 "open-port --endpoints ep2 1000/tcp" repl (model-m)> SELECT prdesc FROM v_port_range uuid from_port to_port unit_uuid unit_name protocol endpoint bda33dda-852e-45ee-8505-1481d509f8a2 1000 1000 7e7414c1-71a7-4350-89d3-081118304afc ubuntu/0 tcp ep1 1fb45aee-16fb-42d9-80f0-cf889af2e7bc 1000 1000 7e7414c1-71a7-4350-89d3-081118304afc ubuntu/0 tcp ep2 ``` ``` $ juju exec --unit ubuntu/0 "close-port 1000/tcp" repl (model-m)> SELECT prdesc FROM v_port_range uuid from_port to_port unit_uuid unit_name protocol endpoint ``` ``` $ juju exec --unit ubuntu/0 "open-port 1000/tcp" $ juju exec --unit ubuntu/0 "close-port --endpoints ep2 1000/tcp" > SELECT prdesc FROM v_port_range uuid from_port to_port unit_uuid unit_name protocol endpoint 82936455-979d-4e15-8395-6ad68005493b 1000 1000 7e7414c1-71a7-4350-89d3-081118304afc ubuntu/0 tcp ep3 2c051f61-310b-4eea-802f-c30563ee6e36 1000 1000 7e7414c1-71a7-4350-89d3-081118304afc ubuntu/0 tcp ep1 ```
- Loading branch information