ricardozanini commented on code in PR #565:
URL:
https://github.com/apache/incubator-kie-kogito-serverless-operator/pull/565#discussion_r1829469035
##########
internal/controller/profiles/common/knative_eventing.go:
##########
@@ -79,3 +85,37 @@ func (k knativeObjectManager) Ensure(ctx context.Context,
workflow *operatorapi.
}
return objs, nil
}
+
+func (k knativeObjectManager) cleanupOutdatedRevisions(ctx context.Context,
workflow *operatorapi.SonataFlow, sinkBinding client.Object) error {
+ if !workflow.IsKnativeDeployment() {
+ return nil
+ }
+ injected, err := knative.CheckKSinkInjected(workflow.Name,
workflow.Namespace)
+ if err != nil {
+ return err
+ }
+ if !injected {
+ return nil
+ }
+ opts := &client.ListOptions{
+ LabelSelector: labels.SelectorFromSet(
+ map[string]string{
+ workflowproj.LabelWorkflow:
workflow.Name,
+ workflowproj.LabelWorkflowNamespace:
workflow.Namespace,
+ },
+ ),
+ Namespace: workflow.Namespace,
+ }
+ revisionList := &servingv1.RevisionList{}
+ if err := k.C.List(context.TODO(), revisionList, opts); err != nil {
Review Comment:
```suggestion
if err := k.C.List(ctx, revisionList, opts); err != nil {
```
##########
internal/controller/profiles/common/knative_eventing.go:
##########
@@ -67,6 +70,9 @@ func (k knativeObjectManager) Ensure(ctx context.Context,
workflow *operatorapi.
return objs, err
} else if sinkBinding != nil {
objs = append(objs, sinkBinding)
+ if err := k.cleanupOutdatedRevisions(ctx, workflow,
sinkBinding); err != nil {
Review Comment:
We have a post-hook implementation that we can use to garbage collect it.
WDYT? Also, `sinkBinding` is not used anywhere.
https://github.com/apache/incubator-kie-kogito-serverless-operator/blob/main/internal/controller/profiles/profile.go#L74
So, in the reconciliation states, we can have a GC calling
`cleanupOutdatedRevisions`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]