[ 
https://issues.apache.org/jira/browse/AIRFLOW-6585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17211678#comment-17211678
 ] 

ASF GitHub Bot commented on AIRFLOW-6585:
-----------------------------------------

ashb commented on a change in pull request #11219:
URL: https://github.com/apache/airflow/pull/11219#discussion_r502780828



##########
File path: airflow/kubernetes/refresh_config.py
##########
@@ -24,15 +24,22 @@
 import logging
 import os
 import time
-from datetime import datetime
 from typing import Optional
 
+import pendulum
 import yaml
 from kubernetes.client import Configuration
 from kubernetes.config.exec_provider import ExecProvider
 from kubernetes.config.kube_config import KUBE_CONFIG_DEFAULT_LOCATION, 
KubeConfigLoader
 
 
+def _parse_timestamp(ts_str: str) -> int:
+    parsed_dt = pendulum.parse(ts_str)
+    if isinstance(parsed_dt, pendulum.DateTime):

Review comment:
       What's this for? Doesn't pendulum throw an error if it can't parse?

##########
File path: tests/kubernetes/test_refresh_config.py
##########
@@ -0,0 +1,31 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from unittest import TestCase
+
+from airflow.kubernetes.refresh_config import _parse_timestamp
+
+
+class TestRefreshKubeConfigLoader(TestCase):
+
+    def test_parse_timestamp_should_convert_z_timezone_to_unix_timestamp(self):
+        ts = _parse_timestamp("2020-01-13T13:42:20Z")
+        self.assertEqual(1578922940, ts)
+
+    def 
test_parse_timestamp_should_convert_regular_timezone_to_unix_timestamp(self):

Review comment:
       Could you test an error condition too?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Timestamp bug in RefreshKubeConfigLoader
> ----------------------------------------
>
>                 Key: AIRFLOW-6585
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-6585
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: executor-kubernetes, executors, hooks
>    Affects Versions: 1.10.7
>            Reporter: Jan Brusch
>            Assignee: Jan Brusch
>            Priority: Major
>
> When using the KubernetesPodOperator on an aws kubernetes cluster, the 
> aws-iam-authenticator is used to obtain kubernetes authentication tokens. The 
> aws tokens contain ISO-8601 formatted timestamps, which couldn't be parsed in 
> case of a "Z" (Zulu Time) timezone. This PR fixes this problem by converting 
> the "Z" timezone into a regular "+0000" format.
> Upon further review this is only a problem with python version <= 3.6. But 
> that should not keep the issue from being fixed.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to