feat: clean up unused services and resources#274
Merged
shreddedbacon merged 16 commits intomainfrom Feb 11, 2026
Merged
Conversation
1b83d72 to
de56df8
Compare
de56df8 to
cf2a8b9
Compare
Member
Author
|
Edit: now closer to release worthy |
119f2bb to
116a828
Compare
f27f87c to
d07f6e6
Compare
046253e to
6205bc8
Compare
5fa9d71 to
0988100
Compare
…ing services works for cleaning up/saving state for future use
9ce6808 to
4feb7f4
Compare
4feb7f4 to
cc29e72
Compare
CGoodwin90
reviewed
Feb 10, 2026
CGoodwin90
approved these changes
Feb 10, 2026
Contributor
CGoodwin90
left a comment
There was a problem hiding this comment.
The logic looks good, and it's behaving as expected locally with adding/removing services.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
warnand 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, aServiceand/or aPersistentVolumeClaim. 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-servicesconfigmap 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.