Skip to content

Commit 282d309

Browse files
committed
Limit API listing to 200 at a time via pagination
Control how many objects (`metal3data`,`metal3datatemplate`, `metal3machine`, `metal3machinetemplate`) should be retrieved per list call (200). This should in theory reduce the load on the API server's memory consumption, especially when there is a large number of objects with large amount of data on them. Signed-off-by: Feruzjon Muyassarov <[email protected]>
1 parent c5dc02e commit 282d309

File tree

5 files changed

+5
-1
lines changed

5 files changed

+5
-1
lines changed

baremetal/metal3data_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ func fetchM3IPClaim(ctx context.Context, cl client.Client, mLog logr.Logger,
14981498
func (m *DataManager) fetchIPClaimsWithLabels(ctx context.Context, pool string) ([]ipamv1.IPClaim, error) {
14991499
allIPClaims := ipamv1.IPClaimList{}
15001500
opts := []client.ListOption{
1501-
&client.ListOptions{Namespace: m.Data.Namespace},
1501+
&client.ListOptions{Namespace: m.Data.Namespace, Limit: DefaultListLimit},
15021502
client.MatchingLabels{
15031503
DataLabelName: m.Data.Name,
15041504
PoolLabelName: pool,

baremetal/metal3datatemplate_manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ func (m *DataTemplateManager) UpdateDatas(ctx context.Context) (bool, bool, erro
158158
// without this ListOption, all namespaces would be including in the listing
159159
opts := &client.ListOptions{
160160
Namespace: m.DataTemplate.Namespace,
161+
Limit: DefaultListLimit,
161162
}
162163

163164
err = m.client.List(ctx, &dataClaimObjects, opts)

baremetal/metal3machine_manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ func (m *MachineManager) chooseHost(ctx context.Context) (*bmov1alpha1.BareMetal
797797
// without this ListOption, all namespaces would be including in the listing.
798798
opts := &client.ListOptions{
799799
Namespace: m.Metal3Machine.Namespace,
800+
Limit: DefaultListLimit,
800801
}
801802

802803
err := m.client.List(ctx, &hosts, opts)

baremetal/metal3machinetemplate_manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func (m *MachineTemplateManager) UpdateAutomatedCleaningMode(ctx context.Context
6868
// without this ListOption, all namespaces would be included in the listing
6969
opts := &client.ListOptions{
7070
Namespace: m.Metal3MachineTemplate.Namespace,
71+
Limit: DefaultListLimit,
7172
}
7273

7374
if err := m.client.List(ctx, m3ms, opts); err != nil {

baremetal/utils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const (
4242
metal3MachineKind = "Metal3Machine"
4343
VerbosityLevelDebug = 4
4444
VerbosityLevelTrace = 5
45+
DefaultListLimit = 200
4546
)
4647

4748
// Contains returns true if a list contains a string.

0 commit comments

Comments
 (0)