diff --git a/README.md b/README.md index ceb0468..d459897 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,12 @@ example.com { The plugin responds to the following Incus events: -* `api.EventLifecycleInstanceStarted` +* `api.EventLifecycleInstanceCreated` * `api.EventLifecycleInstanceRestarted` +* `api.EventLifecycleInstanceResumed` +* `api.EventLifecycleInstanceStarted` -It currently *only* retrieves the ipv4 addresses of the instances. +It currently *only* matches against the upstream ipv4 addresses of instances. ## Hackin' diff --git a/upstreams.go b/upstreams.go index 74db687..4c17f3c 100644 --- a/upstreams.go +++ b/upstreams.go @@ -187,6 +187,13 @@ func (u *Upstreams) provisionCandidates(ctx caddy.Context, conn incus.InstanceSe ) address := net.JoinHostPort(addr, port) + + ctx.Logger().Info("new candidate provisioned", + zap.String("instance_name", i.Name), + zap.String("address", address), + zap.Any("matchers", matchers), + ) + updated = append(updated, candidate{ matchers: matchers, upstream: &reverseproxy.Upstream{Dial: address}, @@ -213,8 +220,11 @@ func (u *Upstreams) keepUpdated(ctx caddy.Context, conn incus.InstanceServer) { ctx.Logger().Debug("initialised event listener") events := []string{ - api.EventLifecycleInstanceStarted, + api.EventLifecycleInstanceCreated, + api.EventLifecycleInstanceReady, api.EventLifecycleInstanceRestarted, + api.EventLifecycleInstanceResumed, + api.EventLifecycleInstanceStarted, } if _, err := listener.AddHandler([]string{"lifecycle"}, func(event api.Event) { @@ -228,6 +238,9 @@ func (u *Upstreams) keepUpdated(ctx caddy.Context, conn incus.InstanceServer) { return } + // NOTE(d1): ensure network comes up + time.Sleep(3 * time.Second) + ctx.Logger().Debug("handling event", zap.String("instance_name", metadata.Name), zap.String("event", metadata.Action),