aliyun-openapi-python-sdk icon indicating copy to clipboard operation
aliyun-openapi-python-sdk copied to clipboard

aliyunsdkcore/auth/signers/ecs_ram_role_signer TypeError

Open aldojimenez opened this issue 7 years ago • 5 comments

https://github.com/aliyun/aliyun-openapi-python-sdk/blob/f0b2a41e01ea09e552a23720bf0f757bfcb37291/aliyun-python-sdk-core/aliyunsdkcore/auth/signers/ecs_ram_role_signer.py#L54

Summary Python script used for pushing custom metric to Cloud Monitor which is executed from an ECS instance within a scaling group. The python script uses the EcsRamRoleSigner for authentication

The Error The Signer automatically calls the def _check_session_credential(self) on subsequent API calls, but this function fails with the following error:

Traceback (most recent call last): File "c:\push_metric\push_custom_metric.py", line 166, in main(args) File "c:\push_metric\push_custom_metric.py", line 136, in main targets = get_active_instances(client, ess_id) File "c:\push_metric\push_custom_metric.py", line 98, in get_active_instances response = client.do_action_with_exception(ess_request) File "C:\Python27\lib\site-packages\aliyunsdkcore\client.py", line 258, in do_action_with_exception status, headers, body = self.implementation_of_do_action(acs_request) File "C:\Python27\lib\site-packages\aliyunsdkcore\client.py", line 224, in implementation_of_do_action http_response = self._make_http_response(endpoint, request, signer) File "C:\Python27\lib\site-packages\aliyunsdkcore\client.py", line 183, in _make_http_response header, url = signer.sign(self.__region_id, request) File "C:\Python27\lib\site-packages\aliyunsdkcore\auth\signers\ecs_ram_role_singer.py", line 39, in sign self._check_session_credential() File "C:\Python27\lib\site-packages\aliyunsdkcore\auth\signers\ecs_ram_role_singer.py", line 52, in _check_session_cre dential if now - self._last_update_time > (self._expiration * self._REFRESH_SCALE): TypeError: can't multiply sequence by non-int of type 'float'

Reason self._expiration is not an int, it is a datetime unicode string with the following format: 2019-01-14T13:45:02Z

Temporary workaround Changing line 54 to if now >= (time.mktime(exp_date):

aldojimenez avatar Jan 14 '19 10:01 aldojimenez

Thanks for your feedback, we will fix this problem as soon as possible.

Qingtang-SDK avatar Jan 14 '19 10:01 Qingtang-SDK

Encountered this bug with our service as well. I think this bug was fixed with https://github.com/aliyun/aliyun-openapi-python-sdk/commit/d58094fc58bad4, so hopefully out in the next release

edmundlam avatar Jan 28 '19 21:01 edmundlam

Hi, this bug has been fixed in our newest version, please update your aliyun-python-sdk-core and try again. Thank you, and have a good day!

Suvie277 avatar Jan 29 '19 02:01 Suvie277

Hello, @wallisyan, we have this issue when using aliyun-python-sdk-core==2.12.0 which appears to be the latest release on PyPi (released Jan 11th, 2019). https://pypi.org/project/aliyun-python-sdk-core/#history

Is there a new version out already or coming out soon that will include commit https://github.com/aliyun/aliyun-openapi-python-sdk/commit/d58094f (which was committed after 2.12.0 on Jan 25)?

edmundlam avatar Jan 29 '19 14:01 edmundlam

Sorry for the late response. The latest version 2.13.0 released on Feb 1.

Suvie277 avatar Feb 11 '19 07:02 Suvie277