pkalsi97 commented on code in PR #6423:
URL: https://github.com/apache/camel-k/pull/6423#discussion_r2619911891


##########
pkg/trait/gc.go:
##########
@@ -119,7 +119,20 @@ func (t *gcTrait) Configure(e *Environment) (bool, 
*TraitCondition, error) {
 }
 
 func (t *gcTrait) Apply(e *Environment) error {
-       if e.Integration.GetGeneration() > 1 || 
e.IntegrationInPhase(v1.IntegrationPhaseBuildComplete) {
+       // Garbage collection runs when:
+       // 1. Generation > 1: resource was updated, clean up old generation 
resources
+       // 2. BuildComplete phase with Replicas > 0: undeploy scenario, clean 
up runtime resources
+       //    (Replicas > 0 indicates the integration was previously running)
+       shouldRunGC := e.Integration.GetGeneration() > 1
+
+       if !shouldRunGC && 
e.IntegrationInPhase(v1.IntegrationPhaseBuildComplete) {
+               // Replicas > 0 means the integration was running before 
reaching BuildComplete (undeploy case)
+               if e.Integration.Status.Replicas != nil && 
*e.Integration.Status.Replicas > 0 {

Review Comment:
   @squakez Very interesting. I did not think about this edge case. I'll look 
into readyness and see how this can be fixed. Just came to my mind. Do you 
think deploymentTimestamp can also help here ? has this integration ever been 
deployed? this can also be a reliable way to determine. what do you think?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to