Skip to content

feat: clean up unused services and resources#274

Merged
shreddedbacon merged 16 commits intomainfrom
cleanup-old-services
Feb 11, 2026
Merged

feat: clean up unused services and resources#274
shreddedbacon merged 16 commits intomainfrom
cleanup-old-services

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 8 times, most recently from 046253e to 6205bc8 Compare October 24, 2025 03:10
Copy link
Contributor

@CGoodwin90 CGoodwin90 left a comment

Choose a reason for hiding this comment

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

The logic looks good, and it's behaving as expected locally with adding/removing services.

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