Skip to content

Commit

Permalink
macvlan cmdDel: replace the loadConf function with json.unmarshal
Browse files Browse the repository at this point in the history
We call the loadConf function in cmDel just for ipam, So we just replace loadConf with json.unmarshal, which would be simpler. This also fixes the issue that when the pod's NIC is accidentally deleted, we should return nil to the runtime instead of LinkNotFound error.

Signed-off-by: cyclinder <qifeng.guo@daocloud.io>
  • Loading branch information
cyclinder committed Oct 12, 2023
1 parent f955052 commit dc27da3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/main/macvlan/macvlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,13 @@ func cmdAdd(args *skel.CmdArgs) error {
}

func cmdDel(args *skel.CmdArgs) error {
n, _, err := loadConf(args, args.Args)
var n NetConf
err := json.Unmarshal(args.StdinData, &n)
if err != nil {
return err
return fmt.Errorf("failed to load netConf: %v", err)
}

isLayer3 := n.IPAM.Type != ""

if isLayer3 {
err = ipam.ExecDel(n.IPAM.Type, args.StdinData)
if err != nil {
Expand Down

0 comments on commit dc27da3

Please sign in to comment.