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

route53_health_check: Fix "Name" tag key removal idempotentcy issue #1253

Conversation

mandar242
Copy link
Contributor

@mandar242 mandar242 commented Nov 8, 2022

SUMMARY

Depends-On: #1280

Fixes #1188

When using health_check_name as unique identifier (setting use_unique_names: True and providing a health_check_name) and health_check tags are set,

Current logic for adding name to a health_check causes an issue when rerunning the create/update task.
While ideally it should be idempotent, it removes the 'Name' tag (used for health_check_name) causing removal of health check name.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

route53_health_check

ADDITIONAL INFORMATION

To test, run the following sample playbook task twice
Expected output: Health check name should not disapper (i.e. 'Name' tag should not get removed on rerun)

---
- hosts: localhost
  gather_facts: False
  tasks:
    - name: Create a health-check
      amazon.aws.route53_health_check:
        health_check_name: my-test-hc
        use_unique_names: true
        fqdn: my-test-xyz.com
        type: HTTPS
        resource_path: /
        request_interval: 30
        failure_threshold: 3
        tags:
          Service: my-service
          Owner: my-test-xyz
          Lifecycle: dev

@ansibullbot
Copy link

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

Build failed.

✔️ ansible-galaxy-importer SUCCESS in 4m 09s
✔️ build-ansible-collection SUCCESS in 5m 01s
ansible-test-sanity-aws-ansible-python38 FAILURE in 8m 11s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 10m 53s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 9m 03s
✔️ ansible-test-sanity-aws-ansible-2.14 SUCCESS in 8m 47s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 33s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 5m 53s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 11m 40s
✔️ cloud-tox-py3 SUCCESS in 3m 00s
✔️ ansible-test-splitter SUCCESS in 3m 01s
integration-amazon.aws-1 FAILURE in 6m 40s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-amazon.aws-14 SKIPPED
⚠️ integration-amazon.aws-15 SKIPPED
⚠️ integration-amazon.aws-16 SKIPPED
⚠️ integration-amazon.aws-17 SKIPPED
⚠️ integration-amazon.aws-18 SKIPPED
⚠️ integration-amazon.aws-19 SKIPPED
⚠️ integration-amazon.aws-20 SKIPPED
⚠️ integration-amazon.aws-21 SKIPPED
⚠️ integration-amazon.aws-22 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
⚠️ integration-community.aws-19 SKIPPED
⚠️ integration-community.aws-20 SKIPPED
⚠️ integration-community.aws-21 SKIPPED
⚠️ integration-community.aws-22 SKIPPED
✔️ ansible-test-changelog SUCCESS in 2m 22s
✔️ noop SUCCESS in 0s

# Add 'Name' tag to add name to health check
if not tags:
tags = {}
tags['Name'] = health_check_name
Copy link
Contributor

Choose a reason for hiding this comment

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

If you do this, you need to make sure "purge_tags" is updated to False, if you don't, then leaving tags empty results in all non-Name tags being purged.

Copy link
Contributor Author

@mandar242 mandar242 Nov 8, 2022

Choose a reason for hiding this comment

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

I'm not sure if I follow,
if user does not change anything in the task, run it multiple times, with tags being read into the module from the task here, it shouldn't cause issue and should not remove non-name tags

if the user runs the task, then on the second run removes the tags from the task (keeping everything else same), then definitely module will remove the changed tags (still keeping Name tag), I assume that's the behavior we currently have and are aiming for right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for current code change purge_tags=False does not remove existing tags.
Added integration test to verify the same
https://github.com/ansible-collections/amazon.aws/pull/1253/files#diff-0d5db09c227a69a9880f5e7f16fde22576839c70c836a2836edbee1cee26989dR114-R146

Copy link
Member

Choose a reason for hiding this comment

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

I think what @tremble is saying (feel free to correct me) is that because purge_tagsby default is true, if the user has not set tags, what you are doing here is likely different than what they intend. With this logic, what will effectively happen is the following, even if they had not set tags:

route53_health_check:
  ...
  tags:
    Name: whatever
  purge_tags: true

This means the only tag remaining after the task runs will be the Name tag.

Copy link
Member

Choose a reason for hiding this comment

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

What we would want from a testing scenario is to have the task that sets use_unique_names, sets purge_tags=true (or just doesn't set it, since this is the default), and does not set the tags parameter. Then check to make sure that this does not remove the other non-Name tags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, added integration tests as well.
Now code behavior is as below

  • tags={}, purge_tags=false do nothing
  • tags={}, purge_tags=true remove existing tags except 'Name' tag
  • tags=None, purge_tags=true do nothing

@mandar242
Copy link
Contributor Author

Moving PR to WIP, adding more tests for asserting that tags are added/removed as per expected behavior.

@mandar242 mandar242 changed the title route53_health_check: Fix "Name" tag key removal idempotentcy issue [WIP] route53_health_check: Fix "Name" tag key removal idempotentcy issue Nov 8, 2022
@ansibullbot ansibullbot added the WIP Work in progress label Nov 8, 2022
@mandar242 mandar242 changed the title [WIP] route53_health_check: Fix "Name" tag key removal idempotentcy issue route53_health_check: Fix "Name" tag key removal idempotentcy issue Nov 8, 2022
@ansibullbot ansibullbot removed the WIP Work in progress label Nov 8, 2022
@mandar242 mandar242 changed the title route53_health_check: Fix "Name" tag key removal idempotentcy issue [WIP] route53_health_check: Fix "Name" tag key removal idempotentcy issue Nov 8, 2022
@ansibullbot ansibullbot added the WIP Work in progress label Nov 8, 2022
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

✔️ ansible-galaxy-importer SUCCESS in 4m 23s
✔️ build-ansible-collection SUCCESS in 7m 48s
ansible-test-sanity-aws-ansible-python38 FAILURE in 9m 23s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 10m 44s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 8m 35s
✔️ ansible-test-sanity-aws-ansible-2.14 SUCCESS in 10m 14s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 33s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 26s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 46s
✔️ cloud-tox-py3 SUCCESS in 3m 32s
✔️ ansible-test-splitter SUCCESS in 3m 08s
integration-amazon.aws-1 FAILURE in 7m 34s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-amazon.aws-14 SKIPPED
⚠️ integration-amazon.aws-15 SKIPPED
⚠️ integration-amazon.aws-16 SKIPPED
⚠️ integration-amazon.aws-17 SKIPPED
⚠️ integration-amazon.aws-18 SKIPPED
⚠️ integration-amazon.aws-19 SKIPPED
⚠️ integration-amazon.aws-20 SKIPPED
⚠️ integration-amazon.aws-21 SKIPPED
⚠️ integration-amazon.aws-22 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
⚠️ integration-community.aws-19 SKIPPED
⚠️ integration-community.aws-20 SKIPPED
⚠️ integration-community.aws-21 SKIPPED
⚠️ integration-community.aws-22 SKIPPED
✔️ ansible-test-changelog SUCCESS in 2m 44s
✔️ noop SUCCESS in 0s

@goneri
Copy link
Member

goneri commented Nov 8, 2022

recheck

2 similar comments
@gravesm
Copy link
Member

gravesm commented Nov 9, 2022

recheck

@goneri
Copy link
Member

goneri commented Nov 9, 2022

recheck

@softwarefactory-project-zuul

This comment was marked as outdated.

@softwarefactory-project-zuul

This comment was marked as outdated.

@mandar242 mandar242 changed the title [WIP] route53_health_check: Fix "Name" tag key removal idempotentcy issue route53_health_check: Fix "Name" tag key removal idempotentcy issue Nov 10, 2022
@ansibullbot ansibullbot removed the WIP Work in progress label Nov 10, 2022
@softwarefactory-project-zuul

This comment was marked as outdated.

@mandar242
Copy link
Contributor Author

Sanity test failing for unrelated PR's changelog
#1275

2022-11-18 18:47:13.456476 | controller | ERROR: changelogs/fragments/1268-lambda-execute-arn.yml:0:0: 
(WARNING/2) Inline literal start-string without end-string.

@softwarefactory-project-zuul

This comment was marked as outdated.

@mandar242
Copy link
Contributor Author

recheck

@softwarefactory-project-zuul

This comment was marked as outdated.

softwarefactory-project-zuul bot pushed a commit that referenced this pull request Nov 18, 2022
Sanity fix for changelog fragment

SUMMARY

Sanity fix for changelog fragment of #1275
The changelogs fragment is causing CI failure for sanity tests for other PRs such as #1253

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION
@mandar242 mandar242 force-pushed the route53_health_check_Name_tag_idem_fix branch from d215048 to e115368 Compare November 18, 2022 21:29
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

✔️ ansible-galaxy-importer SUCCESS in 4m 05s
✔️ build-ansible-collection SUCCESS in 5m 50s
ansible-test-sanity-aws-ansible-python38 FAILURE in 9m 30s (non-voting)
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 8m 47s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 8m 39s
✔️ ansible-test-sanity-aws-ansible-2.14 SUCCESS in 8m 32s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 25s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 11s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 5m 54s
✔️ cloud-tox-py3 SUCCESS in 3m 25s
✔️ ansible-test-changelog SUCCESS in 2m 23s
✔️ ansible-test-splitter SUCCESS in 2m 41s
✔️ integration-amazon.aws-1 SUCCESS in 8m 56s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-amazon.aws-14 SKIPPED
⚠️ integration-amazon.aws-15 SKIPPED
⚠️ integration-amazon.aws-16 SKIPPED
⚠️ integration-amazon.aws-17 SKIPPED
⚠️ integration-amazon.aws-18 SKIPPED
⚠️ integration-amazon.aws-19 SKIPPED
⚠️ integration-amazon.aws-20 SKIPPED
⚠️ integration-amazon.aws-21 SKIPPED
⚠️ integration-amazon.aws-22 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
⚠️ integration-community.aws-19 SKIPPED
⚠️ integration-community.aws-20 SKIPPED
⚠️ integration-community.aws-21 SKIPPED
⚠️ integration-community.aws-22 SKIPPED

@mandar242 mandar242 added the mergeit Merge the PR (SoftwareFactory) label Nov 29, 2022
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

✔️ ansible-galaxy-importer SUCCESS in 4m 26s
✔️ build-ansible-collection SUCCESS in 5m 24s
✔️ ansible-test-splitter SUCCESS in 2m 48s
✔️ integration-amazon.aws-1 SUCCESS in 8m 02s
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-amazon.aws-14 SKIPPED
⚠️ integration-amazon.aws-15 SKIPPED
⚠️ integration-amazon.aws-16 SKIPPED
⚠️ integration-amazon.aws-17 SKIPPED
⚠️ integration-amazon.aws-18 SKIPPED
⚠️ integration-amazon.aws-19 SKIPPED
⚠️ integration-amazon.aws-20 SKIPPED
⚠️ integration-amazon.aws-21 SKIPPED
⚠️ integration-amazon.aws-22 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
⚠️ integration-community.aws-19 SKIPPED
⚠️ integration-community.aws-20 SKIPPED
⚠️ integration-community.aws-21 SKIPPED
⚠️ integration-community.aws-22 SKIPPED

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit d73b9e4 into ansible-collections:main Nov 29, 2022
@github-actions
Copy link

Docs Build 📝

Thank you for contribution!✨

This PR has been merged and your docs changes will be incorporated when they are next published.

@mandar242 mandar242 deleted the route53_health_check_Name_tag_idem_fix branch May 9, 2023 02:46
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Oct 24, 2023
Prepare release 4.0.0

SUMMARY
Prepare release 4.0.0

Changelogs
galaxy.yml
Updated docs

ISSUE TYPE

Docs Pull Request

COMPONENT NAME
CHANGELOG.rst
README.md
changelogs/changelog.yaml
galaxy.yml
docs/
ADDITIONAL INFORMATION

Reviewed-by: Markus Bergholz <git@osuv.de>
Reviewed-by: Mandar Kulkarni <mandar242@gmail.com>
Reviewed-by: Alina Buzachis <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug community_review has_issue 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.

route53_health_check - Name tag lost on 2nd deploy
7 participants