mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-07-18 17:52:37 +00:00
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.
This commit is contained in:
parent
53a68c35ff
commit
a1915e1a8e
@ -815,8 +815,13 @@ func CmdDel(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) er
|
|||||||
}
|
}
|
||||||
|
|
||||||
if in.ReadinessIndicatorFile != "" {
|
if in.ReadinessIndicatorFile != "" {
|
||||||
if err := types.GetReadinessIndicatorFile(in.ReadinessIndicatorFile); err != nil {
|
readinessfileexists, err := types.ReadinessIndicatorExistsNow(in.ReadinessIndicatorFile)
|
||||||
return cmdErr(k8sArgs, "PollImmediate error waiting for ReadinessIndicatorFile (on del): %v", err)
|
if err != nil {
|
||||||
|
return cmdErr(k8sArgs, "error checking readinessindicatorfile on CNI DEL @ %v: %v", in.ReadinessIndicatorFile, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !readinessfileexists {
|
||||||
|
logging.Verbosef("warning: readinessindicatorfile @ %v does not exist on CNI DEL", in.ReadinessIndicatorFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,17 +20,17 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
utilwait "k8s.io/apimachinery/pkg/util/wait"
|
|
||||||
|
|
||||||
"github.com/containernetworking/cni/libcni"
|
"github.com/containernetworking/cni/libcni"
|
||||||
"github.com/containernetworking/cni/pkg/skel"
|
"github.com/containernetworking/cni/pkg/skel"
|
||||||
cni100 "github.com/containernetworking/cni/pkg/types/100"
|
cni100 "github.com/containernetworking/cni/pkg/types/100"
|
||||||
"github.com/containernetworking/cni/pkg/version"
|
"github.com/containernetworking/cni/pkg/version"
|
||||||
nadutils "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/utils"
|
nadutils "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/utils"
|
||||||
"gopkg.in/k8snetworkplumbingwg/multus-cni.v4/pkg/logging"
|
"gopkg.in/k8snetworkplumbingwg/multus-cni.v4/pkg/logging"
|
||||||
|
utilwait "k8s.io/apimachinery/pkg/util/wait"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -610,7 +610,13 @@ func CheckSystemNamespaces(namespace string, systemNamespaces []string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetReadinessIndicatorFile waits for readinessIndicatorFile
|
// GetReadinessIndicatorFile waits for readinessIndicatorFile
|
||||||
func GetReadinessIndicatorFile(readinessIndicatorFile string) error {
|
func GetReadinessIndicatorFile(readinessIndicatorFileRaw string) error {
|
||||||
|
cleanpath := filepath.Clean(readinessIndicatorFileRaw)
|
||||||
|
readinessIndicatorFile, err := filepath.Abs(cleanpath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to get absolute path of readinessIndicatorFile: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
pollDuration := 1000 * time.Millisecond
|
pollDuration := 1000 * time.Millisecond
|
||||||
pollTimeout := 45 * time.Second
|
pollTimeout := 45 * time.Second
|
||||||
return utilwait.PollImmediate(pollDuration, pollTimeout, func() (bool, error) {
|
return utilwait.PollImmediate(pollDuration, pollTimeout, func() (bool, error) {
|
||||||
@ -618,3 +624,21 @@ func GetReadinessIndicatorFile(readinessIndicatorFile string) error {
|
|||||||
return err == nil, nil
|
return err == nil, nil
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadinessIndicatorExistsNow reports if the readiness indicator exists immediately.
|
||||||
|
func ReadinessIndicatorExistsNow(readinessIndicatorFileRaw string) (bool, error) {
|
||||||
|
cleanpath := filepath.Clean(readinessIndicatorFileRaw)
|
||||||
|
readinessIndicatorFile, err := filepath.Abs(cleanpath)
|
||||||
|
if err != nil {
|
||||||
|
return false, fmt.Errorf("failed to get absolute path of readinessIndicatorFile: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = os.Stat(readinessIndicatorFile)
|
||||||
|
if err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user