Skip to content

Commit dfe615f

Browse files
committed
node: Add comments explaining uidProviderWrapper/syncProviderWrapper backwards compatibility
1 parent 11bbe25 commit dfe615f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

node/podcontroller.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ func NewPodController(cfg PodControllerConfig) (*PodController, error) {
274274
return nil, pkgerrors.Wrap(err, "could not create resource manager")
275275
}
276276

277+
// Under the hood, we expect the provider to implement PodUIDLifecycleHandler.
278+
// However, PodControllerConfig accepts PodLifecycleHandler, which might not
279+
// implement this. For backwards compatibility, we haven't changed the type
280+
// in PodControllerConfig, but if the provider doesn't implement PodUIDLifecycleHandler
281+
// we wrap it in uidProviderWrapper. In the future, we will require asyncProvider
282+
// to be implemented directly (PodUIDLifecycleHandler + PodNotifier).
277283
var provider PodUIDLifecycleHandler
278284
if p, ok := cfg.Provider.(PodUIDLifecycleHandler); ok {
279285
provider = p
@@ -329,6 +335,12 @@ func (pc *PodController) Run(ctx context.Context, podSyncWorkers int) (retErr er
329335
var provider asyncProvider
330336
runProvider := func(context.Context) {}
331337

338+
// Under the hood, we expect the provider to implement PodNotifier.
339+
// However, PodControllerConfig accepts PodLifecycleHandler, which might not
340+
// implement this. For backwards compatibility, we haven't changed the type
341+
// in PodControllerConfig, but if the provider doesn't implement PodNotifier
342+
// we wrap it in syncProviderWrapper. In the future, we will require asyncProvider
343+
// to be implemented directly (PodUIDLifecycleHandler + PodNotifier).
332344
if p, ok := pc.provider.(asyncProvider); ok {
333345
provider = p
334346
} else {

node/uid.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ func (k *podUIDKey) String() string {
3636
return k.ObjectName() + "/" + string(k.UID)
3737
}
3838

39+
// uidProviderWrapper wraps a legacy PodLifecycleHandler to handle GetPodByUID/GetPodStatusByUID,
40+
// by ignoring the pod UID and using only the pod namespace/name.
3941
type uidProviderWrapper struct {
4042
PodLifecycleHandler
4143
}

0 commit comments

Comments
 (0)