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

postgresql_user: fix bugs related to 'expires' option #23862

Merged
merged 16 commits into from Jun 11, 2017

Conversation

pilou-
Copy link
Contributor

@pilou- pilou- commented Apr 21, 2017

SUMMARY

Add tests and fix various errors related to the expires option. The last 4 commits improve readability.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

postgresql_user

ANSIBLE VERSION
ansible-playbook 2.4.0 (devel 8ec4882ba0)
ADDITIONAL INFORMATION

Locally tested using:

ANSIBLE_REMOTE_USER=root ANSIBLE_ROLES_PATH=test/integration/targets ansible-playbook -i 'testhost,' -e ansible_host=10.0.1.129 --tags=test_postgresql,test_postgresql_db,test_postgresql_privs,test_postgresql_user,needs_privileged test/integration/destructive.yml

Related pull-requests:

@ansibot
Copy link
Contributor

ansibot commented Apr 21, 2017

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bugfix_pull_request 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. labels Apr 21, 2017
Copy link
Contributor

@mscherer mscherer left a comment

Choose a reason for hiding this comment

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

All look goods, just one question.

for i in range(len(current_role_attrs)):
if current_role_attrs[i] != new_role_attrs[i]:
changed = True
changed = current_role_attrs != new_role_attrs
Copy link
Contributor

Choose a reason for hiding this comment

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

So , would it work for all psycopg2 version ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

psycopg2.extras.DictRow was already here in 1.99.12 (which was released in march 2005).

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Apr 21, 2017
@pilou- pilou- changed the title postgresql_user: fix bugs related to 'expires' option [WIP] postgresql_user: fix bugs related to 'expires' option Apr 21, 2017
@ansibot ansibot added the WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. label Apr 21, 2017
@drrtuy
Copy link
Contributor

drrtuy commented May 2, 2017

There is one more problem with "expires" code: there is no column rol_valid_until in a pg_authid relation. So this code always compare expires with a None. It should be changed.

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label May 2, 2017
@pilou-
Copy link
Contributor Author

pilou- commented May 9, 2017

@drrtuy thanks for pointing that. I will update this pull request after the merge of #23686.

@pilou- pilou- force-pushed the postgresql_user_fix_valid_until branch from 4359c85 to fb1253c Compare May 31, 2017 02:08
@pilou- pilou- changed the title [WIP] postgresql_user: fix bugs related to 'expires' option postgresql_user: fix bugs related to 'expires' option May 31, 2017
@ansibot
Copy link
Contributor

ansibot commented May 31, 2017

@ansibot ansibot added needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. community_review In order to be merged, this PR must follow the community review workflow. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels May 31, 2017
@pilou- pilou- force-pushed the postgresql_user_fix_valid_until branch from fb1253c to 97dda60 Compare May 31, 2017 02:16
@ansibot
Copy link
Contributor

ansibot commented May 31, 2017

The test ansible-test sanity --test yamllint failed with the following error:

test/integration/targets/postgresql/tasks/test_no_password_change.yml:70:4: syntax error: expected <block end>, but found '<block sequence start>'

click here for bot help

@ansibot ansibot removed the needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html label May 31, 2017
@pilou- pilou- force-pushed the postgresql_user_fix_valid_until branch 4 times, most recently from d3a7acd to 018236b Compare May 31, 2017 14:11
@pilou- pilou- force-pushed the postgresql_user_fix_valid_until branch from c8e9495 to c8000d0 Compare May 31, 2017 15:58
@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels May 31, 2017
@pilou-
Copy link
Contributor Author

pilou- commented May 31, 2017

@matburt @drrtuy @mscherer : ready_for_review

from hashlib import md5
import itertools
import re

from distutils.version import StrictVersion
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd move the hashlib import down here... imports are usually

import stdlib_foo
from stdlib_foo import bar

import thridparty_foo
from thirdparty_foo import bar

import project_foo
from project_foo import bar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hashlib module belongs to the Python standard library (2.7, 3.6.1).

Copy link
Member

Choose a reason for hiding this comment

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

Based on @abadger's comment, due to it being from hashlib import md5 it should go below import re

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh right, I misunderstood! I fixed that and other PEP 8 related problems.

@mscherer
Copy link
Contributor

shipit

@abadger abadger merged commit 460d932 into ansible:devel Jun 11, 2017
@abadger
Copy link
Contributor

abadger commented Jun 11, 2017

Merged to devel. Doesn't cherrypick cleanly and I'm going on a one week vacation followed by ansiblefest London so I didn't want to backport it. If you think it should be backported, feel free to ask one of the other devs if they think it should be.

@pilou-
Copy link
Contributor Author

pilou- commented Jun 12, 2017

This pull-request contains 4 one-liner fixes and many commits related to the tests. Without the bugfixes, expires parameter isn't usable.

Are there any recommendations/policies about backport of bugfixes ?

I have created a branch based on stable-2.3 with the 4 one-liners cherry picked. I have referenced the squashed commit, should I use commit id before the squash instead ?

abadger pushed a commit that referenced this pull request Jul 7, 2017
… (#26539)

* Change 'valid until' even it's the only updated field

(cherry picked from commit 460d932)

* value is changed when another value is provided

(cherry picked from commit 460d932)

* value isn't returned when unset

(cherry picked from commit 460d932)

* Fix comparison between user input and applied configuration

(cherry picked from commit 460d932)
abadger added a commit that referenced this pull request Jul 7, 2017
abadger added a commit that referenced this pull request Jul 7, 2017
abadger pushed a commit that referenced this pull request Jul 7, 2017
… (#26539)

* Change 'valid until' even it's the only updated field

(cherry picked from commit 460d932)

* value is changed when another value is provided

(cherry picked from commit 460d932)

* value isn't returned when unset

(cherry picked from commit 460d932)

* Fix comparison between user input and applied configuration

(cherry picked from commit 460d932)

(cherry picked from commit 5432414)
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 6, 2018
@dagwieers dagwieers added the postgresql PostgreSQL community label Feb 1, 2019
@dagwieers dagwieers added the database Database category label Feb 13, 2019
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. community_review In order to be merged, this PR must follow the community review workflow. database Database category module This issue/PR relates to a module. postgresql PostgreSQL community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants