From 7e153975b9b1fc9043fff3808f51bf7cbe6c05d8 Mon Sep 17 00:00:00 2001 From: Mike Beaumont Date: Fri, 27 Oct 2023 12:51:09 +0200 Subject: [PATCH] fix: don't mark all previou zoneinsight subs disconnected Signed-off-by: Mike Beaumont --- api/system/v1alpha1/zone_insight_helpers.go | 14 ---------- .../v1alpha1/zone_insight_helpers_test.go | 27 ------------------- 2 files changed, 41 deletions(-) diff --git a/api/system/v1alpha1/zone_insight_helpers.go b/api/system/v1alpha1/zone_insight_helpers.go index e60f15a9a314..5f2eb36c6c5f 100644 --- a/api/system/v1alpha1/zone_insight_helpers.go +++ b/api/system/v1alpha1/zone_insight_helpers.go @@ -7,7 +7,6 @@ import ( timestamppb "google.golang.org/protobuf/types/known/timestamppb" "github.com/kumahq/kuma/api/generic" - util_proto "github.com/kumahq/kuma/pkg/util/proto" ) var _ generic.Insight = &ZoneInsight{} @@ -78,7 +77,6 @@ func (x *ZoneInsight) UpdateSubscription(s generic.Subscription) error { return nil } } - x.finalizeSubscriptions() x.Subscriptions = append(x.Subscriptions, kdsSubscription) return nil } @@ -94,18 +92,6 @@ func (x *ZoneInsight) CompactFinished() { } } -// If Global CP was killed ungracefully then we can get a subscription without a DisconnectTime. -// Because of the way we process subscriptions the lack of DisconnectTime on old subscription -// will cause wrong status. -func (x *ZoneInsight) finalizeSubscriptions() { - now := util_proto.Now() - for _, subscription := range x.GetSubscriptions() { - if subscription.DisconnectTime == nil { - subscription.DisconnectTime = now - } - } -} - func NewVersion() *Version { return &Version{ KumaCp: &KumaCpVersion{ diff --git a/api/system/v1alpha1/zone_insight_helpers_test.go b/api/system/v1alpha1/zone_insight_helpers_test.go index 594bd0093bd3..ff88211f952d 100644 --- a/api/system/v1alpha1/zone_insight_helpers_test.go +++ b/api/system/v1alpha1/zone_insight_helpers_test.go @@ -15,33 +15,6 @@ var _ = Describe("Zone Insights", func() { t1, _ := time.Parse(time.RFC3339, "2018-07-17T16:05:36.995+00:00") Context("UpdateSubscription", func() { - It("should leave subscriptions in a valid state", func() { - // given - zoneInsight := &system_proto.ZoneInsight{ - Subscriptions: []*system_proto.KDSSubscription{ - { - Id: "1", - ConnectTime: util_proto.MustTimestampProto(t1), - DisconnectTime: util_proto.MustTimestampProto(t1.Add(1 * time.Hour)), - }, - { - Id: "2", - ConnectTime: util_proto.MustTimestampProto(t1.Add(2 * time.Hour)), - }, - }, - } - - // when - Expect(zoneInsight.UpdateSubscription(&system_proto.KDSSubscription{ - Id: "3", - ConnectTime: util_proto.MustTimestampProto(t1.Add(3 * time.Hour)), - })).To(Succeed()) - - // then - subscription := zoneInsight.GetSubscription("2") - Expect(subscription.(*system_proto.KDSSubscription).DisconnectTime).ToNot(BeNil()) - }) - It("should return error for wrong subscription type", func() { // given zoneInsight := &system_proto.ZoneInsight{