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

Set defaults from params after loading files, allowing params to override #44142

Merged
merged 2 commits into from Sep 10, 2018

Conversation

fabianvf
Copy link
Contributor

SUMMARY

I think this should give parameters to the module priority over incluster/kubeconfig-based authentication.

Fixes #43845

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

k8s

ANSIBLE VERSION
ansible 2.7.0.dev0 (k8s-reorder-auth fd7b1b14ce) last updated 2018/08/14 16:29:11 (GMT -400)
  config file = /home/fabian/tmp/reproducer/ansible/ansible.cfg
  configured module search path = [u'/home/fabian/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/fabian/tmp/reproducer/ansible/lib/ansible
  executable location = /home/fabian/tmp/reproducer/ansible/bin/ansible
  python version = 2.7.15 (default, May 15 2018, 15:37:31) [GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]

@ansibot
Copy link
Contributor

ansibot commented Aug 14, 2018

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Aug 14, 2018
if auth_method == 'params':
return DynamicClient(kubernetes.client.ApiClient(configuration))
configuration = kubernetes.client.Configuration()
for key, value in iteritems(auth):
Copy link
Contributor

Choose a reason for hiding this comment

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

should be auth.items() for python 2 and 3 compatibility.

Edit: I see iteritems comes from six, I'm just not sure why it's needed when auth.items() will work fine

@@ -139,46 +139,37 @@ def get_api_client(self, **auth_params):
auth_params = auth_params or getattr(self, 'params', {})
auth = copy.deepcopy(auth_params)

configuration = kubernetes.client.Configuration()
# Pull authorization settings from environment variables
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment here should be more extensive and state precisely what order we're processing configuration.

@ansibot
Copy link
Contributor

ansibot commented Aug 14, 2018

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

lib/ansible/module_utils/k8s/common.py:150:13: E129 visually indented line with same indent as next logical line
lib/ansible/module_utils/k8s/common.py:162:9: E303 too many blank lines (2)
lib/ansible/module_utils/k8s/common.py:174:5: E303 too many blank lines (2)

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_triage Needs a first human triage before being processed. labels Aug 14, 2018

kubernetes.client.Configuration.set_default(configuration)
return DynamicClient(kubernetes.client.ApiClient(configuration))


def client_from_kubeconfig(self, config_file, context):
Copy link
Contributor

Choose a reason for hiding this comment

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

After this refactor this method is no longer referenced, probably safe to remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, definitely

@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Aug 16, 2018
@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 Aug 25, 2018
@fabianvf
Copy link
Contributor Author

@maxamillion I've fixed the client issue that caused the build to fail, can we rekick?

@ansibot ansibot added stale_review Updates were made after the last review and the last review is more than 7 days old. and 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. labels Aug 28, 2018
@fabianvf fabianvf changed the title [wip] Set defaults from params after loading files, allowing params to override Set defaults from params after loading files, allowing params to override Aug 31, 2018
@fabianvf
Copy link
Contributor Author

@willthames, mind doing another pass?

@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 Sep 8, 2018
@marwatk
Copy link
Contributor

marwatk commented Sep 10, 2018

@willthames, any chance you could take a look at this? I'd love to ditch my local patch...

@fabianvf
Copy link
Contributor Author

@willthames @maxamillion can we get this reviewed and merged soon so we can get this into 2.7 before release?

@maxamillion
Copy link
Contributor

rebuild_merge

@maxamillion
Copy link
Contributor

maxamillion commented Sep 10, 2018

@fabianvf one this merges, we'll need a backport PR against stable-2.7, CC me on it and I'll coordinate with the 2.7 release manager

@maxamillion maxamillion dismissed willthames’s stale review September 10, 2018 16:51

was asked for response 10 days ago, but still no response.

@maxamillion
Copy link
Contributor

rebuild_merge

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. 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 Sep 10, 2018
@maxamillion
Copy link
Contributor

rebuild_merge

@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Sep 10, 2018
@ansibot ansibot merged commit aa01d9d into ansible:devel Sep 10, 2018
fabianvf added a commit to fabianvf/ansible that referenced this pull request Sep 10, 2018
…ride (ansible#44142)

* Set defaults from params after loading files, allowing params to override

* cleanup, add some comments

(cherry picked from commit aa01d9d)
abadger pushed a commit that referenced this pull request Sep 11, 2018
…ride (#45442)

* Set defaults from params after loading files, allowing params to override (#44142)

* Set defaults from params after loading files, allowing params to override

* cleanup, add some comments

(cherry picked from commit aa01d9d)

* Add client_from_kubeconfig function back for 2.7.0 since it's late in the 2.7 cycle to remove module_util code.
ndswartz pushed a commit to ndswartz/ansible that referenced this pull request Nov 28, 2018
…ride (ansible#45442)

* Set defaults from params after loading files, allowing params to override (ansible#44142)

* Set defaults from params after loading files, allowing params to override

* cleanup, add some comments

(cherry picked from commit aa01d9d)

* Add client_from_kubeconfig function back for 2.7.0 since it's late in the 2.7 cycle to remove module_util code.
@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.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

k8s verify_ssl=no still verifies certificate.
5 participants