From 5c2a5d31245a2e4a521f50c8f625cc30c37f72db Mon Sep 17 00:00:00 2001 From: Johannes Haass Date: Tue, 27 Feb 2024 04:32:19 +0100 Subject: [PATCH] Use `max_page` size for apps, service keys & routes (#2794) To reduce the number of db queries in cloud controller it is beneficial to use a larger page size (5k) for potentially large entities. This was already done for `marketplace` and `services` in commit b823ae53f394acf64ad7fb09f550c508a3c46e0a. This commit does the same for `apps`, `routes` and `service-keys` --- actor/v7action/application_summary.go | 1 + actor/v7action/application_summary_test.go | 2 ++ actor/v7action/route.go | 6 ++++-- actor/v7action/route_test.go | 10 ++++++++-- actor/v7action/service_key.go | 1 + actor/v7action/service_key_test.go | 1 + 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/actor/v7action/application_summary.go b/actor/v7action/application_summary.go index 7486dd525cb..d33be9dd4e9 100644 --- a/actor/v7action/application_summary.go +++ b/actor/v7action/application_summary.go @@ -40,6 +40,7 @@ func (actor Actor) GetAppSummariesForSpace(spaceGUID string, labelSelector strin keys := []ccv3.Query{ {Key: ccv3.SpaceGUIDFilter, Values: []string{spaceGUID}}, {Key: ccv3.OrderBy, Values: []string{ccv3.NameOrder}}, + {Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, } if len(labelSelector) > 0 { keys = append(keys, ccv3.Query{Key: ccv3.LabelSelectorFilter, Values: []string{labelSelector}}) diff --git a/actor/v7action/application_summary_test.go b/actor/v7action/application_summary_test.go index 5efe9ce690f..0c44df1638f 100644 --- a/actor/v7action/application_summary_test.go +++ b/actor/v7action/application_summary_test.go @@ -276,6 +276,7 @@ var _ = Describe("Application Summary Actions", func() { ccv3.Query{Key: ccv3.OrderBy, Values: []string{"name"}}, ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{"some-space-guid"}}, ccv3.Query{Key: ccv3.LabelSelectorFilter, Values: []string{"some-key=some-value"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, )) Expect(fakeCloudControllerClient.GetProcessesCallCount()).To(Equal(1)) @@ -296,6 +297,7 @@ var _ = Describe("Application Summary Actions", func() { Expect(fakeCloudControllerClient.GetApplicationsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.OrderBy, Values: []string{"name"}}, ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{"some-space-guid"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, )) }) }) diff --git a/actor/v7action/route.go b/actor/v7action/route.go index abfd349b5d8..7bccf6bdb38 100644 --- a/actor/v7action/route.go +++ b/actor/v7action/route.go @@ -84,7 +84,8 @@ func (actor Actor) GetRouteDestinationByAppGUID(route resources.Route, appGUID s func (actor Actor) GetRoutesBySpace(spaceGUID string, labelSelector string) ([]resources.Route, Warnings, error) { allWarnings := Warnings{} queries := []ccv3.Query{ - ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{spaceGUID}}, + {Key: ccv3.SpaceGUIDFilter, Values: []string{spaceGUID}}, + {Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, } if len(labelSelector) > 0 { queries = append(queries, ccv3.Query{Key: ccv3.LabelSelectorFilter, Values: []string{labelSelector}}) @@ -189,7 +190,8 @@ func (actor Actor) GetRoute(routePath string, spaceGUID string) (resources.Route func (actor Actor) GetRoutesByOrg(orgGUID string, labelSelector string) ([]resources.Route, Warnings, error) { allWarnings := Warnings{} queries := []ccv3.Query{ - ccv3.Query{Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + {Key: ccv3.OrganizationGUIDFilter, Values: []string{orgGUID}}, + {Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, } if len(labelSelector) > 0 { queries = append(queries, ccv3.Query{Key: ccv3.LabelSelectorFilter, Values: []string{labelSelector}}) diff --git a/actor/v7action/route_test.go b/actor/v7action/route_test.go index e2e06891d61..4333188be41 100644 --- a/actor/v7action/route_test.go +++ b/actor/v7action/route_test.go @@ -296,9 +296,11 @@ var _ = Describe("Route Actions", func() { Expect(fakeCloudControllerClient.GetRoutesCallCount()).To(Equal(1)) query := fakeCloudControllerClient.GetRoutesArgsForCall(0) - Expect(query).To(HaveLen(1)) + Expect(query).To(HaveLen(2)) Expect(query[0].Key).To(Equal(ccv3.SpaceGUIDFilter)) Expect(query[0].Values).To(ConsistOf("space-guid")) + Expect(query[1].Key).To(Equal(ccv3.PerPage)) + Expect(query[1].Values).To(ConsistOf(ccv3.MaxPerPage)) }) When("a label selector is provided", func() { @@ -312,6 +314,7 @@ var _ = Describe("Route Actions", func() { Expect(fakeCloudControllerClient.GetRoutesCallCount()).To(Equal(1)) expectedQuery := []ccv3.Query{ {Key: ccv3.SpaceGUIDFilter, Values: []string{"space-guid"}}, + {Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, {Key: ccv3.LabelSelectorFilter, Values: []string{"ink=blink"}}, } actualQuery := fakeCloudControllerClient.GetRoutesArgsForCall(0) @@ -631,9 +634,11 @@ var _ = Describe("Route Actions", func() { Expect(fakeCloudControllerClient.GetRoutesCallCount()).To(Equal(1)) query := fakeCloudControllerClient.GetRoutesArgsForCall(0) - Expect(query).To(HaveLen(1)) + Expect(query).To(HaveLen(2)) Expect(query[0].Key).To(Equal(ccv3.OrganizationGUIDFilter)) Expect(query[0].Values).To(ConsistOf("org-guid")) + Expect(query[1].Key).To(Equal(ccv3.PerPage)) + Expect(query[1].Values).To(ConsistOf(ccv3.MaxPerPage)) }) When("a label selector is provided", func() { @@ -647,6 +652,7 @@ var _ = Describe("Route Actions", func() { Expect(fakeCloudControllerClient.GetRoutesCallCount()).To(Equal(1)) expectedQuery := []ccv3.Query{ {Key: ccv3.OrganizationGUIDFilter, Values: []string{"org-guid"}}, + {Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, {Key: ccv3.LabelSelectorFilter, Values: []string{"env=prod"}}, } actualQuery := fakeCloudControllerClient.GetRoutesArgsForCall(0) diff --git a/actor/v7action/service_key.go b/actor/v7action/service_key.go index 79684de0a2f..7c6989000b0 100644 --- a/actor/v7action/service_key.go +++ b/actor/v7action/service_key.go @@ -62,6 +62,7 @@ func (actor Actor) GetServiceKeysByServiceInstance(serviceInstanceName, spaceGUI keys, warnings, err = actor.CloudControllerClient.GetServiceCredentialBindings( ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstance.GUID}}, ccv3.Query{Key: ccv3.TypeFilter, Values: []string{"key"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, ) return }, diff --git a/actor/v7action/service_key_test.go b/actor/v7action/service_key_test.go index 95c4ab82e9b..d34d7be8c4f 100644 --- a/actor/v7action/service_key_test.go +++ b/actor/v7action/service_key_test.go @@ -248,6 +248,7 @@ var _ = Describe("Service Key Action", func() { Expect(fakeCloudControllerClient.GetServiceCredentialBindingsArgsForCall(0)).To(ConsistOf( ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstanceGUID}}, ccv3.Query{Key: ccv3.TypeFilter, Values: []string{"key"}}, + ccv3.Query{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}, )) })