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


##########
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:
   The idea of using this as as a way to know if the Integration has ever run 
is interesting. However, can be a false negative, when, for instance, the user 
is building the application specifying the `.spec.replica` 0. I think it would 
be wiser to find a more consistent way to make sure the condition is met. We 
can probably leverage any other conditions (such as readyness) to verify we're 
falling in that circumstance.



-- 
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