Skip to content

Conversation

@shreddedbacon
Copy link
Member

@shreddedbacon shreddedbacon commented Dec 2, 2023

This adds support for cleaning up unused services within an environment.

As Lagoon has typically not cleaned up in the past, this is a potentially dangerous operation in some cases. A user may be unaware that they may still be using or have an old service in their environment, and their application may still be using it.

There isn't any way to actually confirm if a service is still in used by an application during a build, so the action will be to warn and let the user decide on what action to take.

Maybe in the future removals will happen automatically and it will produce a warning still, but no choice in action.

Currently, this can detect and clean up any services, or dangling resources that a service created. In this case a typical service comprises of Kubernetes resources of the types Deployment, and then depending on the service, a Service and/or a PersistentVolumeClaim. A service can also be one of the DBaaS types.

Once the build has detected these, it will output the resources that would be removed and instruct what to do to have them removed. The user can verify the changes and make the decision to remove them in a future build, but also makes it clear that they need to verify that the resources are not used anymore before they are removed.

A new function that will save the service states into a lagoon-services configmap which can be used by the remote-controller to send environment state back to the API for visibility.

To properly support all the changes in this in the API and other systems, the following are required, and the references to pr-99 are added in code to identify where the changes will need to be made in the future to use machinery.

@shreddedbacon shreddedbacon force-pushed the cleanup-old-services branch 6 times, most recently from 1b83d72 to de56df8 Compare December 3, 2023 07:37
@shreddedbacon shreddedbacon added the enhancement New feature or request label Dec 21, 2023
@shreddedbacon shreddedbacon added the onhold pending other changes label Jan 14, 2024
@tobybellwood tobybellwood added this to the 2.20.0 milestone May 27, 2024
@shreddedbacon shreddedbacon removed this from the 2.20.0 milestone Jun 19, 2024
@shreddedbacon
Copy link
Member Author

shreddedbacon commented Jun 19, 2024

This needs more work before it is ready for a release, so I've removed the milestone

Edit: now closer to release worthy

@shreddedbacon shreddedbacon marked this pull request as ready for review June 20, 2024 22:23
@shreddedbacon shreddedbacon marked this pull request as draft June 20, 2024 22:24
@shreddedbacon shreddedbacon force-pushed the cleanup-old-services branch 14 times, most recently from 119f2bb to 116a828 Compare September 24, 2024 02:22
@shreddedbacon shreddedbacon removed the onhold pending other changes label Sep 24, 2024
@shreddedbacon shreddedbacon force-pushed the cleanup-old-services branch from 58f17fd to 23f0e4a Compare July 31, 2025 01:06
@shreddedbacon shreddedbacon force-pushed the cleanup-old-services branch 2 times, most recently from 8a04da3 to 4c93e12 Compare September 18, 2025 07:11
@shreddedbacon shreddedbacon force-pushed the cleanup-old-services branch 3 times, most recently from e68fa7f to a1a1b8b Compare October 20, 2025 02:55
@shreddedbacon shreddedbacon force-pushed the cleanup-old-services branch 7 times, most recently from 7c844e7 to 0010cb5 Compare October 22, 2025 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants