Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imagebuilder command cannot receive all images #8980

Open
1 task
jaypan13 opened this issue Oct 16, 2024 · 2 comments
Open
1 task

Imagebuilder command cannot receive all images #8980

jaypan13 opened this issue Oct 16, 2024 · 2 comments
Assignees
Labels
bug This issue is a bug. ec2 p2 This is a standard priority issue service-api This issue is due to a problem in a service API, not the SDK implementation.

Comments

@jaypan13
Copy link

Describe the bug

aws imagebuilder list-images command always returns nextToken causing it to not get all images from ec2 image builder.

image

I found that it is getting stopped after 25 results and then it sends back nextToken no matter what option I use. So, I tried to filter it with --query like below

aws imagebuilder list-images --query "imageVersionList[?version=='2024.10.15']" --output table

and even though I have less than 20 images with that version, it showed only 3 images in the result.
Next I tried using --filters option and it still returned only 3 results with nextToken

aws imagebuilder list-images --filters "name=version,values='2024.10.15'" | jq -r '.nextToken' | cut -c1-4

In summary, I used all options and still cannot return my version = 2024.10.15 images in cli.

P.S. Just a suggestion – the global --no-paginate option could really benefit from a different name. Many people assume that using this option means pagination is disabled and that all results will be returned in one go. Although

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

It should return 20 images

Current Behavior

I tried all options and still cannot return my version = 2024.10.15 images when using aws cli.

Reproduction Steps

  1. Create 20 image builder pipelines
  2. Create images using those pipelines (Probably you need to create more images so the count gets more than 25 - I cannot test this unfortunately and I have more than 100 images generated with different versions)
  3. Using aws cli, try to get all 20 images with specific version.

Possible Solution

No response

Additional Information/Context

No response

CLI version used

aws-cli/2.17.13 Python/3.11.9 Linux/5.15.153.1-microsoft-standard-WSL2 exe/x86_64.ubuntu.22

Environment details (OS name and version, etc.)

Ubuntu in wsl

@jaypan13 jaypan13 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 16, 2024
@tim-finnigan tim-finnigan self-assigned this Oct 17, 2024
@tim-finnigan tim-finnigan added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Oct 17, 2024
@tim-finnigan
Copy link
Contributor

Thanks for reaching out. Here is a link to the documentation for that command: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/imagebuilder/list-images.html. There is actually a limitation here with the underlying ListImages API, where it will only return up to 25 results at a time. The --query parameter is for client-side filtering, so that won't be able to filter on anything not returned by the API.

You can try setting the --by-name boolean parameter for filtering by name, for example:

aws imagebuilder list-images  --by-name  --filters "name=name,values=test-recipe"

Another option you could try using is a boto3 script like this to fetch all of the results:

import boto3

list = []
client = boto3.client('imagebuilder')

response = client.list_images(filters=[
    {'name': 'name', 'values': ['test-recipe']}])
list.append(response['imageVersionList'])

while 'nextToken' in response:
    response = client.list_images(filters=[
        {'name': 'name', 'values': ['test-recipe']}], nextToken=response['nextToken'])
    list.append(response['imageVersionList'])

print(list)

Upon searching internally I founder there was a previous issue related to this filtering behavior. I think the EC2 Image Builder team was planning improvements to this — I'm not sure if there are any updates on that but will try following up with them.

@tim-finnigan tim-finnigan added ec2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. service-api This issue is due to a problem in a service API, not the SDK implementation. p2 This is a standard priority issue and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. needs-triage This issue or PR still needs to be triaged. labels Oct 17, 2024
@jaypan13
Copy link
Author

Thank you for boto script. I used bash to do similar kind of task.

I cannot use --by-name as image name contains some string that I need to look for and it is not exact match.

I understand that issue relies with underlying API returning back 25 results. But even though I have less than 25 results on the server, filters command is not returning back all the results at the same time. I assume --filters is happening on the server side unlike --query, which is happening at client side as you mentioned. I tried below query too.

aws imagebuilder list-images --filters "name=version,values='2024.10.15'" --max-results 25

Not sure if that other issue you mentioned in your comment is related with the same thing that I mentioned above, but just putting it here for later knowledge.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. ec2 p2 This is a standard priority issue service-api This issue is due to a problem in a service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

2 participants