@@ -3,14 +3,12 @@ package cdk8sappproxy
33import (
44 "context"
55 "sync"
6- "time"
76
87 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
98 "k8s.io/apimachinery/pkg/runtime/schema"
109 "k8s.io/apimachinery/pkg/types"
1110 "k8s.io/apimachinery/pkg/watch"
1211 "k8s.io/client-go/dynamic"
13- ctrl "sigs.k8s.io/controller-runtime"
1412 "sigs.k8s.io/controller-runtime/pkg/client"
1513 "sigs.k8s.io/controller-runtime/pkg/log"
1614)
@@ -20,7 +18,6 @@ type ResourceWatchManager struct {
2018 mu sync.RWMutex
2119 watches map [types.NamespacedName ]map [string ]context.CancelFunc
2220 client client.Client
23- queue workqueue.RateLimitingInterface
2421}
2522
2623// WatchInfo holds information about an active watch
@@ -33,11 +30,10 @@ type WatchInfo struct {
3330}
3431
3532// NewResourceWatchManager creates a new resource watch manager.
36- func NewResourceWatchManager (client client.Client , reconcileFunc func (context. Context , ctrl. Request ) (ctrl. Result , error ) ) * ResourceWatchManager {
33+ func NewResourceWatchManager (client client.Client ) * ResourceWatchManager {
3734 return & ResourceWatchManager {
3835 watches : make (map [types.NamespacedName ]map [string ]context.CancelFunc ),
3936 client : client ,
40- queue : workqueue .NewNamedRateLimitingQueue (workqueue .DefaultControllerRateLimiter (), "resource-deletion" ),
4137 }
4238}
4339
@@ -155,21 +151,6 @@ func (m *ResourceWatchManager) watchResource(ctx context.Context, targetClient d
155151func (m * ResourceWatchManager ) triggerReconciliation (ctx context.Context , parentProxy types.NamespacedName ) error {
156152 logger := log .FromContext (ctx ).WithValues ("parentProxy" , parentProxy .String ())
157153
158- if m .reconcileFunc != nil {
159- req := ctrl.Request {NamespacedName : parentProxy }
160- go func () {
161- reconcileCtx , cancel := context .WithTimeout (context .Background (), 30 * time .Second )
162- defer cancel ()
163-
164- _ , err := m .reconcileFunc (reconcileCtx , req )
165- if err != nil {
166- logger .Error (err , "Failed to reconcile after resource deletion" )
167- } else {
168- logger .Info ("Successfully triggered reconciliation after resource deletion" )
169- }
170- }()
171- }
172-
173154 logger .Info ("Resource deletion detected, reconciliation triggered" )
174155
175156 return nil
0 commit comments