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

Support changing of launch type #840

Conversation

mjmayer
Copy link
Contributor

@mjmayer mjmayer commented Dec 17, 2021

SUMMARY

When changing the launch_type parameter for an ecs_taskdefition there was no change reported by the module. This adds a check to see if launch_type in the ecs_taskdefinition has changed. If there is a change detected the module reports back there is not a matching task definition and creates a new one.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

ecs_taskdefinition

Copy link
Contributor

@alinabuzachis alinabuzachis left a comment

Choose a reason for hiding this comment

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

@mjmayer Thank you for taking time to work on this. Could you please add a changelog fragment for this fix?

@mjmayer
Copy link
Contributor Author

mjmayer commented Jan 13, 2022

I had troubles running the test suite locally. I was seeing failures unrelated to the code changes I made. In the IRC channel it was suggested to open a PR and see if the tests run.

Looking at the zuul build I'm not sure it is running the tests properly.
https://ansible.softwarefactory-project.io/zuul/build/7e6a171433914034b8a35071cf6e7e96/log/job-output.txt

2022-01-13 19:58:40.955462 | TASK [ansible-test : Run the test suite]

2022-01-13 19:58:42.578880 | controller | RLIMIT_NOFILE: (1024, 524288)

2022-01-13 19:58:42.578953 | controller | MAXFD: -1

2022-01-13 19:58:42.578987 | controller | Falling back to tests in "tests/integration/targets/" because "roles/test/" was not found.

2022-01-13 19:58:42.605172 | controller | WARNING: Excluding target tests marked "unsupported" which require --allow-unsupported or prefixing with "unsupported/": ecs_cluster

2022-01-13 19:58:42.618859 | controller | Run command: ssh-keygen -m PEM -q -t rsa -N '' -f /home/zuul/.ansible/test/id_rsa

2022-01-13 19:58:42.618912 | controller | Working directory: /home/zuul/.ansible/collections/ansible_collections/community/aws

2022-01-13 19:58:42.619159 | controller | Program found: /usr/bin/ssh-keygen

2022-01-13 19:58:42.619190 | controller | HOME=/home/zuul

2022-01-13 19:58:42.619212 | controller | LC_ALL=en_US.UTF-8

2022-01-13 19:58:42.619233 | controller | PATH=/home/zuul/venv/bin:/home/zuul/.local/bin:/home/zuul/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin

2022-01-13 19:58:42.864572 | controller | Command exited with status 0 after 0.24477124214172363 seconds.

2022-01-13 19:58:42.865986 | controller | WARNING: All targets skipped.

2022-01-13 19:58:43.234349 | controller | ok: Runtime: 0:00:00.738980

CHANGELOG.rst Outdated
@@ -85,6 +85,7 @@ Bugfixes
- route53 - fix diff mode when deleting records (https://github.com/ansible-collections/community.aws/pull/802).
- route53 - return empty result for nonexistent records (https://github.com/ansible-collections/community.aws/pull/799).
- sns_topic - define suboptions for delivery_policy option (https://github.com/ansible-collections/community.aws/issues/713).
- ecs_taskdefinition - include launch_type comparison when comparing task definitions (https://github.com/ansible-collections/community.aws/pull/840)
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no need to modify this file (this file is autogenerated). You have to place your changelog here https://github.com/ansible-collections/community.aws/tree/main/changelogs/fragments. For example, you can name the file 840-ecs_taskdefinition-fix-task-definition-comparison.yml (or if you find a better name) and place inside the file

bugfixes:
- ecs_taskdefinition - include launch_type comparison when comparing task definitions (https://github.com/ansible-collections/community.aws/pull/840)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for being very explicit about the change required. I've made the requested changes.

@alinabuzachis
Copy link
Contributor

I had troubles running the test suite locally. I was seeing failures unrelated to the code changes I made. In the IRC channel it was suggested to open a PR and see if the tests run.

Looking at the zuul build I'm not sure it is running the tests properly. https://ansible.softwarefactory-project.io/zuul/build/7e6a171433914034b8a35071cf6e7e96/log/job-output.txt

2022-01-13 19:58:40.955462 | TASK [ansible-test : Run the test suite]

2022-01-13 19:58:42.578880 | controller | RLIMIT_NOFILE: (1024, 524288)

2022-01-13 19:58:42.578953 | controller | MAXFD: -1

2022-01-13 19:58:42.578987 | controller | Falling back to tests in "tests/integration/targets/" because "roles/test/" was not found.

2022-01-13 19:58:42.605172 | controller | WARNING: Excluding target tests marked "unsupported" which require --allow-unsupported or prefixing with "unsupported/": ecs_cluster

2022-01-13 19:58:42.618859 | controller | Run command: ssh-keygen -m PEM -q -t rsa -N '' -f /home/zuul/.ansible/test/id_rsa

2022-01-13 19:58:42.618912 | controller | Working directory: /home/zuul/.ansible/collections/ansible_collections/community/aws

2022-01-13 19:58:42.619159 | controller | Program found: /usr/bin/ssh-keygen

2022-01-13 19:58:42.619190 | controller | HOME=/home/zuul

2022-01-13 19:58:42.619212 | controller | LC_ALL=en_US.UTF-8

2022-01-13 19:58:42.619233 | controller | PATH=/home/zuul/venv/bin:/home/zuul/.local/bin:/home/zuul/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin

2022-01-13 19:58:42.864572 | controller | Command exited with status 0 after 0.24477124214172363 seconds.

2022-01-13 19:58:42.865986 | controller | WARNING: All targets skipped.

2022-01-13 19:58:43.234349 | controller | ok: Runtime: 0:00:00.738980

Concerning the integrations tests, since they are marked with unsupported, they aren't run in the CI at the moment. Not sure why there are marked so (cc @markuman), but we we'll test your change locally before merging it.
If you'd like to spend some time to check if the tests are running properly (and then remove unsupported), that would be awesome!

@mjmayer mjmayer force-pushed the support_changing_of_launch_type branch from 5cda82c to 207d190 Compare January 20, 2022 16:25
Copy link
Member

@markuman markuman left a comment

Choose a reason for hiding this comment

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

The integration test of ecs_cluster is a bad adventure ...

Because of so many issues, it's marked as unstable I think

TASK [ecs_cluster : create ECS service definition] *****************************
An error occurred (InvalidParameterException) when calling the CreateService operation: 
Unable to Start a service that is still Draining.

The service will be deleted: https://github.com/ansible-collections/community.aws/blob/main/tests/integration/targets/ecs_cluster/tasks/force_service_deletion.yml#L244
and afterwards instantly recreated: https://github.com/ansible-collections/community.aws/blob/main/tests/integration/targets/ecs_cluster/tasks/force_service_deletion.yml#L257

Furthermore the ressources are not cleaned up after failure.

When I reduce the integration test to - include_tasks: full_test.yml, that is touched in this PR, we run in more technical debt issues

TASK [ecs_cluster : provision ec2 instance to create an image] *****************
An error occurred (InvalidParameterCombination) when calling the RunInstances operation: 
Enhanced networking with the Elastic Network Adapter (ENA) is required for the 't3.micro' instance type. 
Ensure that you are using an AMI that is enabled for ENA.

A hotfix for this error is

diff --git a/tests/integration/targets/ecs_cluster/tasks/full_test.yml b/tests/integration/targets/ecs_cluster/tasks/full_test.yml
index 88e29ce..a48bf98 100644
--- a/tests/integration/targets/ecs_cluster/tasks/full_test.yml
+++ b/tests/integration/targets/ecs_cluster/tasks/full_test.yml
@@ -111,7 +111,7 @@
 
     - name: set image id fact
       set_fact:
-        ecs_image_id: "{{ (ec2_ami_info.images|first).image_id }}"
+        ecs_image_id: "{{ (ec2_ami_info.images|last).image_id }}"
 
     - name: provision ec2 instance to create an image
       ec2_instance:

There are so many "igonoring errors" due undefined variables errors, fixme notes etc. Cleanup the ecs_cluster integration test is a mammoth task

The list of errors is endless

TASK [ecs_cluster : create fargate ECS task with run task] *********************
botocore.errorfactory.ClientException: An error occurred (ClientException) when calling the RunTask operation: 
ECS was unable to assume the role 'arn:aws:iam::611139332414:role/ecsTaskExecutionRole' that was provided for this task. 
Please verify that the role being passed has the proper trust relationship and permissions and that your IAM user has permissions to pass this role.

But back to this PR.

This test is failing which is successfull in main branch.

TASK [ecs_cluster : recreate task definition] **********************************
changed: [testhost] => {"changed": true, "resource_actions": ["ecs:RegisterTaskDefinition", "ecs:ListTaskDefinitions", "ecs:DescribeTaskDefinition"], "taskdefinition": {"compatibilities": ["EXTERNAL", "EC2"], "containerDefinitions": [{"cpu": 0, "environment": [], "essential": true, "image": "nginx", "linuxParameters": {"maxSwap": 0, "swappiness": 80}, "memory": 128, "mountPoints": [], "name": "ansible-test-64854856-rocket-task", "portMappings": [{"containerPort": 8080, "hostPort": 0, "protocol": "tcp"}], "volumesFrom": []}], "family": "ansible-test-64854856-rocket-task", "networkMode": "bridge", "placementConstraints": [], "revision": 2, "status": "ACTIVE", "taskDefinitionArn": "arn:aws:ecs:eu-central-1:611139332414:task-definition/ansible-test-64854856-rocket-task:2", "volumes": []}}

TASK [ecs_cluster : check that task definition does not change] ****************
fatal: [testhost]: FAILED! => {
    "assertion": "not ecs_task_definition_again.changed",
    "changed": false,
    "evaluated_to": false,
    "msg": "Assertion failed"
}

So it must be fixed before merging

@mjmayer
Copy link
Contributor Author

mjmayer commented Feb 4, 2022

@markuman Thank you for the detailed description of the state of ecs_cluster integration test. I would have given up on the PR without it.

The test is still failing, but the failures appears unrelated to my changes.

TASK [ecs_cluster : disable taskLongArnFormat] *************************************************************************************************************************************************************
task path: /root/ansible_collections/community/aws/tests/output/.tmp/integration/ecs_cluster-bmqn6pdd-ÅÑŚÌβŁÈ/tests/integration/targets/ecs_cluster/tasks/full_test.yml:759
<testhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<testhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<testhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1644012273.1265073-8916-231925734205881 `" && echo ansible-tmp-1644012273.1265073-8916-231925734205881="` echo /root/.ansible/tmp/ansible-tmp-1644012273.1265073-8916-231925734205881 `" ) && sleep 0'
Using module file /root/ansible/lib/ansible/modules/command.py
<testhost> PUT /root/.ansible/tmp/ansible-local-7475irwy76p7/tmp2avad1wm TO /root/.ansible/tmp/ansible-tmp-1644012273.1265073-8916-231925734205881/AnsiballZ_command.py
<testhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1644012273.1265073-8916-231925734205881/ /root/.ansible/tmp/ansible-tmp-1644012273.1265073-8916-231925734205881/AnsiballZ_command.py && sleep 0'
<testhost> EXEC /bin/sh -c 'ANSIBLE_DEBUG_BOTOCORE_LOGS=True AWS_ACCESS_KEY_ID=****************8 AWS_SECRET_ACCESS_KEY=**********************AWS_SESSION_TOKEN=************************* AWS_DEFAULT_REGION=us-west-2 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1644012273.1265073-8916-231925734205881/AnsiballZ_command.py && sleep 0'
fatal: [testhost]: FAILED! => {
    "changed": true,
    "cmd": [
        "aws",
        "ecs",
        "put-account-setting",
        "--name",
        "taskLongArnFormat",
        "--value",
        "disabled"
    ],
    "delta": "0:00:00.881105",
    ...

@ansibullbot
Copy link

@ansibullbot ansibullbot added bug This issue/PR relates to a bug community_review integration tests/integration module module plugins plugin (any type) tests tests labels Feb 4, 2022
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (third-party-check pipeline).

@mjmayer
Copy link
Contributor Author

mjmayer commented Feb 15, 2022

@alinabuzachis Could you kick off another build of this PR? The latest build failed because of some issue with the CI/CD trying to install a Python package, which was totally unrelated to the changes in this PR.

@markuman
Copy link
Member

recheck

Copy link
Contributor

@alinabuzachis alinabuzachis left a comment

Choose a reason for hiding this comment

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

@mjmayer Thank you very much for your contribution. This LGTM!

@markuman markuman added backport-2 PR should be backported to the stable-2 branch backport-3 PR should be backported to the stable-3 branch labels Feb 18, 2022
@markuman markuman added the mergeit Merge the PR (SoftwareFactory) label Feb 18, 2022
@alinabuzachis alinabuzachis added mergeit Merge the PR (SoftwareFactory) and removed mergeit Merge the PR (SoftwareFactory) labels Feb 18, 2022
@alinabuzachis alinabuzachis added mergeit Merge the PR (SoftwareFactory) and removed mergeit Merge the PR (SoftwareFactory) labels Feb 23, 2022
@marknet15
Copy link
Contributor

regate

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit c67c890 into ansible-collections:main Mar 18, 2022
@patchback
Copy link

patchback bot commented Mar 18, 2022

Backport to stable-2: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-2/c67c890726a512b5bfadf0cfa97f1534ce470711/pr-840

Backported as #1007

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Mar 18, 2022
Support changing of launch type

SUMMARY
When changing the launch_type parameter for an ecs_taskdefition there was no change reported by the module. This adds a check to see if launch_type in the ecs_taskdefinition has changed. If there is a change detected the module reports back there is not a matching task definition and creates a new one.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ecs_taskdefinition

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Michael Mayer <mjmayer@gmail.com>
Reviewed-by: Markus Bergholz <git@osuv.de>
(cherry picked from commit c67c890)
@patchback
Copy link

patchback bot commented Mar 18, 2022

Backport to stable-3: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-3/c67c890726a512b5bfadf0cfa97f1534ce470711/pr-840

Backported as #1008

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Mar 18, 2022
Support changing of launch type

SUMMARY
When changing the launch_type parameter for an ecs_taskdefition there was no change reported by the module. This adds a check to see if launch_type in the ecs_taskdefinition has changed. If there is a change detected the module reports back there is not a matching task definition and creates a new one.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ecs_taskdefinition

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Michael Mayer <mjmayer@gmail.com>
Reviewed-by: Markus Bergholz <git@osuv.de>
(cherry picked from commit c67c890)
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Mar 19, 2022
[PR #840/c67c8907 backport][stable-3] Support changing of launch type

This is a backport of PR #840 as merged into main (c67c890).
SUMMARY
When changing the launch_type parameter for an ecs_taskdefition there was no change reported by the module. This adds a check to see if launch_type in the ecs_taskdefinition has changed. If there is a change detected the module reports back there is not a matching task definition and creates a new one.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ecs_taskdefinition
softwarefactory-project-zuul bot pushed a commit that referenced this pull request Mar 19, 2022
[PR #840/c67c8907 backport][stable-2] Support changing of launch type

This is a backport of PR #840 as merged into main (c67c890).
SUMMARY
When changing the launch_type parameter for an ecs_taskdefition there was no change reported by the module. This adds a check to see if launch_type in the ecs_taskdefinition has changed. If there is a change detected the module reports back there is not a matching task definition and creates a new one.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ecs_taskdefinition
abikouo pushed a commit to abikouo/community.aws that referenced this pull request Oct 24, 2023
…sible-collections#840)

Add support for copy_db_cluster_snapshot for rds_cluster_snapshot

SUMMARY

Add support for copy_db_cluster_snapshot for rds_cluster_snapshot

Necessary for ansible-collections#788
Just to verify:
Depends-On: ansible/ansible-zuul-jobs#1520
ISSUE TYPE


Feature Pull Request

COMPONENT NAME

module_utils/rds.py
ADDITIONAL INFORMATION

Reviewed-by: Joseph Torcasso <None>
Reviewed-by: Jill R <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-2 PR should be backported to the stable-2 branch backport-3 PR should be backported to the stable-3 branch bug This issue/PR relates to a bug community_review integration tests/integration mergeit Merge the PR (SoftwareFactory) module module plugins plugin (any type) tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants