Skip to content

HAProxy spams logs with pydantic validation error #379

@SK1Y101

Description

@SK1Y101

Bug Description

Again using the new MAAS spike from canonical/maas-charms#571

Adding the HAProxy relation spams the debug log with pydantic validation errors on the port, before the relation has fully spun up and provided data, even though the port is provided in the MAAS charm at all staged of the relation.

I suspect HAProxy is too enthusiastic, and trying to configure before everything is ready.

Impact

Low (minor issue or cosmetic problem)

Impact Rationale

No response

To Reproduce

deploy both charms such that the relation exists
juju deploy haproxy --channel=2.8/edge
juju deploy maas-region --channel=latest/edge/haproxy-relation

Integrate both relations with haproxy
juju integrate maas-region:ingress-tcp haproxy:haproxy-route-tcp

Watch the logs as the charm relation is added and data transferred.

Environment

Environment deployed according to https://github.com/canonical/maas-terraform-modules

(Local juju, 3.6.3, with lxd vms, MAAS and HAProxy on the deployed channels as in the reproducer steps)

Relevant log output

unit-haproxy-0: 14:50:35 ERROR unit.haproxy/0.juju-log haproxy-route-tcp:8: 1 validation error for TcpRequirerApplicationData
port
  Field required [type=missing, input_value={}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/missing
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-haproxy-0/charm/lib/charms/haproxy/v1/haproxy_route_tcp.py", line 297, in load
    return cls.model_validate_json(json.dumps(data))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/lib/juju/agents/unit-haproxy-0/charm/venv/lib/python3.12/site-packages/pydantic/main.py", line 766, in model_validate_json
    return cls.__pydantic_validator__.validate_json(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for TcpRequirerApplicationData
port
  Field required [type=missing, input_value={}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/missing
unit-haproxy-0: 14:50:35 ERROR unit.haproxy/0.juju-log haproxy-route-tcp:8: Invalid requirer application data for maas-region

Additional context

MAAS defines the route as:

        self.haproxy_non_tls_route = HaproxyRouteTcpRequirer(
            self,
            HAPROXY_NON_TLS,
            port=80,
            backend_port=MAAS_HTTP_PORT,
            **COMMON_DEFAULT_HAPROXY_ARGS,
        )

and uses it with:

            self.haproxy_non_tls_route.provide_haproxy_route_tcp_requirements(
                port=80, hosts=self.maas_ips, **COMMON_DEFAULT_HAPROXY_ARGS
            )

At no point on the MAAS side is the port not provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions