bad service_port if service_host is not specified in the relation data

Bug #1745973 reported by Junien Fridrick
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
charm-haproxy
Triaged
High
Unassigned

Bug Description

Hi,

If you set the "services" config option to the empty string, and send the following as reverseproxy relation data in "services" :

  - { service_name: foo,
      service_options: [mode http, balance leastconn],
      service_port: 8080
      servers: [[foo bar_0, 10.0.0.1, 8080, 'check port 8080']] }

then haproxy will bind the port 10002 for this service.

The reason is that there is a bug in the ensure_service_host_port() function :

 562 def ensure_service_host_port(services):
 563 config_data = config_get()
 564 seen = []
 565 missing = []
 566 for service, options in sorted(services.iteritems()):
 567 if "service_host" not in options:
 568 missing.append(options)
 569 continue
 570 if "service_port" not in options:
 571 missing.append(options)
 572 continue
 573 seen.append((options["service_host"], int(options["service_port"])))
 574
 575 seen.sort()
 576 last_port = seen and seen[-1][1] or int(config_data["monitoring_port"])
 577 for options in missing:
 578 last_port += 2
 579 options["service_host"] = "0.0.0.0"
 580 options["service_port"] = last_port
 581
 582 return services

Here, we have a single "missing" option (service_host), but as you can see in the last "for" loop, the service_port is overriden even if only service_host is missing.

And since, for unknown reason, last_port is set to the default monitoring_port of 10000, the service_port ends up being 10002.

Junien Fridrick (axino)
summary: - bad service_port is service_host is not specified in the relation data
+ bad service_port if service_host is not specified in the relation data
Changed in charm-haproxy:
importance: Undecided → High
status: New → Triaged
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.