vincbeck commented on code in PR #77412:
URL: https://github.com/apache/airflow/pull/77412#discussion_r4647246685
##########
providers/amazon/tests/unit/amazon/aws/executors/eks/test__client_factory.py:
##########
@@ -325,13 +325,41 @@ def write_keys(access_key_id):
assert _signing_key_id(configuration) == "AKIASECONDKEY"
-def _unauthorized(api_exception_cls):
- error = api_exception_cls(status=401, reason="Unauthorized")
+def _returns_rejected_responses(api_exception_cls) -> bool:
+ # kubernetes 37 returns a rejected response from ApiClient.call_api and
raises the error later.
+ return api_exception_cls is client.ApiException and
_client_factory._KUBERNETES_MAJOR_VERSION >= 37
+
+
+def _rejection(api_exception_cls, status=401):
+ """What the transport yields for a rejected request: an exception to
raise, or on kubernetes 37 a response."""
+ error = api_exception_cls(status=status, reason="Rejected")
# The client decodes the body of a failed response before raising it.
- error.body = b'{"kind":"Status","code":401,"reason":"Unauthorized"}'
+ error.body = b'{"kind":"Status"}'
+ if _returns_rejected_responses(api_exception_cls):
+ return mock.create_autospec(
+ client.rest.RESTResponse, instance=True, status=status,
reason=error.reason, data=error.body
+ )
return error
+def _reject(api_exception_cls, status=401):
+ rejection = _rejection(api_exception_cls, status)
+ if isinstance(rejection, Exception):
+ raise rejection
+ return rejection
+
+
+def _pods_response():
+ return mock.create_autospec(
+ client.rest.RESTResponse, instance=True, status=200, data=b'{"items":
[]}', response=mock.sentinel.raw
+ )
+
+
+def _result_of(pods, api_exception_cls):
+ # With _preload_content=False, kubernetes 37 hands back the raw response
wrapped by the transport's.
Review Comment:
All the 401 tests use `_preload_content=False`. Should we also cover the
default path, where on 37 the retried response goes through
`response_deserialize`? That's the path pod creation uses.
##########
providers/amazon/tests/unit/amazon/aws/executors/eks/test__client_factory.py:
##########
@@ -325,13 +325,41 @@ def write_keys(access_key_id):
assert _signing_key_id(configuration) == "AKIASECONDKEY"
-def _unauthorized(api_exception_cls):
- error = api_exception_cls(status=401, reason="Unauthorized")
+def _returns_rejected_responses(api_exception_cls) -> bool:
Review Comment:
`cncf.kubernetes` still pins `kubernetes<37`, so CI only runs the 36 shapes
here and none of these tests fail if the fix is reverted. Is the plan to merge
this first and let #77374 cover 37?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]