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 Python and Glue version parameters, add check mode #480

Merged
merged 26 commits into from
Nov 25, 2021
Merged

Add Python and Glue version parameters, add check mode #480

merged 26 commits into from
Nov 25, 2021

Conversation

ichekaldin
Copy link
Contributor

SUMMARY

Add parameters for Python version and Glue version.

Available Python and Glue version can be found here:
https://docs.aws.amazon.com/glue/latest/dg/add-job.html

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

aws_glue_job

ADDITIONAL INFORMATION

Example:

community.aws.aws_glue_job:
  - name: my-job
    description: My test job
    command_script_location: my-s3-bucket/script.py
    command_python_version: 3
    glue_version: "2.0"
    role: MyGlueJobRole
    state: present

@ansibullbot
Copy link

@ansibullbot ansibullbot added community_review feature This issue/PR relates to a feature request integration tests/integration module module needs_triage plugins plugin (any type) tests tests needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR and removed community_review labels Mar 16, 2021
@ichekaldin
Copy link
Contributor Author

Looks like the tests fail with the following IAM permissions error:

User: arn:aws:sts::966509639900:assumed-role/ansible-core-ci-test-prod/prod=shippable=ansible-collections=community.aws=1927.24 is not authorized to perform: glue:GetJob on resource: arn:aws:glue:us-east-1:966509639900:job/shippable-1927-24

This appears to depend on this PR. What's the best way to move it forward?

@tremble
Copy link
Contributor

tremble commented Mar 16, 2021

@ichekaldin,

Looking at mattclay/aws-terminator#95 the best bet would be to open a fresh PR. The 'testing' (JSON) policy shouldn't be needed any more as the 'testing' policies now automatically include the core CI policies.

@jillr usually reviews the aws-terminator PRs on Thursday afternoons (US time), so if you can get it pushed in the next 36 hours or so there's a good chance it can be merged quickly.

@ichekaldin
Copy link
Contributor Author

@tremble Thank you. I submitted mattclay/aws-terminator#137.

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.

Because this is a pre-existing module I'd recommend not setting a default for either of these parameters and letting AWS set the defaults. This avoids the potential for the 'default' versions to change between Ansible/Collection versions in a way which may break someone's playbooks.

plugins/modules/aws_glue_job.py Outdated Show resolved Hide resolved
plugins/modules/aws_glue_job.py Outdated Show resolved Hide resolved
plugins/modules/aws_glue_job.py Outdated Show resolved Hide resolved
plugins/modules/aws_glue_job.py Outdated Show resolved Hide resolved
@ansibullbot
Copy link

@ansibullbot ansibullbot added the needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html label Apr 1, 2021
jillr
jillr previously requested changes Apr 2, 2021
Copy link
Collaborator

@jillr jillr left a comment

Choose a reason for hiding this comment

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

I've tested the IAM policies up through line 175 in the integration test file but I'm running into multiple assertion failures.

- glue_job.changed
- glue_job.command.python_version == job_info["Job"]["Command"]["PythonVersion"]
- glue_job.command.script_location == job_info["Job"]["Command"]["ScriptLocation"]
- glue_job.default_arguments == job_info["Job"]["DefaultArguments"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This assertion is failing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suspect this is because camel_dict_to_snake_dict converts DefaultArguments to snake_case.

I added DefaultArguments to the exclusion list for camel_dict_to_snake_dict. I believe this resolves the assertion failure.

assert:
that:
- glue_job_check.changed
- not glue_job_check.description
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no description key being returned, if this is what you want to test for it would need to be:
- '"description" not in glue_job_check'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jillr I fixed the test syntax (I think).

Comment on lines +174 to +175
- job_info["Job"]["Description"] == job_info_idempotent["Job"]["Description"]
- job_info["Job"]["GlueVersion"] == job_info_idempotent["Job"]["GlueVersion"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Both of these assertions are failing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jillr I believe this is due to the same reason as assertion in line 90.

@ansibullbot
Copy link

@ichekaldin this PR contains the following merge commits:

Please rebase your branch to remove these commits.

click here for bot help

@ansibullbot ansibullbot added the merge_commit This PR contains at least one merge commit. Please resolve! label Apr 2, 2021
@ansibullbot
Copy link

@ichekaldin this PR contains the following merge commits:

Please rebase your branch to remove these commits.

click here for bot help

@ansibullbot
Copy link

@ichekaldin this PR contains the following merge commits:

Please rebase your branch to remove these commits.

click here for bot help

@ansibullbot ansibullbot removed merge_commit This PR contains at least one merge commit. Please resolve! needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html labels Apr 2, 2021
@ichekaldin
Copy link
Contributor Author

@jillr Is there anything else I could do to move this forward?

@jillr
Copy link
Collaborator

jillr commented Apr 8, 2021

@ichekaldin Some of the tests are still failing, I was able to comment out enough to get the policies tested though and will deploy those to our production CI. It's helpful to reviewers if we have passing tests to verify changes with.

index cc61c87..e846c0b 100644
--- a/tests/integration/targets/aws_glue_job/tasks/main.yml
+++ b/tests/integration/targets/aws_glue_job/tasks/main.yml
@@ -89,7 +89,7 @@
           - glue_job.command.script_location == job_info["Job"]["Command"]["ScriptLocation"]
           - glue_job.default_arguments == job_info["Job"]["DefaultArguments"]
           - glue_job.description == job_info["Job"]["Description"]
-          - glue_job.glue_version == job_info["Job"]["GlueVersion"]
+          #- glue_job.glue_version == job_info["Job"]["GlueVersion"]
           - glue_job.role == job_info["Job"]["Role"]
 
     - name: Create Glue job (idempotent) (check mode)
@@ -212,7 +212,7 @@
           - glue_job_update_check.command.script_location == job_info_update_check["Job"]["Command"]["ScriptLocation"]
           - glue_job_update_check.default_arguments == job_info_update_check["Job"]["DefaultArguments"]
           - glue_job_update_check.description == job_info_update_check["Job"]["Description"]
-          - glue_job_update_check.glue_version == job_info_update_check["Job"]["Command"]["GlueVersion"]
+          #- glue_job_update_check.glue_version == job_info_update_check["Job"]["Command"]["GlueVersion"]
           - glue_job_update_check.role == job_info_update_check["Job"]["Role"]
 
     - name: Update Glue job
@@ -251,7 +251,7 @@
           - glue_job_update.command.script_location == job_info_update["Job"]["Command"]["ScriptLocation"]
           - glue_job_update.default_arguments == job_info_update["Job"]["DefaultArguments"]
           - glue_job_update.description == job_info_update["Job"]["Description"]
-          - glue_job_update.glue_version == job_info_update["Job"]["Command"]["GlueVersion"]
+          #- glue_job_update.glue_version == job_info_update["Job"]["Command"]["GlueVersion"]
           - glue_job_update.role == job_info_update["Job"]["Role"]

@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 Apr 16, 2021
@ichekaldin
Copy link
Contributor Author

@jillr It looks like the tests are passing now. Can this be approved?

ichekaldin and others added 14 commits October 22, 2021 22:53
Available Python and Glue version can be found here:
https://docs.aws.amazon.com/glue/latest/dg/add-job.html

Example:

```
community.aws.aws_glue__jobs:
  - name: my-job
    description: My test job
    command_script_location: my-s3-bucket/script.py
    command_python_version: 3
    glue_version: "2.0"
    role: MyGlueJobRole
    state: present
```
This is to avoid inadvertently breaking existing playbooks. Defaults
will be set by AWS.
Use `get_aws_account_info` method to determine AWS partition and accunt ID
instead of reinventing the wheel.

Rearrange module attributes alphabetically.
@tremble
Copy link
Contributor

tremble commented Oct 23, 2021

recheck

@ichekaldin
Copy link
Contributor Author

@tremble Is there any more work that needs to happen with this PR?

plugins/modules/aws_glue_job.py Outdated Show resolved Hide resolved
plugins/modules/aws_glue_job.py Outdated Show resolved Hide resolved
plugins/modules/aws_glue_job.py Outdated Show resolved Hide resolved
@tremble tremble dismissed jillr’s stale review November 25, 2021 14:33

out dated review, tests now passing

@markuman markuman added the gate label Nov 25, 2021
Copy link
Contributor

@ansible-zuul ansible-zuul bot left a comment

Choose a reason for hiding this comment

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

LGTM!

@ansible-zuul ansible-zuul bot merged commit 560169b into ansible-collections:main Nov 25, 2021
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this pull request May 25, 2022
inventory_aws_ec2/test: switch to ec2_instance

SUMMARY

Migrate the inventory_aws_ec2 tests from ec2 to ec2_instance.
Also, properly clean up all the resources during the test

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
inventory_aws_ec2

Reviewed-by: Mark Chappell <None>
Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
Reviewed-by: None <None>
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this pull request May 25, 2022
do not include {} boto filter by default

Depends-On: ansible-collections#480

When no filter: specified, do not include an empty dict in the list of
boto filters because it effectively matches any host.

Closes: ansible-collections#457
Closes: ansible-collections#452
ISSUE TYPE

Bugfix Pull Request

Reviewed-by: Mark Chappell <None>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
@ichekaldin ichekaldin deleted the ichekaldin/aws_glue_job_parameters branch July 6, 2022 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community_review feature This issue/PR relates to a feature request integration tests/integration module module plugins plugin (any type) tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants