Merge pull request #390 from sipsma/firewall-fix
firewall: don't return error in DEL if prevResult is not found.
This commit is contained in:
commit
d0eeb27494
@ -27,7 +27,6 @@ import (
|
|||||||
"github.com/containernetworking/cni/pkg/types/current"
|
"github.com/containernetworking/cni/pkg/types/current"
|
||||||
"github.com/containernetworking/cni/pkg/version"
|
"github.com/containernetworking/cni/pkg/version"
|
||||||
|
|
||||||
"github.com/containernetworking/plugins/pkg/ns"
|
|
||||||
bv "github.com/containernetworking/plugins/pkg/utils/buildversion"
|
bv "github.com/containernetworking/plugins/pkg/utils/buildversion"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -68,9 +67,15 @@ func parseConf(data []byte) (*FirewallNetConf, *current.Result, error) {
|
|||||||
return nil, nil, fmt.Errorf("failed to load netconf: %v", err)
|
return nil, nil, fmt.Errorf("failed to load netconf: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default the firewalld zone to trusted
|
||||||
|
if conf.FirewalldZone == "" {
|
||||||
|
conf.FirewalldZone = "trusted"
|
||||||
|
}
|
||||||
|
|
||||||
// Parse previous result.
|
// Parse previous result.
|
||||||
if conf.RawPrevResult == nil {
|
if conf.RawPrevResult == nil {
|
||||||
return nil, nil, fmt.Errorf("missing prevResult from earlier plugin")
|
// return early if there was no previous result, which is allowed for DEL calls
|
||||||
|
return &conf, ¤t.Result{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse previous result.
|
// Parse previous result.
|
||||||
@ -85,11 +90,6 @@ func parseConf(data []byte) (*FirewallNetConf, *current.Result, error) {
|
|||||||
return nil, nil, fmt.Errorf("could not convert result to current version: %v", err)
|
return nil, nil, fmt.Errorf("could not convert result to current version: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default the firewalld zone to trusted
|
|
||||||
if conf.FirewalldZone == "" {
|
|
||||||
conf.FirewalldZone = "trusted"
|
|
||||||
}
|
|
||||||
|
|
||||||
return &conf, result, nil
|
return &conf, result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,6 +116,10 @@ func cmdAdd(args *skel.CmdArgs) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if conf.PrevResult == nil {
|
||||||
|
return fmt.Errorf("missing prevResult from earlier plugin")
|
||||||
|
}
|
||||||
|
|
||||||
backend, err := getBackend(conf)
|
backend, err := getBackend(conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -142,12 +146,6 @@ func cmdDel(args *skel.CmdArgs) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tolerate errors if the container namespace has been torn down already
|
|
||||||
containerNS, err := ns.GetNS(args.Netns)
|
|
||||||
if err == nil {
|
|
||||||
defer containerNS.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Runtime errors are ignored
|
// Runtime errors are ignored
|
||||||
if err := backend.Del(conf, result); err != nil {
|
if err := backend.Del(conf, result); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -167,8 +165,8 @@ func cmdCheck(args *skel.CmdArgs) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure we have previous result.
|
// Ensure we have previous result.
|
||||||
if result == nil {
|
if conf.PrevResult == nil {
|
||||||
return fmt.Errorf("Required prevResult missing")
|
return fmt.Errorf("missing prevResult from earlier plugin")
|
||||||
}
|
}
|
||||||
|
|
||||||
backend, err := getBackend(conf)
|
backend, err := getBackend(conf)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user