Skip to content

KPO: Add Typing on Security Context - #31275

Closed
kbumsik wants to merge 1 commit into
apache:mainfrom
kbumsik:security-context
Closed

KPO: Add Typing on Security Context#31275
kbumsik wants to merge 1 commit into
apache:mainfrom
kbumsik:security-context

Conversation

@kbumsik

Copy link
Copy Markdown

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.
@boring-cyborgboring-cyborgBot added provider:cncf-kubernetes Kubernetes (k8s) provider related issues area:providers labels May 14, 2023
@boring-cyborg

Copy link
Copy Markdown

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

@hussein-awalahussein-awala left a comment

Copy link
Copy Markdown
Member

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:

deftest_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))
assertpod.spec.security_context==security_context
deftest_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))
assertpod.spec.containers[0].security_context==container_security_context

@hussein-awalahussein-awala left a comment

Copy link
Copy Markdown
Member

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:

deftest_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))
assertpod.spec.security_context==security_context
deftest_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))
assertpod.spec.containers[0].security_context==container_security_context

@github-actions

Copy link
Copy Markdown
Contributor

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-actionsgithub-actionsBot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Jun 29, 2023
@amoghrajesh

Copy link
Copy Markdown
Contributor

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

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providersprovider:cncf-kubernetesKubernetes (k8s) provider related issuesstaleStale PRs per the .github/workflows/stale.yml policy file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@kbumsik@amoghrajesh@hussein-awala