Skip to content

Commit 8bfaf63

Browse files
authored
Fix force drain active daemonset check (#185)
* Fix upgrade controller always using `POD_NAMESPACE` instead of given namespace for cache setup * Use direct (unconstrained) API reader to load daemonsets The cache is constrained to the controller namespace by default. We could expand the cache for daemonsets but we don't want to cache all daemonsets for a few requests a maintenance.
2 parents 37a385b + 6f597a2 commit 8bfaf63

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

controllers/node_force_drain_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ func (r *NodeForceDrainReconciler) podIsControlledByExistingDaemonSet(ctx contex
499499
// We don't need a full object, metadata is enough.
500500
var ds metav1.PartialObjectMetadata
501501
ds.SetGroupVersionKind(appsv1.SchemeGroupVersion.WithKind("DaemonSet"))
502-
err := r.Get(ctx, client.ObjectKey{Namespace: pod.Namespace, Name: controllerRef.Name}, &ds)
502+
err := r.APIReader.Get(ctx, client.ObjectKey{Namespace: pod.Namespace, Name: controllerRef.Name}, &ds)
503503
if err != nil {
504504
// Edge case: Pod was orphaned
505505
// See https://github.com/kubernetes/kubectl/blob/442e3d141a35703b7637f41339b9f73cad005c47/pkg/drain/filters.go#L174

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func main() {
172172
}
173173
if namespace != "" {
174174
cacheOpts.DefaultNamespaces = map[string]cache.Config{
175-
defaultNamespace: {},
175+
namespace: {},
176176
}
177177
}
178178

@@ -294,7 +294,7 @@ func main() {
294294
os.Exit(1)
295295
}
296296

297-
setupLog.Info("starting manager")
297+
setupLog.Info("starting manager", "namespace", namespace)
298298
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
299299
setupLog.Error(err, "problem running manager")
300300
os.Exit(1)

0 commit comments

Comments
 (0)