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

Add logging support for init containers in KubernetesPodOperator (#42498) #43853

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

mrk-andreev
Copy link
Contributor

@mrk-andreev mrk-andreev commented Nov 9, 2024

This change adds an option to print logs for init containers. The init_container_logs argument enables the display of logs specifically for spec.initContainers (not spec.containers).

Fixes: #42498

@potiuk
Copy link
Member

potiuk commented Nov 9, 2024

@dstandish @jedcunningham @jscheffl @hussein-awala -> that one was submitted during the Man's Hackathon - I am not sure if I am competent enough to review the details, but it looks good at a first glance, I'd need someone more k8s-api-involved to review it :)

Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

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

I also only feel 50% competent, added some feedback from just code reading.

I am not an K8s expert, can init containers run in parallel? Or are they executed serial?
How about if init containers run for a longer time? Would it be interesting to stream logs while they are running to see progress? And if they run in parallel would it mix logs?

@mrk-andreev
Copy link
Contributor Author

I am not an K8s expert, can init containers run in parallel? Or are they executed serial?
How about if init containers run for a longer time? Would it be interesting to stream logs while they are running to see progress? And if they run in parallel would it mix logs?

Each init container runs sequentially, with each one waiting for the previous container to complete. The main containers wait until all init containers are ready before starting.

Ref: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/#understanding-init-containers

Init containers are exactly like regular containers, except:

  • Init containers always run to completion.
  • Each init container must complete successfully before the next one starts.

@mrk-andreev mrk-andreev force-pushed the issue-42498 branch 2 times, most recently from d58a784 to c77bc4d Compare November 10, 2024 00:06
@mrk-andreev mrk-andreev changed the title Add support logging in KubernetesPodOperator (#42498) Add logging support for init containers in KubernetesPodOperator (#42498) Nov 10, 2024
@mrk-andreev mrk-andreev force-pushed the issue-42498 branch 2 times, most recently from c0e0a1d to bbb224d Compare November 10, 2024 22:41
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.

Overall it looks good, just need to check if the pod was started before you start reading the logs from init containers, the rest is nit.

@mrk-andreev mrk-andreev force-pushed the issue-42498 branch 4 times, most recently from 15527a3 to 9baf12d Compare November 12, 2024 22:57
@mrk-andreev mrk-andreev force-pushed the issue-42498 branch 2 times, most recently from fb62e27 to e710eae Compare November 14, 2024 23:51
@mrk-andreev
Copy link
Contributor Author

Hi @jscheffl, @hussein-awala, @dstandish, @potiuk, @jedcunningham

Does this PR need any additional changes? Are there any blockers we should address? Let me know how I can help to move it forward!

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

LGTM. But I think some questions/answers need confirmation from @hussein-awala and @dstandish

@potiuk
Copy link
Member

potiuk commented Dec 3, 2024

Can you rebase in the meantime @mrk-andreev ?

Copy link
Contributor

@eladkal eladkal left a comment

Choose a reason for hiding this comment

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

LGTM

If no further comments I will merge this PR for next provider wave

@potiuk
Copy link
Member

potiuk commented Dec 16, 2024

LGTM

If no further comments I will merge this PR for next provider wave

Let's. I think it looks good.

…che#42498)

This change adds an option to print logs for init containers. The get_init_containers_logs and init_container_logs functions allow displaying the logs of init containers.

Fixes: apache#42498
@potiuk
Copy link
Member

potiuk commented Dec 16, 2024

I rebased it - and let's give @dstandish and @hussein-awala last chance to comment.

@potiuk potiuk merged commit 60eced9 into apache:main Dec 17, 2024
76 checks passed
LefterisXefteris pushed a commit to LefterisXefteris/airflow that referenced this pull request Jan 5, 2025
…che#42498) (apache#43853)

This change adds an option to print logs for init containers. The get_init_containers_logs and init_container_logs functions allow displaying the logs of init containers.

Fixes: apache#42498
agupta01 pushed a commit to agupta01/airflow that referenced this pull request Jan 6, 2025
…che#42498) (apache#43853)

This change adds an option to print logs for init containers. The get_init_containers_logs and init_container_logs functions allow displaying the logs of init containers.

Fixes: apache#42498
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kubernetes Pod Operator Init container logging
6 participants