Skip to content

Commit

Permalink
Merge branch 'master' into simplifyUID
Browse files Browse the repository at this point in the history
  • Loading branch information
lahabana authored Oct 5, 2023
2 parents 242409b + 671b992 commit ac111ef
Show file tree
Hide file tree
Showing 140 changed files with 1,811 additions and 464 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/update-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
path: repo
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
go-version-file: repo/go.mod
- name: "sync docs" # loop over all the branches and generate the docs
run: |
cd repo
Expand Down
11 changes: 11 additions & 0 deletions api/system/v1alpha1/zone_insight_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ func (x *ZoneInsight) UpdateSubscription(s generic.Subscription) error {
return nil
}

// CompactFinished removes detailed information about finished subscriptions to trim the object size
// The last subscription always has details.
func (x *ZoneInsight) CompactFinished() {
for i := 0; i < len(x.GetSubscriptions())-1; i++ {
x.Subscriptions[i].Config = ""
if status := x.Subscriptions[i].Status; status != nil {
status.Stat = map[string]*KDSServiceStats{}
}
}
}

// 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.
Expand Down
58 changes: 56 additions & 2 deletions api/system/v1alpha1/zone_insight_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
)

var _ = Describe("Zone Insights", func() {
Context("UpdateSubscription", func() {
t1, _ := time.Parse(time.RFC3339, "2018-07-17T16:05:36.995+00:00")
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{
Expand Down Expand Up @@ -66,4 +66,58 @@ var _ = Describe("Zone Insights", func() {
Expect(err.Error()).To(Equal("invalid type *v1alpha1.DiscoverySubscription for ZoneInsight"))
})
})

It("should compact finished subscriptions", 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)),
Config: "a",
Status: &system_proto.KDSSubscriptionStatus{
LastUpdateTime: util_proto.MustTimestampProto(t1),
Total: &system_proto.KDSServiceStats{
ResponsesSent: 1,
ResponsesAcknowledged: 1,
},
Stat: map[string]*system_proto.KDSServiceStats{
"TrafficRoute": {
ResponsesSent: 1,
ResponsesAcknowledged: 1,
},
},
},
},
{
Id: "2",
ConnectTime: util_proto.MustTimestampProto(t1.Add(2 * time.Hour)),
Config: "b",
Status: &system_proto.KDSSubscriptionStatus{
LastUpdateTime: util_proto.MustTimestampProto(t1),
Total: &system_proto.KDSServiceStats{
ResponsesSent: 1,
ResponsesAcknowledged: 1,
},
Stat: map[string]*system_proto.KDSServiceStats{
"TrafficRoute": {
ResponsesSent: 1,
ResponsesAcknowledged: 1,
},
},
},
},
},
}

// when
zoneInsight.CompactFinished()

// then
Expect(zoneInsight.Subscriptions[0].Config).To(Equal(""))
Expect(zoneInsight.Subscriptions[0].Status.Stat).To(BeEmpty())
Expect(zoneInsight.Subscriptions[1].Config).To(Equal("b"))
Expect(zoneInsight.Subscriptions[1].Status.Stat).NotTo(BeEmpty())
})
})

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import{d as s,o as n,j as r,h as o,w as e,V as c,l as a,i as t,U as i,W as _,m as l}from"./index-65a641bf.js";const m={class:"overview"},p=l("p",null,"Page Not Found",-1),x=s({__name:"AppNotFoundView",setup(d){return(u,f)=>(n(),r("div",m,[o(t(_),null,{title:e(()=>[o(c,{class:"mb-3"}),a(),p]),message:e(()=>[a(`
import{d as s,o as n,j as r,h as o,w as e,V as c,l as a,i as t,U as i,W as _,m as l}from"./index-a63a3d32.js";const m={class:"overview"},p=l("p",null,"Page Not Found",-1),x=s({__name:"AppNotFoundView",setup(d){return(u,f)=>(n(),r("div",m,[o(t(_),null,{title:e(()=>[o(c,{class:"mb-3"}),a(),p]),message:e(()=>[a(`
The page or entity you were looking for does not exist.
`)]),cta:e(()=>[o(t(i),{appearance:"primary",to:{name:"home"}},{default:e(()=>[a(`
Go Home
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ac111ef

Please sign in to comment.