Revert "Fix error type for NoK8sNetworkError"

This reverts commit 3245ed8577, due to
missing pull request process. will file it again as pull request.
This commit is contained in:
Tomofumi Hayashi 2018-04-23 15:49:16 +09:00
parent 3245ed8577
commit 362be285c9
2 changed files with 11 additions and 15 deletions

View File

@ -30,11 +30,9 @@ import (
) )
// NoK8sNetworkError indicates error, no network in kubernetes // NoK8sNetworkError indicates error, no network in kubernetes
type NoK8sNetworkError struct { type NoK8sNetworkError string
message string
}
func (e *NoK8sNetworkError) Error() string { return string(e.message) } func (e NoK8sNetworkError) Error() string { return string(e) }
func createK8sClient(kubeconfig string) (*kubernetes.Clientset, error) { func createK8sClient(kubeconfig string) (*kubernetes.Clientset, error) {
@ -260,7 +258,7 @@ func GetK8sNetwork(args *skel.CmdArgs, kubeconfig string) ([]map[string]interfac
} }
if len(netAnnot) == 0 { if len(netAnnot) == 0 {
return podNet, &NoK8sNetworkError{"no kubernetes network found"} return podNet, NoK8sNetworkError("no kubernetes network found")
} }
netObjs, err := parsePodNetworkObject(netAnnot) netObjs, err := parsePodNetworkObject(netAnnot)

View File

@ -336,19 +336,17 @@ func cmdDel(args *skel.CmdArgs) error {
if in.Kubeconfig != "" { if in.Kubeconfig != "" {
podDelegate, r := k8s.GetK8sNetwork(args, in.Kubeconfig) podDelegate, r := k8s.GetK8sNetwork(args, in.Kubeconfig)
if r != nil { if r != nil && r.Error() == "nonet" {
if _, ok := r.(*NoK8sNetworkError); ok { nopodnet = true
nopodnet = true if !defaultcninetwork {
// no network found from default and annotaed network, return fmt.Errorf("Multus: Err in getting k8s network from the poc spec, check the pod spec or set delegate for the default network, Refer the README.md: %v", r)
// we do nothing to remove network for the pod!
if !defaultcninetwork {
return fmt.Errorf("Multus: Err in getting k8s network from the poc spec, check the pod spec or set delegate for the default network, Refer the README.md: %v", r)
}
} else {
return fmt.Errorf("Multus: Err in getting k8s network from pod: %v", r)
} }
} }
if r != nil && !defaultcninetwork {
return fmt.Errorf("Multus: Err in getting k8s network from pod: %v", r)
}
if len(podDelegate) != 0 { if len(podDelegate) != 0 {
if in.UseDefault { if in.UseDefault {
// In the case that we force the default // In the case that we force the default