Skip to content

AMI status check wait issue #250

Closed
Closed

Description

@suresh-kumarp
SUMMARY

We are using CodeBuild service to build our product. In that process, we are using Ansible module to create an AMI image from AppServer instance. Since the AMI creation taking more time the AMI status check API request getting expire after 15 minutes.

ISSUE TYPE
COMPONENT NAME

/root/.pyenv/versions/3.8.3/lib/python3.8/site-packages/ansible_collections/amazon/aws/plugins/modules/ec2_ami.py

ANSIBLE VERSION

ansible 2.10.5
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /root/.pyenv/versions/3.8.3/lib/python3.8/site-packages/ansible
executable location = /root/.pyenv/versions/3.8.3/bin/ansible
python version = 3.8.3


##### CONFIGURATION


##### OS / ENVIRONMENT
Linux(Ubuntu 18.04.5 LTS)


##### STEPS TO REPRODUCE
If the AMI creation steps taking more than 15 mins this error occurs.


##### EXPECTED RESULTS
It should wait until the AMI gets created and once the AMI status is available then it should proceed further.


##### ACTUAL RESULTS
TASK [Create AMI snapshot of app host] *****************************************
task path: /make_ami/ansible/snapshot-ec2-ami.yml:36
redirecting (type: modules) ansible.builtin.ec2_ami to amazon.aws.ec2_ami
Using module file /root/.pyenv/versions/3.8.3/lib/python3.8/site-packages/ansible_collections/amazon/aws/plugins/modules/ec2_ami.py
Pipelining is enabled.
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '/root/.pyenv/versions/3.8.3/bin/python && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "<stdin>", line 102, in <module>
  File "<stdin>", line 94, in _ansiballz_main
  File "<stdin>", line 40, in invoke_module
  File "/root/.pyenv/versions/3.8.3/lib/python3.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/root/.pyenv/versions/3.8.3/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/root/.pyenv/versions/3.8.3/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_ec2_ami_payload_qno0haa5/ansible_ec2_ami_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_ami.py", line 761, in <module>
  File "/tmp/ansible_ec2_ami_payload_qno0haa5/ansible_ec2_ami_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_ami.py", line 757, in main
  File "/tmp/ansible_ec2_ami_payload_qno0haa5/ansible_ec2_ami_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_ami.py", line 511, in create_image
  File "/root/.pyenv/versions/3.8.3/lib/python3.8/site-packages/botocore/waiter.py", line 310, in wait
    raise WaiterError(
botocore.exceptions.WaiterError: Waiter image_available failed: Request has expired.
fatal: [localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"<stdin>\", line 102, in <module>\n  File \"<stdin>\", line 94, in _ansiballz_main\n  File \"<stdin>\", line 40, in invoke_module\n  File \"/root/.pyenv/versions/3.8.3/lib/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/root/.pyenv/versions/3.8.3/lib/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/root/.pyenv/versions/3.8.3/lib/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_ec2_ami_payload_qno0haa5/ansible_ec2_ami_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_ami.py\", line 761, in <module>\n  File \"/tmp/ansible_ec2_ami_payload_qno0haa5/ansible_ec2_ami_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_ami.py\", line 757, in main\n  File \"/tmp/ansible_ec2_ami_payload_qno0haa5/ansible_ec2_ami_payload.zip/ansible_collections/amazon/aws/plugins/modules/ec2_ami.py\", line 511, in create_image\n  File \"/root/.pyenv/versions/3.8.3/lib/python3.8/site-packages/botocore/waiter.py\", line 310, in wait\n    raise WaiterError(\nbotocore.exceptions.WaiterError: Waiter image_available failed: Request has expired.\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Activity

  1. ansibullbot commented on Jan 27, 2021

    @ansibullbot

    Files identified in the description:

    If these files are inaccurate, please update the component name section of the description or use the !component bot command.

    click here for bot help

  2. gravesm commented on Jan 29, 2021

    @gravesm
    Member

    @sureshkumarp0 Could you confirm if you are using a wait_timeout in your task, and if so, how long?

  3. tremble commented on May 5, 2021

    @tremble
    Contributor

    A quick search using Google seems to imply that the most common cause of this error is expired session tokens. The alternative would be the botocore waiter code not updating the timestamp on the requests it makes, and would be a bug in botocore, not this module.

    See for example hashicorp/packer#8299

    Since neither of these scenarios are something we can/should realistically handle, and we've heard nothing from you since January I'm going to close this issue.

  4. added 2 commits that reference this issue on Sep 18, 2023
    0e1b283
    3c58ff9
  5. added a commit that references this issue on Oct 24, 2023
    88f5d0c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions