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

Delete temporary resources when agent completes #54

Closed
Tracked by #236
carolynvs opened this issue Nov 8, 2021 · 5 comments
Closed
Tracked by #236

Delete temporary resources when agent completes #54

carolynvs opened this issue Nov 8, 2021 · 5 comments
Assignees
Labels
0 - 🚨🍩 Emergency donugts come first
Milestone

Comments

@carolynvs
Copy link
Member

carolynvs commented Nov 8, 2021

When the agent completes, delete any temporary resources created by the operator such as: jobs, pvcs, secrets.

@carolynvs carolynvs added this to the v1 milestone Nov 18, 2021
@carolynvs
Copy link
Member Author

@carolynvs
Copy link
Member Author

It would be nice to have some configuration options:

  • feature flag to disable pruning
  • TTL or some other way to say how long to keep them before deleting
  • Possibly keep failed runs longer or treat differently than passing jobs

@carolynvs carolynvs added the 0 - 🚨🍩 Emergency donugts come first label Feb 2, 2023
@carolynvs
Copy link
Member Author

carolynvs commented Feb 2, 2023

We could use the built-in cleanup offered in k8s (https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/), but it will delete the resource based on the configured TTL when the job finishes(the job status is completed or failed).
What we can do is keep the finalizer on the resource longer and change the configured TTL if we want to hold off on cleanup until some other condition (like giving a failed run an hour for troubleshooting for example).

@carolynvs carolynvs self-assigned this Apr 27, 2023
@carolynvs
Copy link
Member Author

carolynvs commented Apr 27, 2023

The plan is to add TTLSecondsAfterFinished to AgentConfig. This controls how an AgentAction and associated resources (job, pv, pvc, secrets, etc) should remain after the action finishes (success or failure). We will apply that value to the Agent Job and watch for its deletion. When it's deleted, we will remove our finalizer to allow it to delete, and then delete the parent AgentAction.

Resources created by the operator

  • Agent Job
  • Agent PVC
  • Agent PV (share bundle outputs and files between porter and the bundle)
  • Porter Config Secret
  • Porter WorkDir Secret

Resources created by the agent (k8s driver)

  • Bundle Job
  • Bundle Secret (inject env vars into bundle)

I have created cnabio/cnab-go#300 to track supporting owner references in the k8s driver

@carolynvs
Copy link
Member Author

I chose to not go with the operator framework pruning library because it would be on us to schedule and call it regularly. There aren't any documented best practices on how to run that in an operator at this time and I didn't find any use of the library in existing projects to look for ideas.

The simplicity of pawning off the pruning trigger onto k8s instead seems more reliable to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 - 🚨🍩 Emergency donugts come first
Projects
Status: Done
Status: Done
Development

No branches or pull requests

2 participants