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

Adding missing idempotence support in load balancer #45548

Merged
merged 29 commits into from
Nov 14, 2018

Conversation

zikalino
Copy link
Contributor

SUMMARY

Idempotence is not supported at all.
Load balancer can't be updated at the moment

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

azure_rm_loadbalancer

ANSIBLE VERSION

2.7

ADDITIONAL INFORMATION

@ansibot
Copy link
Contributor

ansibot commented Sep 12, 2018

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 azure bug This issue/PR relates to a bug. cloud community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. owner_pr This PR is made by the module's maintainer. support:community This issue/PR relates to code supported by the Ansible community. labels Sep 12, 2018
@zikalino zikalino closed this Sep 12, 2018
@zikalino zikalino reopened this Sep 12, 2018
@zikalino zikalino closed this Sep 12, 2018
@zikalino zikalino reopened this Sep 12, 2018
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Sep 12, 2018
@zikalino zikalino closed this Sep 12, 2018
@zikalino zikalino reopened this Sep 12, 2018
@ansibot ansibot added test This PR relates to tests. and removed owner_pr This PR is made by the module's maintainer. labels Sep 12, 2018
@mattclay
Copy link
Member

CI failure in integration tests: https://app.shippable.com/github/ansible/ansible/runs/83704/85/tests

@mattclay mattclay added the ci_verified Changes made in this PR are causing tests to fail. label Sep 12, 2018
@ansibot
Copy link
Contributor

ansibot commented Sep 12, 2018

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:692:25: E265 block comment should start with '# '

click here for bot help

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Sep 12, 2018
@zikalino zikalino changed the title Adding missing idempotency support in load balancer Adding missing idempotence support in load balancer Sep 12, 2018
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Sep 12, 2018
@ansibot
Copy link
Contributor

ansibot commented Sep 12, 2018

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:855:1: E302 expected 2 blank lines, found 1

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Sep 12, 2018

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:857:1: E302 expected 2 blank lines, found 1

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Sep 13, 2018

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:857:1: E302 expected 2 blank lines, found 1

click here for bot help

@ansibot ansibot removed stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. stale_review Updates were made after the last review and the last review is more than 7 days old. labels Oct 30, 2018
@Fred-sun
Copy link
Contributor

@yungezz @zikalino How about this PR going ahead? It could be merged or need further review? Please help confirm. Thanks!

if not compare(a.get(k, None), b.get(k, None), t[k]):
return False
if not compare(a.get(k, None), b.get(k, None), t[k]):
return False
Copy link
Contributor

Choose a reason for hiding this comment

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

line 875, what if a==none and b==none, the compare return true, but it should be false.

Copy link
Contributor

Choose a reason for hiding this comment

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

line 861, if s is not None, be specific s=="index"

Copy link
Contributor

Choose a reason for hiding this comment

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

line 858-860, no matter what t is, how many properties in it, if one of properties =="index", s will be "index". sorry I didn't get it.

Copy link
Contributor

Choose a reason for hiding this comment

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

line 887, default comparison, not considering number

@ansibot
Copy link
Contributor

ansibot commented Nov 13, 2018

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:756:0: syntax-error invalid syntax (<unknown>, line 756)
test/sanity/pylint/ignore.txt:10:1: A102 Remove since "lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py" passes "ansible-format-automatic-specification" pylint test

The test ansible-test sanity --test ansible-doc --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test ansible-doc --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test ansible-doc --python 3.5 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test ansible-doc --python 3.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test ansible-doc --python 3.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test docs-build [explain] failed with the error:

Command "/usr/bin/python test/sanity/code-smell/docs-build.py" returned exit status 1.
>>> Standard Error
Command 'make singlehtmldocs' failed with status code: 2
--> Standard Output
cat _themes/srtd/static/css/theme.css | sed -e 's/^[ 	]*//g; s/[ 	]*$//g; s/\([:{;,]\) /\1/g; s/ {/{/g; s/\/\*.*\*\///g; /^$/d' | sed -e :a -e '$!N; s/\n\(.\)/\1/; ta' > _themes/srtd/static/css/theme.min.css
PYTHONPATH=../../lib ../bin/dump_config.py --template-file=../templates/config.rst.j2 --output-dir=rst/reference_appendices/ -d ../../lib/ansible/config/base.yml
mkdir -p rst/cli
PYTHONPATH=../../lib ../bin/generate_man.py --template-file=../templates/cli_rst.j2 --output-dir=rst/cli/ --output-format rst ../../lib/ansible/cli/*.py
PYTHONPATH=../../lib ../bin/dump_keywords.py --template-dir=../templates --output-dir=rst/reference_appendices/ -d ./keyword_desc.yml
PYTHONPATH=../../lib ../bin/plugin_formatter.py -t rst --template-dir=../templates --module-dir=../../lib/ansible/modules -o rst/modules/ 
Makefile:93: recipe for target 'modules' failed
--> Standard Error
Traceback (most recent call last):
  File "../bin/plugin_formatter.py", line 720, in <module>
    main()
  File "../bin/plugin_formatter.py", line 678, in main
    plugin_info, categories = get_plugin_info(options.module_dir, limit_to=options.limit_to, verbose=(options.verbosity > 0))
  File "../bin/plugin_formatter.py", line 269, in get_plugin_info
    doc, examples, returndocs, metadata = plugin_docs.get_docstring(module_path, fragment_loader, verbose=verbose)
  File "/root/ansible/lib/ansible/utils/plugin_docs.py", line 99, in get_docstring
    data = read_docstring(filename, verbose=verbose, ignore_errors=ignore_errors)
  File "/root/ansible/lib/ansible/parsing/plugin_docs.py", line 43, in read_docstring
    M = ast.parse(b_module_data.read())
  File "/usr/lib/python3.6/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 756
    not default_compare(new_dict, load_balancer, ''):
                                                    ^
SyntaxError: invalid syntax
make: *** [modules] Error 1

The test ansible-test sanity --test compile --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:756:73: SyntaxError: not default_compare(new_dict, load_balancer, ''):

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:756:73: SyntaxError: not default_compare(new_dict, load_balancer, ''):

The test ansible-test sanity --test compile --python 3.5 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:756:73: SyntaxError: not default_compare(new_dict, load_balancer, ''):

The test ansible-test sanity --test compile --python 3.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:756:73: SyntaxError: not default_compare(new_dict, load_balancer, ''):

The test ansible-test sanity --test compile --python 3.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:756:73: SyntaxError: not default_compare(new_dict, load_balancer, ''):

The test ansible-test sanity --test import --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:756:73: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:756:73: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.5 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:756:73: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:756:73: SyntaxError: invalid syntax

The test ansible-test sanity --test import --python 3.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:756:73: SyntaxError: invalid syntax

The test ansible-test sanity --test pep8 [explain] failed with 83 errors:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:755:25: E127 continuation line over-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:756:25: E127 continuation line over-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:757:28: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:757:30: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:758:17: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:759:28: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:759:30: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:760:13: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:761:17: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:761:24: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:761:26: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:762:9: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:763:13: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:763:20: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:763:22: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:765:9: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:765:30: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:765:32: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:766:9: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:767:13: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:767:55: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:767:57: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:768:13: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:769:17: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:769:24: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:769:26: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:770:9: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:771:13: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:772:17: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:772:24: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:772:26: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:773:9: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:773:32: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:773:34: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:775:9: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:776:13: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:776:34: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:776:36: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:777:9: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:778:13: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:779:13: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:779:34: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:779:36: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:781:9: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:783:5: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:784:9: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:785:9: E128 continuation line under-indented for visual indent
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:786:20: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:786:22: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:789:5: E122 continuation line missing indentation or outdented
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:797:5: E122 continuation line missing indentation or outdented
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:801:19: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:801:21: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:806:5: E122 continuation line missing indentation or outdented
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:808:19: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:808:21: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:809:19: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:809:21: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:815:1: E122 continuation line missing indentation or outdented
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:829:16: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:829:18: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:831:20: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:831:22: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:833:20: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:833:22: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:834:16: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:834:18: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:835:16: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:835:18: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:837:16: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:837:18: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:838:16: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:838:18: E251 unexpected spaces around keyword / parameter equals
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:844:26: W291 trailing whitespace
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:847:1: E122 continuation line missing indentation or outdented
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:854:5: E123 closing bracket does not match indentation of opening bracket's line
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:857:1: E122 continuation line missing indentation or outdented
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:864:5: E123 closing bracket does not match indentation of opening bracket's line
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:867:1: E122 continuation line missing indentation or outdented
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:874:5: E123 closing bracket does not match indentation of opening bracket's line
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:877:1: E122 continuation line missing indentation or outdented
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:882:1: E122 continuation line missing indentation or outdented
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:884:1: E901 TokenError: EOF in multi-line statement

The test ansible-test sanity --test validate-modules [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:0:0: E401 Python SyntaxError while parsing module

The test ansible-test sanity --test yamllint [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:756:73: python-syntax-error invalid syntax (<unknown>, line 756)

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Nov 14, 2018

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:820:19: undefined-variable Undefined variable 'false'
lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:844:25: trailing-whitespace Trailing whitespace

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/cloud/azure/azure_rm_loadbalancer.py:844:26: W291 trailing whitespace

click here for bot help

@@ -784,7 +790,7 @@ def get_load_balancer(self):
"""Get a load balancer"""
self.log('Fetching loadbalancer {0}'.format(self.name))
try:
return self.network_client.load_balancers.get(self.resource_group, self.name)
return self.network_client.load_balancers.get(self.resource_group, self.name).as_dict()
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm not sure as_dict() whether works on load balancer, but it doesn't not work on webapp objects

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what happens in webapp?


return result
def default_compare(new, old, path):
if new is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

what if old is none too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean if old is not none?
at this point I am just assuming that if parameter is not specified (is None), then we don't do comparison. I am not sure whether it's right or wrong default behavior in idempotency check.

Copy link
Contributor

Choose a reason for hiding this comment

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

then why check new not None?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in this case we should just remove this check.... and then it will fall under else.

Copy link
Contributor

Choose a reason for hiding this comment

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

actually i would suggest keep none check inside this function. as a function, you cannot have assumption on what will be passed in. it's hard to rely on caller to do none 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.

well, I just removed it, if it's None it will fall under else, and there will be just == comparison, which will return True if old is also None, or False if old is something else.

if new is None:
return True
elif isinstance(new, dict):
if not isinstance(old, dict):
Copy link
Contributor

Choose a reason for hiding this comment

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

if new is dict, and old is None, that means previously user didn't set some properties(None), now, user want to update it(dict), why return False?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so that correct, returning False will trigger update.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok. so true if compare equals, false if not. Seems like equal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, exactly

return False
return True
elif isinstance(new, list):
if not isinstance(old, list) or len(new) != len(old):
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above, if old is None. such as previous rules is None

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so we will return False and that will trigger update.

@yungezz
Copy link
Contributor

yungezz commented Nov 14, 2018

the compare method is ok for this module specific. while if want to make it general, need rethink the interface and compare way, actually it's equal. equal need 2 params, and third one is optional, such as sort order, comparator etc. suggest to compare by keys matching one by one, instead of requires a dict of k, with some not-so-straight-forward values: index, default etc.

@zikalino
Copy link
Contributor Author

@yungezz I am going to propose extended method. it will be very simple.
default method + last parameter will be a list of "exceptions". sth like that.
so for 95% of modules this method will work.

@zikalino zikalino merged commit 7db4352 into ansible:devel Nov 14, 2018
@zikalino zikalino deleted the lb-fixing-idempotency branch November 14, 2018 08:57
mjmayer pushed a commit to mjmayer/ansible that referenced this pull request Nov 30, 2018
Tomorrow9 pushed a commit to Tomorrow9/ansible that referenced this pull request Dec 4, 2018
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 azure bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants