Skip to content

Set images.list maxResults to 10k and make it configurable - default was 500#548

Open
gbhat618 wants to merge 3 commits into
jenkinsci:developfrom
gbhat618:fix-too-many-source-image-bug
Open

Set images.list maxResults to 10k and make it configurable - default was 500#548
gbhat618 wants to merge 3 commits into
jenkinsci:developfrom
gbhat618:fix-too-many-source-image-bug

Conversation

@gbhat618
Copy link
Copy Markdown
Contributor

@gbhat618 gbhat618 commented May 8, 2026

Whenever a GCP project had more than 500 images, the list was truncated to 500 - due to GCP server side default is 500.
https://docs.cloud.google.com/compute/docs/reference/rest/v1/images/list#query-parameters

The maximum number of results per page that should be returned. If the number of available results is larger than maxResults, Compute Engine returns a nextPageToken that can be used to get the next page of results in subsequent list requests. Acceptable values are 0 to 500, inclusive. (Default: 500)

This PR fixes by - setMaxResults to higher value (Integer.MAX_VALUE) when images().list()

Testing

Reproduced the issue, with a project having 828 images.

Before After
Log line: 2026-05-08 08:35:29.516+0000 [id=97] INFO c.g.j.p.c.InstanceConfiguration$DescriptorImpl#doFillBootDiskSourceImageNameItems: listImages() returned 500 images for project tiger-team-testing Log line: 2026-05-08 08:32:21.842+0000 [id=144] INFO c.g.j.p.c.InstanceConfiguration$DescriptorImpl#doFillBootDiskSourceImageNameItems: listImages(maxResults=2147483647) returned 828 images for project tiger-team-testing
only up to 500 images image no missing images even beyond 500image
  • manual build running in jenkins works ✔️
  • ran a couple of integration tests, works ✔️

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

/**
* Lists images in {@code imageProject} with an explicit {@code maxResults}, bypassing the
* archived gcp-plugin-core-java {@code ComputeClient#listImages} which silently truncates
* at the server default of 500.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gbhat618
Copy link
Copy Markdown
Contributor Author

gbhat618 commented May 8, 2026

/label bug

@jtnord jtnord added the bug Something isn't working label May 11, 2026
Comment thread src/main/java/com/google/jenkins/plugins/computeengine/InstanceConfiguration.java Outdated
public List<Image> listImages(String imageProject, long maxResults) throws IOException {
var resp = compute.images().list(imageProject).setMaxResults(maxResults).execute();
List<Image> items = resp.getItems();
return items == null ? Collections.emptyList() : items;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this ever return null?!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/main/java/com/google/jenkins/plugins/computeengine/InstanceConfiguration.java Outdated
@gbhat618 gbhat618 changed the title images.list with maxResults to Integer.MAX_VALUE Set images.list maxResults to 10k and make it configurable - default was 500 May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants