From 566940a17abfb8501a6de130bfa546aed5d8a2dc Mon Sep 17 00:00:00 2001 From: dougbtv Date: Tue, 20 Feb 2024 13:58:51 -0500 Subject: [PATCH] Skips checking for readiness on CNI DEL (and instead warns) Because deletes should favor a successful path, the readiness check should be skipped for pod removals. This can cause an issue where there's pods pending deletes and that might impact scheduling of a pod that may be necessary in order to set the readiness indicator. Adds a new method to check for readiness indicator alone in order to immediately log a warning. --- pkg/multus/multus.go | 9 +++++++-- pkg/types/conf.go | 11 +++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pkg/multus/multus.go b/pkg/multus/multus.go index e9ecc1ed1..80900a1d5 100644 --- a/pkg/multus/multus.go +++ b/pkg/multus/multus.go @@ -815,8 +815,13 @@ func CmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) er } if in.ReadinessIndicatorFile != "" { - if err := types.GetReadinessIndicatorFile(in.ReadinessIndicatorFile); err != nil { - return cmdErr(k8sArgs, "PollImmediate error waiting for ReadinessIndicatorFile (on del): %v", err) + readinessfileexists, err := types.ReadinessIndicatorExistsNow(in.ReadinessIndicatorFile) + if err != nil { + return cmdErr(k8sArgs, "error checking readinessindicatorfile @ %v: %v", in.ReadinessIndicatorFile, err) + } else { + if !readinessfileexists { + logging.Verbosef("warning: readinessindicatorfile @ %v does not exist", in.ReadinessIndicatorFile) + } } } diff --git a/pkg/types/conf.go b/pkg/types/conf.go index 4402b4ec7..c9fbd73a1 100644 --- a/pkg/types/conf.go +++ b/pkg/types/conf.go @@ -618,3 +618,14 @@ func GetReadinessIndicatorFile(readinessIndicatorFile string) error { return err == nil, nil }) } + +func ReadinessIndicatorExistsNow(readinessIndicatorFile string) (bool, error) { + _, err := os.Stat(readinessIndicatorFile) + if err != nil { + if os.IsNotExist(err) { + return false, nil // File does not exist + } + return false, err // Some other error occurred + } + return true, nil // File exists +}