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

[k8s] Suppress insecure request warnings #3888

Merged
merged 3 commits into from
Sep 9, 2024
Merged

Conversation

romilbhardwaj
Copy link
Collaborator

If user uses disables tls for k8s with insecure-skip-tls-verify in their kubeconfig, urllib3 prints warnings for each connection:

/Users/romilb/tools/anaconda3/lib/python3.9/site-packages/urllib3/connectionpool.py:1103: InsecureRequestWarning: Unverified HTTPS request is being made to host '150.136.46.159'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
  warnings.warn(

This PR disables warnings with the method recommended by urllib3.

Tested (run the relevant ones):

  • Code formatting: bash format.sh
  • Manual tests to verify warnings are no longer printed.

@@ -18,6 +18,8 @@
urllib3 = common.LazyImport('urllib3',
import_error_message=_IMPORT_ERROR_MESSAGE)

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will cause urllib3 being imported when the adaptors being imported, which may cause errors when skypilot is not installed with skypilot[kubernetes] or skypilot[all].

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, we only specify urllib3 in the dependency of aws, we should have it specified for kubernetes as well in setup.py

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, I have moved it to _load_config so that it is invoked only when a) _configured=False and b) other import checks have already been run.

urllib3 does not need to be explicitly specified in setup.py, since the kubernetes package depends on urllib3 and urllib3 will automatically be installed when kubernetes is installed.

Copy link
Collaborator

@Michaelvll Michaelvll left a comment

Choose a reason for hiding this comment

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

LGTM!

@romilbhardwaj romilbhardwaj added this pull request to the merge queue Sep 9, 2024
Merged via the queue into master with commit 145d728 Sep 9, 2024
20 checks passed
@romilbhardwaj romilbhardwaj deleted the k8s_tls_suppress branch September 9, 2024 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants