Comment 1 for bug 1924780

Revision history for this message
Ian Booth (wallyworld) wrote : Re: easyrsa install hook fails on public address not found

The easyrsa unit looks to be running on machine 1.
Logs from machine 1 show the machine agent starting. One of the things that happens is that the IP addresses of the machine are recorded. This is done via a call to Go's net.InterfaceAddrs() API. The logs show this:

2021-04-15 17:22:33 DEBUG juju.worker.dependency engine.go:564 "machiner" manifold worker started at 2021-04-15 17:22:33.977186529 +0000 UTC
2021-04-15 17:22:33 DEBUG juju.network network.go:142 no lxc bridge addresses to filter for machine
2021-04-15 17:22:33 DEBUG juju.network network.go:178 cannot get "lxdbr0" addresses: route ip+net: no such network interface (ignoring)
2021-04-15 17:22:33 DEBUG juju.network network.go:178 cannot get "virbr0" addresses: route ip+net: no such network interface (ignoring)
2021-04-15 17:22:33 DEBUG juju.network network.go:127 including address local-machine:127.0.0.1 for machine
2021-04-15 17:22:33 DEBUG juju.network network.go:127 including address local-cloud:172.31.43.239 for machine
2021-04-15 17:22:33 DEBUG juju.network network.go:127 including address local-fan:252.43.239.1 for machine
2021-04-15 17:22:33 DEBUG juju.network network.go:127 including address local-machine:::1 for machine
2021-04-15 17:22:33 DEBUG juju.network network.go:196 addresses after filtering: [local-machine:127.0.0.1 local-cloud:172.31.43.239 local-fan:252.43.239.1 local-machine:::1]
2021-04-15 17:22:33 INFO juju.worker.machiner machiner.go:162 setting addresses for "machine-1" to [local-machine:127.0.0.1 local-cloud:172.31.43.239 local-fan:252.43.239.1 local-machine:::1]
2021-04-15 17:22:34 INFO juju.worker.machiner machiner.go:112 "machine-1" started

There's no public IP address reported initially on startup. Compare this to machine 0, the controller, where these addresses are known when these logs were recorded:

2021-04-15 17:22:32 DEBUG juju.network network.go:127 including address public:34.239.49.54 for machine
2021-04-15 17:22:32 DEBUG juju.network network.go:127 including address local-cloud:172.31.39.150 for machine
2021-04-15 17:22:32 DEBUG juju.network network.go:127 including address local-fan:252.39.150.1 for machine
2021-04-15 17:22:32 DEBUG juju.network network.go:127 including address local-machine:127.0.0.1 for machine
2021-04-15 17:22:32 DEBUG juju.network network.go:127 including address local-machine:::1 for machine

Note the 34.* public address.

Juju does periodically update the machine addresses if they change. But it appears no public IP address becomes known prior to the easyrsa unit asking for the public address, hence the install hook error reporting that such an address is not found.

The fact that status has the public address means that it became available at some short time later, after the charm had initially asked for it. Charms need to be resilient to such scenarios. Juju will fire a config-changed hook when the host machine of a charm gets updated addresses. The charm needs to wait until the public address is available. Also, the charm should be using network-get and not unit-get pubic-address which is deprecated.