Skip to content

Commit

Permalink
fix(ZoneWatch): stop watching Zone if ZoneInsight not found (#8766)
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <[email protected]>
  • Loading branch information
michaelbeaumont authored Jan 9, 2024
1 parent f0fff41 commit 3eea93b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
17 changes: 7 additions & 10 deletions pkg/kds/mux/zone_watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,14 @@ func (zw *ZoneWatch) Start(stop <-chan struct{}) error {
log := kuma_log.AddFieldsFromCtx(zw.log, ctx, zw.extensions)
if err := zw.rm.Get(ctx, zoneInsight, store.GetByKey(zone.zone, model.NoMesh)); err != nil {
if store.IsResourceNotFound(err) {
zoneRes := system.NewZoneResource()
if err := zw.rm.Get(ctx, zoneRes, store.GetByKey(zone.zone, model.NoMesh)); err != nil && store.IsResourceNotFound(err) {
zw.bus.Send(service.ZoneWentOffline{
Zone: zone.zone,
TenantID: zone.tenantID,
})
delete(zw.zones, zone)
continue
}
zw.bus.Send(service.ZoneWentOffline{
Zone: zone.zone,
TenantID: zone.tenantID,
})
delete(zw.zones, zone)
} else {
log.Info("error getting ZoneInsight", "zone", zone.zone, "error", err)
}
log.Info("error getting ZoneInsight", "zone", zone.zone, "error", err)
continue
}

Expand Down
10 changes: 9 additions & 1 deletion pkg/kds/mux/zone_watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"

system_proto "github.com/kumahq/kuma/api/system/v1alpha1"
"github.com/kumahq/kuma/pkg/config/multizone"
Expand Down Expand Up @@ -65,11 +66,18 @@ var _ = Describe("ZoneWatch", func() {
Timeout: types.Duration{Duration: timeout},
}

rm = manager.NewResourceManager(memory.NewStore())
zoneRes := system.NewZoneResource()
zoneRes.Spec.Enabled = wrapperspb.Bool(true)
Expect(rm.Create(
context.Background(),
zoneRes,
store.CreateByKey(zone, core_model.NoMesh),
)).To(Succeed())
zoneInsight := system.NewZoneInsightResource()
zoneInsight.Spec.HealthCheck = &system_proto.HealthCheck{
Time: timestamppb.New(time.Now()),
}
rm = manager.NewResourceManager(memory.NewStore())
Expect(rm.Create(
context.Background(),
zoneInsight,
Expand Down

0 comments on commit 3eea93b

Please sign in to comment.