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

Reconnect on read_pods when k8s auth fails #32719

Closed
wants to merge 2 commits into from

Conversation

kannon92
Copy link

closes: #32718

I have a patch from my client that they use to reconnect pods with KPO in the case of an expiring token.

Opening this up as is and happy to discuss better ideas!

Essentially we want to reconnect/reauthenticate on read_pods as we found that when the token expires our tasks start getting 401 errors.

@boring-cyborg boring-cyborg bot added provider:cncf-kubernetes Kubernetes provider related issues area:providers labels Jul 20, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented Jul 20, 2023

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@kannon92 kannon92 changed the title add a patch fix for reconnecting on read_pods for caes where k8 auth … Reconnect on read_pods when k8s auth fails Jul 26, 2023
@kannon92
Copy link
Author

@hussein-awala or @jedcunningham can I get CI approval to run the tests? I think I took some merges with the kubernetes cleanup and it caused some extra issues. I ran precommit and breeze and I think it should be good again.

Copy link
Member

@hussein-awala hussein-awala left a comment

Choose a reason for hiding this comment

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

This change could fix your issue, but it will impact the performance of the KP operator and hook. I need to check how the Kubernetes python client handle the ExecCredentials and if there is another way or a a workaround to fix the issue without loading the client before each call. (for example through refresh_api_key_hook parameter).

And if not, maybe we can add a new parameter for client reloading and set it to False by default, and load the client only when it's True, something like:

- @cached_property
+ @property
def get_conn:
-  #prepare client
-  return client
+  if reload_client or not self.__cached_client:
+    self.__cached_client: = #prepare client
+  self.__cached_client:

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Sep 12, 2023
@github-actions github-actions bot closed this Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:cncf-kubernetes Kubernetes provider related issues stale Stale PRs per the .github/workflows/stale.yml policy file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kubernetes Pod Operator Auth Failure if Token expires
3 participants