open_port call should not fail if port is already open by another unit

Bug #1792939 reported by Andrey Pavlov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
charm-haproxy
New
Undecided
Unassigned

Bug Description

Application can independently call open_port and pass configuration to haproxy charm.
in this case haproxy will generate an error:

2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed Configuration file is valid
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed ERROR cannot open 8081/tcp (unit "haproxy/2"): conflicts with existing 8081/tcp (unit "contrail-analytics/2")
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed Traceback (most recent call last):
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed File "/var/lib/juju/agents/unit-haproxy-2/charm/hooks/reverseproxy-relation-changed", line 1368, in <module>
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed main(hook_name)
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed File "/var/lib/juju/agents/unit-haproxy-2/charm/hooks/reverseproxy-relation-changed", line 1338, in main
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed reverseproxy_interface("changed")
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed File "/var/lib/juju/agents/unit-haproxy-2/charm/hooks/reverseproxy-relation-changed", line 1003, in reverseproxy_interface
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed config_changed()
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed File "/var/lib/juju/agents/unit-haproxy-2/charm/hooks/reverseproxy-relation-changed", line 961, in config_changed
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed update_service_ports(old_service_ports, get_service_ports())
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed File "/var/lib/juju/agents/unit-haproxy-2/charm/hooks/reverseproxy-relation-changed", line 274, in update_service_ports
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed open_port(port)
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed File "/var/lib/juju/agents/unit-haproxy-2/charm/hooks/charmhelpers/core/hookenv.py", line 609, in open_port
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed subprocess.check_call(_args)
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed raise CalledProcessError(retcode, cmd)
2018-09-17 12:56:58 DEBUG reverseproxy-relation-changed subprocess.CalledProcessError: Command '['open-port', '8081/TCP']' returned non-zero exit status 1
2018-09-17 12:56:58 ERROR juju.worker.uniter.operation runhook.go:113 hook "reverseproxy-relation-changed" failed: exit status 1

in multinode configuration application 'A' and haproxy units on the same node can receive info at different time.

working solution:
1. application 'A' receive info with VIP and call close_port
2. haproxy receive services configuration and call open_port

non-working solution:
1. haproxy receive services configuration and call open_port
2. application 'A' receive info with VIP and call close_port
at step 1 exception is raised...

Revision history for this message
Junien Fridrick (axino) wrote :

Is this a case where application 'A' is listening on port 8081, but then you add HA, and so haproxy becomes the one to listen on port 8081 ?

Changed in charm-haproxy:
status: New → Incomplete
Revision history for this message
Andrey Pavlov (apavlov-e) wrote :

@Junien,
haproxy should be the one. but there is a race when application receives event and closes port AFTER haproxy will try to open the same port.

Changed in charm-haproxy:
status: Incomplete → New
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.