Skip to content

Conversation

@DavidHuie
Copy link
Contributor

@DavidHuie DavidHuie commented Apr 2, 2019

This PR fixes two different bugs: a missing import and a tempfile issue. The existence of both of these bugs actually prevents using kubeconfig files containing certificates. More precise descriptions of the fixes are in the commit messages.

@k8s-ci-robot k8s-ci-robot requested review from drubin and mbohlool April 2, 2019 13:24
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 2, 2019
@DavidHuie
Copy link
Contributor Author

CLA updated.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Apr 2, 2019
@DavidHuie
Copy link
Contributor Author

This change is also included in #39.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Apr 2, 2019
@DavidHuie DavidHuie changed the title Require 'kubernetes/utils' Fix issues with certificate based auth Apr 2, 2019
@DavidHuie DavidHuie force-pushed the add-missing-require branch from 0b96619 to 4ea5dad Compare April 2, 2019 14:07
@DavidHuie DavidHuie closed this Apr 2, 2019
@DavidHuie DavidHuie reopened this Apr 2, 2019
@DavidHuie
Copy link
Contributor Author

@drubin also cc: @brendandburns

Copy link
Contributor

@drubin drubin left a comment

Choose a reason for hiding this comment

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

Just had a few questions around tests (so we don't break these fixes in future).

But the changes make sense.

end
end

context 'when it is already called' do
Copy link
Contributor

Choose a reason for hiding this comment

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

@DavidHuie We should maybe adjust this test so that it works with the given refactoring.

If we remove it entirely we don't have a test that checks the caching functionality isn't removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. I re-wrote the test to use the newest bit of code.

require 'kubernetes/api_client'
require 'kubernetes/configuration'
require 'kubernetes/config/error'
require 'kubernetes/utils'
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean we were missing a test that would have highlighted this?

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, although I think getting the import situation completely fixed is a bit out of the scope of this PR. IMO, all require calls should just be made within kubernetes/lib/kubernetes.rb so things like this aren't missed.

Without this import, `Kubernetes` module functions like
`Kubernetes.create_temp_file_and_set` aren't actually useable from
within the `KubeConfig` class, breaking certificate-based auth.
We currently save the string *path* to tempfiles within the
`@temp_files` cache in the `Kubernetes` module. This is incorrect
because tempfiles are deleted when Ruby garbage collects the parent
`Tempfile` instance.

This change replaces the string path with the `Tempfile` instance so
that the files exist indefinitely. I also drop the function
`cache_temp_file` since it's unused and its behavior is incorrect with
regards to tempfiles.
@DavidHuie DavidHuie force-pushed the add-missing-require branch from 4ea5dad to 7205308 Compare April 5, 2019 14:32
@brendandburns
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 7, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, DavidHuie

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 7, 2019
@k8s-ci-robot k8s-ci-robot merged commit 2571273 into kubernetes-client:master Apr 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants