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

ValueError: invalid literal for int() with base 10 #1072

Closed
frodre opened this issue Feb 6, 2020 · 2 comments
Closed

ValueError: invalid literal for int() with base 10 #1072

frodre opened this issue Feb 6, 2020 · 2 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@frodre
Copy link

frodre commented Feb 6, 2020

What happened (please include outputs or screenshots):

In [3]: kube.config.load_kube_config()                                                                                                                                                                      
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-23e550793f86> in <module>
----> 1 kube.config.load_kube_config()

~/miniconda3/envs/fv3net/lib/python3.7/site-packages/kubernetes/config/kube_config.py in load_kube_config(config_file, context, client_configuration, persist_config)
    647     if client_configuration is None:
    648         config = type.__call__(Configuration)
--> 649         loader.load_and_set(config)
    650         Configuration.set_default(config)
    651     else:

~/miniconda3/envs/fv3net/lib/python3.7/site-packages/kubernetes/config/kube_config.py in load_and_set(self, client_configuration)
    459 
    460     def load_and_set(self, client_configuration):
--> 461         self._load_authentication()
    462         self._load_cluster_info()
    463         self._set_config(client_configuration)

~/miniconda3/envs/fv3net/lib/python3.7/site-packages/kubernetes/config/kube_config.py in _load_authentication(self)
    201         if not self._user:
    202             return
--> 203         if self._load_auth_provider_token():
    204             return
    205         if self._load_user_token():

~/miniconda3/envs/fv3net/lib/python3.7/site-packages/kubernetes/config/kube_config.py in _load_auth_provider_token(self)
    216             return
    217         if provider['name'] == 'gcp':
--> 218             return self._load_gcp_token(provider)
    219         if provider['name'] == 'azure':
    220             return self._load_azure_token(provider)

~/miniconda3/envs/fv3net/lib/python3.7/site-packages/kubernetes/config/kube_config.py in _load_gcp_token(self, provider)
    257                 ('access-token' not in provider['config']) or
    258                 ('expiry' in provider['config'] and
--> 259                  _is_expired(provider['config']['expiry']))):
    260             # token is not available or expired, refresh it
    261             self._refresh_gcp_token()

~/miniconda3/envs/fv3net/lib/python3.7/site-packages/kubernetes/config/kube_config.py in _is_expired(expiry)
     77 
     78 def _is_expired(expiry):
---> 79     return ((parse_rfc3339(expiry) - EXPIRY_SKEW_PREVENTION_DELAY) <=
     80             datetime.datetime.utcnow().replace(tzinfo=UTC))
     81 

~/miniconda3/envs/fv3net/lib/python3.7/site-packages/kubernetes/config/dateutil.py in parse_rfc3339(s)
     59         dt[x] = int(groups[x])
     60     if groups[6] is not None:
---> 61         dt[6] = int(groups[6])
     62     tz = UTC
     63     if groups[7] is not None and groups[7] != 'Z' and groups[7] != 'z':

ValueError: invalid literal for int() with base 10: '.906455339'

What you expected to happen:
The configuration to load

How to reproduce it (as minimally and precisely as possible):
The GCP credentials expiration string has some decimal fraction of seconds specified in the time stamp. Then the following command fails.

import kubernetes as kube
kube.config.load_kube_config()

Specifically in kubernetes.config.dateutil the function parse_rfc3339 with the input 2020-02-06T01:10:34.194986955Z fails.

Anything else we need to know?:

Dumb fix (always results in 0)
dt[6] = int(float(groups[6]))

It should probably be converted to microseconds or something useful?

Environment:

  • Kubernetes version (kubectl version):
    Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.2", GitCommit:"59603c6e503c87169aea6106f57b9f242f64df89", GitTreeState:"clean", BuildDate:"2020-01-21T22:17:28Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"linux/amd64"}
    Server Version: version.Info{Major:"1", Minor:"13+", GitVersion:"v1.13.11-gke.14", GitCommit:"56d89863d1033f9668ddd6e1c1aea81cd846ef88", GitTreeState:"clean", BuildDate:"2019-11-07T19:12:22Z", GoVersion:"go1.12.11b4", Compiler:"gc", Platform:"linux/amd64"}
  • OS (e.g., MacOS 10.13.6):
    Google Compute Instance
    OS Details:
    NAME="Ubuntu"
    VERSION="18.04.3 LTS (Bionic Beaver)"
    ID=ubuntu
    ID_LIKE=debian
    PRETTY_NAME="Ubuntu 18.04.3 LTS"
    VERSION_ID="18.04"
    HOME_URL="https://www.ubuntu.com/"
    SUPPORT_URL="https://help.ubuntu.com/"
    BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
    PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
    VERSION_CODENAME=bionic
    UBUNTU_CODENAME=bionic
    Machine Details:
canIpForward: false
cpuPlatform: Intel Cascade Lake
creationTimestamp: '2019-09-23T17:17:47.323-07:00'
machineType: https://www.googleapis.com/compute/v1/projects/vcm-ml/zones/us-central1-a/machineTypes/n2-standard-4
zone: https://www.googleapis.com/compute/v1/projects/vcm-ml/zones/us-central1-a
  • Python version (python --version)
    Python 3.7.6
  • Python client version (pip list | grep kubernetes)
    kubernetes 10.0.1
@frodre frodre added the kind/bug Categorizes issue or PR as related to a bug. label Feb 6, 2020
@roycaihw
Copy link
Member

roycaihw commented Mar 9, 2020

The issue has been fixed by kubernetes-client/python-base#150. The fix is included in 11.0.0a1 and later releases

/close

@k8s-ci-robot
Copy link
Contributor

@roycaihw: Closing this issue.

In response to this:

The issue has been fixed by kubernetes-client/python-base#150. The fix is included in 11.0.0a1 and later releases

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants