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

Deploy a sweeper pod to clear completed pod histories #4500

Merged
merged 9 commits into from
Jul 7, 2021

Conversation

ChristopheDuong
Copy link
Contributor

What

Closes #3634

How

Deploy a separate pod sweeper using shell command

command:
- /bin/sh
- -c
- while :; do kubectl get pod | grep Completed | awk '{print $1}' | xargs --no-run-if-empty kubectl delete pod | xargs --no-run-if-empty echo `date "+%Y-%m-%d %H:%M:%S"`; sleep 300; done
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't handle namespaced airbyte deployments. It also doesn't limit itself to just pods that were created as part of Airbyte.

Probably the easiest way to do this is to add a label to all connector pods / command fetcher pods that makes it easy to kubectl get them by this label. Then you can also insert the namespace used in a similar way that we pulled it in as an env variable before, and use that to scope the search for pods.

Copy link
Contributor

@jrhizor jrhizor left a comment

Choose a reason for hiding this comment

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

Needs to address some more edge cases but I like the simple bash pod approach.

@github-actions github-actions bot added the area/worker Related to worker label Jul 2, 2021
Copy link
Contributor

@jrhizor jrhizor left a comment

Choose a reason for hiding this comment

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

Looks good.

We should only clear pods that are not Running and that are older than maybe 1 day. Right now I think this will kill things that are currently running.

It would be nice to also log the name and status for deleted pod on the sweeper.

@ChristopheDuong
Copy link
Contributor Author

We should only clear pods that are not Running and that are older than maybe 1 day.

There is a grep on Completed, is it possible for them to be completed and running at the same time?

@jrhizor
Copy link
Contributor

jrhizor commented Jul 2, 2021

Pods might be stuck in an Error or Pending state, so I think the "not running" condition might be better than "completed". And if we're going to sweep those states we probably want a time window for debugging the pods.

@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Jul 5, 2021
Copy link
Contributor

@jrhizor jrhizor left a comment

Choose a reason for hiding this comment

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

nice!

@ChristopheDuong ChristopheDuong merged commit af57170 into master Jul 7, 2021
@ChristopheDuong ChristopheDuong deleted the chris/pod-sweeper branch July 7, 2021 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Improvements or additions to documentation area/worker Related to worker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add retention policies for pod histories
3 participants