Allow providers to skip downward API resolving
This commit is contained in:
@@ -254,6 +254,11 @@ type NodeConfig struct {
|
|||||||
// Set the error handler for node status update failures
|
// Set the error handler for node status update failures
|
||||||
NodeStatusUpdateErrorHandler node.ErrorHandler
|
NodeStatusUpdateErrorHandler node.ErrorHandler
|
||||||
|
|
||||||
|
// SkipDownwardAPIResolution can be used to skip any attempts at resolving downward API references
|
||||||
|
// in pods before calling CreatePod on the provider.
|
||||||
|
// Providers need this if they need to do their own custom resolving
|
||||||
|
SkipDownwardAPIResolution bool
|
||||||
|
|
||||||
routeAttacher func(Provider, NodeConfig, corev1listers.PodLister)
|
routeAttacher func(Provider, NodeConfig, corev1listers.PodLister)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,6 +405,7 @@ func NewNode(name string, newProvider NewProviderFunc, opts ...NodeOpt) (*Node,
|
|||||||
SecretInformer: secretInformer,
|
SecretInformer: secretInformer,
|
||||||
ConfigMapInformer: configMapInformer,
|
ConfigMapInformer: configMapInformer,
|
||||||
ServiceInformer: serviceInformer,
|
ServiceInformer: serviceInformer,
|
||||||
|
SkipDownwardAPIResolution: cfg.SkipDownwardAPIResolution,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "error creating pod controller")
|
return nil, errors.Wrap(err, "error creating pod controller")
|
||||||
|
|||||||
@@ -69,12 +69,14 @@ func (pc *PodController) createOrUpdatePod(ctx context.Context, pod *corev1.Pod)
|
|||||||
"namespace": pod.GetNamespace(),
|
"namespace": pod.GetNamespace(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if !pc.skipDownwardAPIResolution {
|
||||||
// We do this so we don't mutate the pod from the informer cache
|
// We do this so we don't mutate the pod from the informer cache
|
||||||
pod = pod.DeepCopy()
|
pod = pod.DeepCopy()
|
||||||
if err := podutils.PopulateEnvironmentVariables(ctx, pod, pc.resourceManager, pc.recorder); err != nil {
|
if err := podutils.PopulateEnvironmentVariables(ctx, pod, pc.resourceManager, pc.recorder); err != nil {
|
||||||
span.SetStatus(err)
|
span.SetStatus(err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We have to use a different pod that we pass to the provider than the one that gets used in handleProviderError
|
// We have to use a different pod that we pass to the provider than the one that gets used in handleProviderError
|
||||||
// because the provider may manipulate the pod in a separate goroutine while we were doing work
|
// because the provider may manipulate the pod in a separate goroutine while we were doing work
|
||||||
|
|||||||
@@ -140,6 +140,11 @@ type PodController struct {
|
|||||||
// This is used since `pc.Run()` is typically called in a goroutine and managing
|
// This is used since `pc.Run()` is typically called in a goroutine and managing
|
||||||
// this can be non-trivial for callers.
|
// this can be non-trivial for callers.
|
||||||
err error
|
err error
|
||||||
|
|
||||||
|
// skipDownwardAPIResolution can be used to skip any attempts at resolving downward API references
|
||||||
|
// in pods before calling CreatePod on the provider.
|
||||||
|
// Providers need this if they need to do their own custom resolving
|
||||||
|
skipDownwardAPIResolution bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type knownPod struct {
|
type knownPod struct {
|
||||||
@@ -196,6 +201,11 @@ type PodControllerConfig struct {
|
|||||||
// For example, if the pod informer is not filtering based on pod.Spec.NodeName, you should
|
// For example, if the pod informer is not filtering based on pod.Spec.NodeName, you should
|
||||||
// set that filter here so the pod controller does not handle events for pods assigned to other nodes.
|
// set that filter here so the pod controller does not handle events for pods assigned to other nodes.
|
||||||
PodEventFilterFunc PodEventFilterFunc
|
PodEventFilterFunc PodEventFilterFunc
|
||||||
|
|
||||||
|
// SkipDownwardAPIResolution can be used to skip any attempts at resolving downward API references
|
||||||
|
// in pods before calling CreatePod on the provider.
|
||||||
|
// Providers need this if they need to do their own custom resolving
|
||||||
|
SkipDownwardAPIResolution bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPodController creates a new pod controller with the provided config.
|
// NewPodController creates a new pod controller with the provided config.
|
||||||
@@ -245,6 +255,7 @@ func NewPodController(cfg PodControllerConfig) (*PodController, error) {
|
|||||||
done: make(chan struct{}),
|
done: make(chan struct{}),
|
||||||
recorder: cfg.EventRecorder,
|
recorder: cfg.EventRecorder,
|
||||||
podEventFilterFunc: cfg.PodEventFilterFunc,
|
podEventFilterFunc: cfg.PodEventFilterFunc,
|
||||||
|
skipDownwardAPIResolution: cfg.SkipDownwardAPIResolution,
|
||||||
}
|
}
|
||||||
|
|
||||||
pc.syncPodsFromKubernetes = queue.New(cfg.SyncPodsFromKubernetesRateLimiter, "syncPodsFromKubernetes", pc.syncPodFromKubernetesHandler, cfg.SyncPodsFromKubernetesShouldRetryFunc)
|
pc.syncPodsFromKubernetes = queue.New(cfg.SyncPodsFromKubernetesRateLimiter, "syncPodsFromKubernetes", pc.syncPodFromKubernetesHandler, cfg.SyncPodsFromKubernetesShouldRetryFunc)
|
||||||
|
|||||||
Reference in New Issue
Block a user