Skip to content

Commit

Permalink
fix: don't mark all previou zoneinsight subs disconnected
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <[email protected]>
  • Loading branch information
michaelbeaumont committed Oct 27, 2023
1 parent cf9173c commit 7e15397
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
14 changes: 0 additions & 14 deletions api/system/v1alpha1/zone_insight_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -78,7 +77,6 @@ func (x *ZoneInsight) UpdateSubscription(s generic.Subscription) error {
return nil
}
}
x.finalizeSubscriptions()
x.Subscriptions = append(x.Subscriptions, kdsSubscription)
return nil
}
Expand All @@ -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{
Expand Down
27 changes: 0 additions & 27 deletions api/system/v1alpha1/zone_insight_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 7e15397

Please sign in to comment.