Skip to content

Conversation

@kbumsik
Copy link

@kbumsik kbumsik commented May 14, 2023

This commit is to add appropriate k8s typing on KubernetesPodOperator's security_context and container_security_context field.

This commit is to add appropriate k8s typing on KubernetesPodOperator's
security_context and container_security_context field.
@kbumsik kbumsik requested a review from jedcunningham as a code owner May 14, 2023 09:58
@boring-cyborg boring-cyborg bot added provider:cncf-kubernetes Kubernetes (k8s) provider related issues area:providers labels May 14, 2023
@boring-cyborg
Copy link

boring-cyborg bot commented May 14, 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

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.

Although providing a dictionary for these variables is acceptable in most cases, it is not recommended. +1 for changing the types to align with the Kubernetes client types.

Please remember to update the tests and replace the dictionary values with the appropriate objects. For ex:

def test_security_context(self):
security_context = {
"runAsUser": 1245,
}
k = KubernetesPodOperator(
security_context=security_context,
task_id="task",
)
pod = k.build_pod_request_obj(create_context(k))
assert pod.spec.security_context == security_context
def test_container_security_context(self):
container_security_context = {"allowPrivilegeEscalation": False}
k = KubernetesPodOperator(
container_security_context=container_security_context,
task_id="task",
)
pod = k.build_pod_request_obj(create_context(k))
assert pod.spec.containers[0].security_context == container_security_context

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.

Although providing a dictionary for these variables is acceptable in most cases, it is not recommended. +1 for changing the types to align with the Kubernetes client types.

Please remember to update the tests and replace the dictionary values with the appropriate objects. For ex:

def test_security_context(self):
security_context = {
"runAsUser": 1245,
}
k = KubernetesPodOperator(
security_context=security_context,
task_id="task",
)
pod = k.build_pod_request_obj(create_context(k))
assert pod.spec.security_context == security_context
def test_container_security_context(self):
container_security_context = {"allowPrivilegeEscalation": False}
k = KubernetesPodOperator(
container_security_context=container_security_context,
task_id="task",
)
pod = k.build_pod_request_obj(create_context(k))
assert pod.spec.containers[0].security_context == container_security_context

@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 Jun 29, 2023
@github-actions github-actions bot closed this Jul 4, 2023
@amoghrajesh
Copy link
Contributor

This PR seems to have gone stale. I will lead it to completion. Good find @kbumsik!

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 (k8s) 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.

3 participants