@@ -36,17 +36,17 @@ func nsAttachNetdev(hostIfName string, containerNsPAth string, interfaceConfig a
3636 hostDev , err := netlink .LinkByName (hostIfName )
3737 // recover same behavior on vishvananda/netlink@1.2.1 and do not fail when the kernel returns NLM_F_DUMP_INTR.
3838 if err != nil && ! errors .Is (err , netlink .ErrDumpInterrupted ) {
39- return nil , err
39+ return nil , fmt . Errorf ( "failed to get link for interface %s: %w" , hostIfName , err )
4040 }
4141
4242 // Devices can be renamed only when down
4343 if err = netlink .LinkSetDown (hostDev ); err != nil {
44- return nil , fmt .Errorf ("failed to set %q down: %v " , hostDev .Attrs ().Name , err )
44+ return nil , fmt .Errorf ("failed to set %q down: %w " , hostDev .Attrs ().Name , err )
4545 }
4646
4747 containerNs , err := netns .GetFromPath (containerNsPAth )
4848 if err != nil {
49- return nil , err
49+ return nil , fmt . Errorf ( "failed to get container network namespace %s: %w" , containerNsPAth , err )
5050 }
5151 defer containerNs .Close ()
5252
@@ -121,14 +121,14 @@ func nsAttachNetdev(hostIfName string, containerNsPAth string, interfaceConfig a
121121
122122 _ , err = req .Execute (unix .NETLINK_ROUTE , 0 )
123123 if err != nil && ! errors .Is (err , netlink .ErrDumpInterrupted ) {
124- return nil , err
124+ return nil , fmt . Errorf ( "failed to move interface %s to container namespace %s: %w" , hostIfName , containerNsPAth , err )
125125 }
126126
127127 // to avoid golang problem with goroutines we create the socket in the
128128 // namespace and use it directly
129129 nhNs , err := netlink .NewHandleAt (containerNs )
130130 if err != nil {
131- return nil , err
131+ return nil , fmt . Errorf ( "failed to get netlink handle in container namespace %s: %w" , containerNsPAth , err )
132132 }
133133 defer nhNs .Close ()
134134
0 commit comments