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

Add asg refresh and info modules #487

Conversation

danquixote
Copy link

SUMMARY

Resubmitting rebased-PR after initial review on #425 by @tremble .
Overview:
Adding the ec2_asg_instance_refresh and related *_info module. These modules are intended to be used together to start or cancel an EC2 AutoScaling Group (ASG) instance refresh, and then track the subsequent progress with the provided InstanceRefreshId. The *_info module can also be used to get multiple pages of refresh history using the NextToken.
Fixes #425

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

ec2_asg_instance_refresh
ec2_asg_instance_refreshes_info

ADDITIONAL INFORMATION

{
           'instance_refresh_id': 'string'
 }


 {
            'instance_refreshes': [
                    {
                        'instance_refresh_id': '6507a3e5-4950-4503-8978-e9f2636efc09',
                        'auto_scaling_group_name': 'ansible-test-hermes-63642726-asg',
                        'status': 'Cancelled',
                        'status_reason': 'Cancelled due to user request.',
                        'start_time': '2021-02-04T03:39:40+00:00',
                        'end_time': '2021-02-04T03:41:18+00:00',
                        'percentage_complete': 0,
                        'instances_to_update': 1
                    }
            ],
            'next_token': 'string'
        }


@ansibullbot
Copy link

@ansibullbot ansibullbot added community_review integration tests/integration module module needs_triage new_contributor Help guide this first time contributor new_module New module new_plugin New plugin plugins plugin (any type) tests tests labels Mar 19, 2021
@danquixote
Copy link
Author

/rebuild_failed

@ansibullbot ansibullbot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed community_review labels Mar 19, 2021
@goneri goneri requested a review from tremble April 30, 2021 19:03
@goneri
Copy link
Member

goneri commented Apr 30, 2021

Hi @danquixote,

Thank you for the PR. I re-assign @tremble to it since he was already reviewing the original PR.

Copy link
Contributor

@tremble tremble left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to submit this PR.

The code itself looks reasonable.

The docs need a little work, I've highlighted an example of each type of issue in the docs, rather than adding a suggestion for each time the same issue occurs.

It should be possible to merge the two test targets. This helps to ensure that changes to one module don't affect the other, and also generally reduces the time taken to run the tests since you don't have all of the setup/tear-down time.

---
module: ec2_asg_instance_refresh
version_added: 1.0.0
short_description: Start or cancel an ec2 Auto Scaling Group (ASG) Instance Refresh in AWS
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
short_description: Start or cancel an ec2 Auto Scaling Group (ASG) Instance Refresh in AWS
short_description: Start or cancel an EC2 Auto Scaling Group (ASG) instance refresh in AWS

(nit) EC2 is a product name, the capitalization should follow the product owner's capitalization where possible.

Copy link
Author

@danquixote danquixote May 16, 2021

Choose a reason for hiding this comment

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

Fixed in 1cacca4

version_added: 1.0.0
short_description: Start or cancel an ec2 Auto Scaling Group (ASG) Instance Refresh in AWS
description:
- Start or cancel an ec2 Auto Scaling Group Instance Refresh in AWS
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Start or cancel an ec2 Auto Scaling Group Instance Refresh in AWS
- Start or cancel an EC2 Auto Scaling Group instance refresh in AWS.

https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_documenting.html#documentation-fields

While short_description fields shouldn't have a full stop at the end, description fields should be complete sentences, including a full stop at the end. While there's plenty of bad examples around, we are slowly cleaning them up.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in f2ec8ae

preferences:
description:
- Set of preferences associated with the instance refresh request.
- If not provided, the default values are used. For MinHealthyPercentage, the default value is 90.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- If not provided, the default values are used. For MinHealthyPercentage, the default value is 90.
- If not provided, the default values are used.
- For I(min_healthy_percentage), the default value is C(90).

When referring to other parameters you can should use I(<param_name>), when referring to values use C(<value>). This will then result in formatting which makes it a little easier to distinguish.

You can also do When I(my_param=SomeValue)... where referring to a specific parameter having a specific value.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in f2ec8ae

state=dict(
type='str',
required=True,
choices=['started', 'canceled'],
Copy link
Contributor

Choose a reason for hiding this comment

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

The past tense of cancel is cancelled (with two 'l's)

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in 47e6165

Comment on lines 18 to 27
- You can determine the status of a request by looking at the Status parameter. The following are the possible statuses
- Pending -- The request was created, but the operation has not started.
- InProgress -- The operation is in progress.
- Successful -- The operation completed successfully.
- Failed -- The operation failed to complete. You can troubleshoot using the status reason and the scaling activities.
- Cancelling --
- An ongoing operation is being cancelled.
- Cancellation does not roll back any replacements that have already been completed,
- but it prevents new replacements from being started.
- Cancelled -- The operation is cancelled.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to move most of this description into the return documentation.

Suggested change
- You can determine the status of a request by looking at the Status parameter. The following are the possible statuses
- Pending -- The request was created, but the operation has not started.
- InProgress -- The operation is in progress.
- Successful -- The operation completed successfully.
- Failed -- The operation failed to complete. You can troubleshoot using the status reason and the scaling activities.
- Cancelling --
- An ongoing operation is being cancelled.
- Cancellation does not roll back any replacements that have already been completed,
- but it prevents new replacements from being started.
- Cancelled -- The operation is cancelled.
- You can determine the status of a request by looking at the I(status) parameter.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in f2ec8ae

---
# defaults file for ec2_asg
# Amazon Linux 2 AMI 2019.06.12 (HVM), GP2 Volume Type
ec2_ami_name: 'amzn2-ami-hvm-2.0.20190612-x86_64-gp2'
Copy link
Contributor

Choose a reason for hiding this comment

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

We generally use a wildcard here and then filter it. See for example:
tests/integration/targets/ec2_instance/roles/ec2_instance/tasks/find_ami.yml

This allows for pulling in fixes that might be related to things like hardware support.

Copy link
Author

Choose a reason for hiding this comment

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

I think I included this by mimicking the ec2_asg module...Fixed in 667e501

- name: Create VPC for use in testing
ec2_vpc_net:
name: "{{ resource_prefix }}-vpc"
cidr_block: 10.55.77.0/24
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer using a random subnet here rather than hard coding values. It reduces the risks of collisions when things are run in parallel.

Copy link
Author

Choose a reason for hiding this comment

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

Also an artifact of mimicking ec2_asg...Got a good example from ec2_instance. (Hopefully) fixed in 3392ef7

Comment on lines 1 to 2
cloud/aws
ec2_asg_instance_refreshes_info
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to duplicate the tests here. You can merge the ec2_asg_instance_refreshes_info and ec2_asg_instance_refresh targets and add ec2_asg_instance_refreshes_info to the aliases file

Copy link
Author

Choose a reason for hiding this comment

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

I think I understand what you're saying, and it would of course make sense to combine the two test-"suites" for these related modules into one. However, I'm not 100% sure I did it correctly. Calling each still only runs the tests only for that module. Attempted fix in da9fe1b

Comment on lines 21 to 23
aws_access_key: "{{ aws_access_key }}"
aws_secret_key: "{{ aws_secret_key }}"
region: "{{ aws_region }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be needed and won't work in CI because we use session tokens.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in 958a04a

@danquixote
Copy link
Author

Hi @tremble. Thank you very much for your code-review. I haven't touched this code in a while, but will go over your comments this week and will hopefully also get my builds to pass.

---Also, it looks like I submitted this PR before the Shippable deprecation on May 3rd. Should I still continue work within this PR, or would it be better to open a 'fresh' one?

@tremble
Copy link
Contributor

tremble commented May 7, 2021 via email

@danquixote danquixote force-pushed the add_asg_refresh_and_info_modules branch 2 times, most recently from 47e6165 to 52b5cbc Compare May 16, 2021 08:01
@danquixote danquixote force-pushed the add_asg_refresh_and_info_modules branch from 812a396 to c55e32d Compare May 25, 2021 05:57
@ansibullbot ansibullbot added community_review and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR labels May 25, 2021
@danquixote danquixote requested a review from tremble May 25, 2021 06:06
@danquixote danquixote force-pushed the add_asg_refresh_and_info_modules branch 2 times, most recently from c64eef5 to d2ea03a Compare June 1, 2021 04:54
tremble and others added 3 commits August 11, 2021 12:31
Wrap Kafka tests in custom virtualenv

SUMMARY
aws_msk_config and aws_msk_cluster need recent versions of botocore, explicitly install these so we can still test against our minimum supported boto3/botocore versions
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
aws_msk_config
aws_msk_cluster
ADDITIONAL INFORMATION
fixes: ansible-collections#678

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
@mandar242
Copy link
Contributor

Hi @danquixote, closing this (#487) duplicate PR as you have already opened another with changes and rebase done. #795

@mandar242 mandar242 closed this Feb 23, 2022
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this pull request May 25, 2022
…equests (ansible-collections#487)

ec2_spot_instance_info: add new module for describing spot instance requests

SUMMARY

Added a new module that describes the specified Spot Instance requests.

ISSUE TYPE


New Module Pull Request

COMPONENT NAME

ec2_spot_instance_info
ADDITIONAL INFORMATION



Related Documentation:
https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/DescribeSpotInstanceRequests

Reviewed-by: Jill R <None>
Reviewed-by: None <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community_review integration tests/integration module module new_contributor Help guide this first time contributor new_module New module new_plugin New plugin plugins plugin (any type) tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.