bad service_port if service_host is not specified in the relation data
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_
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_
562 def ensure_
563 config_data = config_get()
564 seen = []
565 missing = []
566 for service, options in sorted(
567 if "service_host" not in options:
568 missing.
569 continue
570 if "service_port" not in options:
571 missing.
572 continue
573 seen.append(
574
575 seen.sort()
576 last_port = seen and seen[-1][1] or int(config_
577 for options in missing:
578 last_port += 2
579 options[
580 options[
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.
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 |