Signed-off-by: Albin Kerouanton <albinker@gmail.com>
| ... | ... |
@@ -312,7 +312,7 @@ func (daemon *Daemon) updateNetwork(cfg *config.Config, container *container.Con |
| 312 | 312 |
return fmt.Errorf("Update network failed: %v", err)
|
| 313 | 313 |
} |
| 314 | 314 |
|
| 315 |
- if err := sb.Refresh(sbOptions...); err != nil {
|
|
| 315 |
+ if err := sb.Refresh(context.TODO(), sbOptions...); err != nil {
|
|
| 316 | 316 |
return fmt.Errorf("Update network failed: Failure in refresh sandbox %s: %v", sid, err)
|
| 317 | 317 |
} |
| 318 | 318 |
|
| ... | ... |
@@ -766,7 +766,7 @@ func (daemon *Daemon) connectToNetwork(ctx context.Context, cfg *config.Config, |
| 766 | 766 |
} |
| 767 | 767 |
defer func() {
|
| 768 | 768 |
if retErr != nil {
|
| 769 |
- if err := ep.Delete(false); err != nil {
|
|
| 769 |
+ if err := ep.Delete(context.WithoutCancel(ctx), false); err != nil {
|
|
| 770 | 770 |
log.G(ctx).Warnf("Could not rollback container connection to network %s", idOrName)
|
| 771 | 771 |
} |
| 772 | 772 |
} |
| ... | ... |
@@ -861,10 +861,10 @@ func (daemon *Daemon) ForceEndpointDelete(name string, networkName string) error |
| 861 | 861 |
if err != nil {
|
| 862 | 862 |
return err |
| 863 | 863 |
} |
| 864 |
- return ep.Delete(true) |
|
| 864 |
+ return ep.Delete(context.TODO(), true) |
|
| 865 | 865 |
} |
| 866 | 866 |
|
| 867 |
-func (daemon *Daemon) disconnectFromNetwork(container *container.Container, n *libnetwork.Network, force bool) error {
|
|
| 867 |
+func (daemon *Daemon) disconnectFromNetwork(ctx context.Context, container *container.Container, n *libnetwork.Network, force bool) error {
|
|
| 868 | 868 |
var ( |
| 869 | 869 |
ep *libnetwork.Endpoint |
| 870 | 870 |
sbox *libnetwork.Sandbox |
| ... | ... |
@@ -891,18 +891,18 @@ func (daemon *Daemon) disconnectFromNetwork(container *container.Container, n *l |
| 891 | 891 |
if err != nil {
|
| 892 | 892 |
return err |
| 893 | 893 |
} |
| 894 |
- return ep.Delete(force) |
|
| 894 |
+ return ep.Delete(ctx, force) |
|
| 895 | 895 |
} |
| 896 | 896 |
return fmt.Errorf("container %s is not connected to network %s", container.ID, n.Name())
|
| 897 | 897 |
} |
| 898 | 898 |
|
| 899 |
- if err := ep.Leave(sbox); err != nil {
|
|
| 899 |
+ if err := ep.Leave(ctx, sbox); err != nil {
|
|
| 900 | 900 |
return fmt.Errorf("container %s failed to leave network %s: %v", container.ID, n.Name(), err)
|
| 901 | 901 |
} |
| 902 | 902 |
|
| 903 | 903 |
container.NetworkSettings.Ports = getPortMapInfo(sbox) |
| 904 | 904 |
|
| 905 |
- if err := ep.Delete(false); err != nil {
|
|
| 905 |
+ if err := ep.Delete(ctx, false); err != nil {
|
|
| 906 | 906 |
return fmt.Errorf("endpoint delete failed for container %s on network %s: %v", container.ID, n.Name(), err)
|
| 907 | 907 |
} |
| 908 | 908 |
|
| ... | ... |
@@ -1087,7 +1087,7 @@ func (daemon *Daemon) ConnectToNetwork(ctx context.Context, container *container |
| 1087 | 1087 |
} |
| 1088 | 1088 |
|
| 1089 | 1089 |
// DisconnectFromNetwork disconnects container from network n. |
| 1090 |
-func (daemon *Daemon) DisconnectFromNetwork(container *container.Container, networkName string, force bool) error {
|
|
| 1090 |
+func (daemon *Daemon) DisconnectFromNetwork(ctx context.Context, container *container.Container, networkName string, force bool) error {
|
|
| 1091 | 1091 |
n, err := daemon.FindNetwork(networkName) |
| 1092 | 1092 |
container.Lock() |
| 1093 | 1093 |
defer container.Unlock() |
| ... | ... |
@@ -1110,7 +1110,7 @@ func (daemon *Daemon) DisconnectFromNetwork(container *container.Container, netw |
| 1110 | 1110 |
return runconfig.ErrConflictHostNetwork |
| 1111 | 1111 |
} |
| 1112 | 1112 |
|
| 1113 |
- if err := daemon.disconnectFromNetwork(container, n, false); err != nil {
|
|
| 1113 |
+ if err := daemon.disconnectFromNetwork(ctx, container, n, false); err != nil {
|
|
| 1114 | 1114 |
return err |
| 1115 | 1115 |
} |
| 1116 | 1116 |
} else {
|
| ... | ... |
@@ -486,7 +486,7 @@ func (daemon *Daemon) DisconnectContainerFromNetwork(containerName string, netwo |
| 486 | 486 |
} |
| 487 | 487 |
return err |
| 488 | 488 |
} |
| 489 |
- return daemon.DisconnectFromNetwork(ctr, networkName, force) |
|
| 489 |
+ return daemon.DisconnectFromNetwork(context.TODO(), ctr, networkName, force) |
|
| 490 | 490 |
} |
| 491 | 491 |
|
| 492 | 492 |
// GetNetworkDriverList returns the list of plugins drivers |
| ... | ... |
@@ -78,7 +78,7 @@ func (sb *Sandbox) setupDefaultGW() error {
|
| 78 | 78 |
|
| 79 | 79 |
defer func() {
|
| 80 | 80 |
if err != nil {
|
| 81 |
- if err2 := newEp.Delete(true); err2 != nil {
|
|
| 81 |
+ if err2 := newEp.Delete(context.WithoutCancel(context.TODO()), true); err2 != nil {
|
|
| 82 | 82 |
log.G(context.TODO()).Warnf("Failed to remove gw endpoint for container %s after failing to join the gateway network: %v",
|
| 83 | 83 |
sb.containerID, err2) |
| 84 | 84 |
} |
| ... | ... |
@@ -99,10 +99,10 @@ func (sb *Sandbox) clearDefaultGW() error {
|
| 99 | 99 |
if ep = sb.getEndpointInGWNetwork(); ep == nil {
|
| 100 | 100 |
return nil |
| 101 | 101 |
} |
| 102 |
- if err := ep.sbLeave(sb, false); err != nil {
|
|
| 102 |
+ if err := ep.sbLeave(context.TODO(), sb, false); err != nil {
|
|
| 103 | 103 |
return fmt.Errorf("container %s: endpoint leaving GW Network failed: %v", sb.containerID, err)
|
| 104 | 104 |
} |
| 105 |
- if err := ep.Delete(false); err != nil {
|
|
| 105 |
+ if err := ep.Delete(context.TODO(), false); err != nil {
|
|
| 106 | 106 |
return fmt.Errorf("container %s: deleting endpoint on GW Network failed: %v", sb.containerID, err)
|
| 107 | 107 |
} |
| 108 | 108 |
return nil |
| ... | ... |
@@ -697,7 +697,7 @@ func (ep *Endpoint) hasInterface(iName string) bool {
|
| 697 | 697 |
} |
| 698 | 698 |
|
| 699 | 699 |
// Leave detaches the network resources populated in the sandbox. |
| 700 |
-func (ep *Endpoint) Leave(sb *Sandbox) error {
|
|
| 700 |
+func (ep *Endpoint) Leave(ctx context.Context, sb *Sandbox) error {
|
|
| 701 | 701 |
if sb == nil || sb.ID() == "" || sb.Key() == "" {
|
| 702 | 702 |
return types.InvalidParameterErrorf("invalid Sandbox passed to endpoint leave: %v", sb)
|
| 703 | 703 |
} |
| ... | ... |
@@ -705,10 +705,10 @@ func (ep *Endpoint) Leave(sb *Sandbox) error {
|
| 705 | 705 |
sb.joinLeaveStart() |
| 706 | 706 |
defer sb.joinLeaveEnd() |
| 707 | 707 |
|
| 708 |
- return ep.sbLeave(sb, false) |
|
| 708 |
+ return ep.sbLeave(ctx, sb, false) |
|
| 709 | 709 |
} |
| 710 | 710 |
|
| 711 |
-func (ep *Endpoint) sbLeave(sb *Sandbox, force bool) error {
|
|
| 711 |
+func (ep *Endpoint) sbLeave(ctx context.Context, sb *Sandbox, force bool) error {
|
|
| 712 | 712 |
n, err := ep.getNetworkFromStore() |
| 713 | 713 |
if err != nil {
|
| 714 | 714 |
return fmt.Errorf("failed to get network from store during leave: %v", err)
|
| ... | ... |
@@ -746,30 +746,30 @@ func (ep *Endpoint) sbLeave(sb *Sandbox, force bool) error {
|
| 746 | 746 |
|
| 747 | 747 |
if d != nil {
|
| 748 | 748 |
if moveExtConn {
|
| 749 |
- log.G(context.TODO()).Debugf("Revoking external connectivity on endpoint %s (%s)", ep.Name(), ep.ID())
|
|
| 749 |
+ log.G(ctx).Debugf("Revoking external connectivity on endpoint %s (%s)", ep.Name(), ep.ID())
|
|
| 750 | 750 |
if err := d.RevokeExternalConnectivity(n.id, ep.id); err != nil {
|
| 751 |
- log.G(context.TODO()).Warnf("driver failed revoking external connectivity on endpoint %s (%s): %v",
|
|
| 751 |
+ log.G(ctx).Warnf("driver failed revoking external connectivity on endpoint %s (%s): %v",
|
|
| 752 | 752 |
ep.Name(), ep.ID(), err) |
| 753 | 753 |
} |
| 754 | 754 |
} |
| 755 | 755 |
|
| 756 | 756 |
if err := d.Leave(n.id, ep.id); err != nil {
|
| 757 | 757 |
if _, ok := err.(types.MaskableError); !ok {
|
| 758 |
- log.G(context.TODO()).Warnf("driver error disconnecting container %s : %v", ep.name, err)
|
|
| 758 |
+ log.G(ctx).Warnf("driver error disconnecting container %s : %v", ep.name, err)
|
|
| 759 | 759 |
} |
| 760 | 760 |
} |
| 761 | 761 |
} |
| 762 | 762 |
|
| 763 | 763 |
if err := ep.deleteServiceInfoFromCluster(sb, true, "sbLeave"); err != nil {
|
| 764 |
- log.G(context.TODO()).Warnf("Failed to clean up service info on container %s disconnect: %v", ep.name, err)
|
|
| 764 |
+ log.G(ctx).Warnf("Failed to clean up service info on container %s disconnect: %v", ep.name, err)
|
|
| 765 | 765 |
} |
| 766 | 766 |
|
| 767 | 767 |
if err := deleteEpFromResolver(ep.Name(), ep.iface, n.Resolvers()); err != nil {
|
| 768 |
- log.G(context.TODO()).Warnf("Failed to clean up resolver info on container %s disconnect: %v", ep.name, err)
|
|
| 768 |
+ log.G(ctx).Warnf("Failed to clean up resolver info on container %s disconnect: %v", ep.name, err)
|
|
| 769 | 769 |
} |
| 770 | 770 |
|
| 771 | 771 |
if err := sb.clearNetworkResources(ep); err != nil {
|
| 772 |
- log.G(context.TODO()).Warnf("Failed to clean up network resources on container %s disconnect: %v", ep.name, err)
|
|
| 772 |
+ log.G(ctx).Warnf("Failed to clean up network resources on container %s disconnect: %v", ep.name, err)
|
|
| 773 | 773 |
} |
| 774 | 774 |
|
| 775 | 775 |
// Update the store about the sandbox detach only after we |
| ... | ... |
@@ -777,12 +777,12 @@ func (ep *Endpoint) sbLeave(sb *Sandbox, force bool) error {
|
| 777 | 777 |
// spurious logs when cleaning up the sandbox when the daemon |
| 778 | 778 |
// ungracefully exits and restarts before completing sandbox |
| 779 | 779 |
// detach but after store has been updated. |
| 780 |
- if err := n.getController().updateToStore(context.TODO(), ep); err != nil {
|
|
| 780 |
+ if err := n.getController().updateToStore(ctx, ep); err != nil {
|
|
| 781 | 781 |
return err |
| 782 | 782 |
} |
| 783 | 783 |
|
| 784 | 784 |
if e := ep.deleteDriverInfoFromCluster(); e != nil {
|
| 785 |
- log.G(context.TODO()).Errorf("Failed to delete endpoint state for endpoint %s from cluster: %v", ep.Name(), e)
|
|
| 785 |
+ log.G(ctx).Errorf("Failed to delete endpoint state for endpoint %s from cluster: %v", ep.Name(), e)
|
|
| 786 | 786 |
} |
| 787 | 787 |
|
| 788 | 788 |
sb.deleteHostsEntries(n.getSvcRecords(ep)) |
| ... | ... |
@@ -798,7 +798,7 @@ func (ep *Endpoint) sbLeave(sb *Sandbox, force bool) error {
|
| 798 | 798 |
// New endpoint providing external connectivity for the sandbox |
| 799 | 799 |
extEp = sb.getGatewayEndpoint() |
| 800 | 800 |
if moveExtConn && extEp != nil {
|
| 801 |
- log.G(context.TODO()).Debugf("Programming external connectivity on endpoint %s (%s)", extEp.Name(), extEp.ID())
|
|
| 801 |
+ log.G(ctx).Debugf("Programming external connectivity on endpoint %s (%s)", extEp.Name(), extEp.ID())
|
|
| 802 | 802 |
extN, err := extEp.getNetworkFromStore() |
| 803 | 803 |
if err != nil {
|
| 804 | 804 |
return fmt.Errorf("failed to get network from store for programming external connectivity during leave: %v", err)
|
| ... | ... |
@@ -807,15 +807,15 @@ func (ep *Endpoint) sbLeave(sb *Sandbox, force bool) error {
|
| 807 | 807 |
if err != nil {
|
| 808 | 808 |
return fmt.Errorf("failed to get driver for programming external connectivity during leave: %v", err)
|
| 809 | 809 |
} |
| 810 |
- if err := extD.ProgramExternalConnectivity(context.WithoutCancel(context.TODO()), extEp.network.ID(), extEp.ID(), sb.Labels()); err != nil {
|
|
| 811 |
- log.G(context.TODO()).Warnf("driver failed programming external connectivity on endpoint %s: (%s) %v",
|
|
| 810 |
+ if err := extD.ProgramExternalConnectivity(context.WithoutCancel(ctx), extEp.network.ID(), extEp.ID(), sb.Labels()); err != nil {
|
|
| 811 |
+ log.G(ctx).Warnf("driver failed programming external connectivity on endpoint %s: (%s) %v",
|
|
| 812 | 812 |
extEp.Name(), extEp.ID(), err) |
| 813 | 813 |
} |
| 814 | 814 |
} |
| 815 | 815 |
|
| 816 | 816 |
if !sb.needDefaultGW() {
|
| 817 | 817 |
if err := sb.clearDefaultGW(); err != nil {
|
| 818 |
- log.G(context.TODO()).Warnf("Failure while disconnecting sandbox %s (%s) from gateway network: %v",
|
|
| 818 |
+ log.G(ctx).Warnf("Failure while disconnecting sandbox %s (%s) from gateway network: %v",
|
|
| 819 | 819 |
sb.ID(), sb.ContainerID(), err) |
| 820 | 820 |
} |
| 821 | 821 |
} |
| ... | ... |
@@ -824,7 +824,7 @@ func (ep *Endpoint) sbLeave(sb *Sandbox, force bool) error {
|
| 824 | 824 |
} |
| 825 | 825 |
|
| 826 | 826 |
// Delete deletes and detaches this endpoint from the network. |
| 827 |
-func (ep *Endpoint) Delete(force bool) error {
|
|
| 827 |
+func (ep *Endpoint) Delete(ctx context.Context, force bool) error {
|
|
| 828 | 828 |
var err error |
| 829 | 829 |
n, err := ep.getNetworkFromStore() |
| 830 | 830 |
if err != nil {
|
| ... | ... |
@@ -848,8 +848,8 @@ func (ep *Endpoint) Delete(force bool) error {
|
| 848 | 848 |
} |
| 849 | 849 |
|
| 850 | 850 |
if sb != nil {
|
| 851 |
- if e := ep.sbLeave(sb, force); e != nil {
|
|
| 852 |
- log.G(context.TODO()).Warnf("failed to leave sandbox for endpoint %s : %v", name, e)
|
|
| 851 |
+ if e := ep.sbLeave(context.WithoutCancel(ctx), sb, force); e != nil {
|
|
| 852 |
+ log.G(ctx).Warnf("failed to leave sandbox for endpoint %s : %v", name, e)
|
|
| 853 | 853 |
} |
| 854 | 854 |
} |
| 855 | 855 |
|
| ... | ... |
@@ -860,14 +860,14 @@ func (ep *Endpoint) Delete(force bool) error {
|
| 860 | 860 |
defer func() {
|
| 861 | 861 |
if err != nil && !force {
|
| 862 | 862 |
ep.dbExists = false |
| 863 |
- if e := n.getController().updateToStore(context.WithoutCancel(context.TODO()), ep); e != nil {
|
|
| 864 |
- log.G(context.TODO()).Warnf("failed to recreate endpoint in store %s : %v", name, e)
|
|
| 863 |
+ if e := n.getController().updateToStore(context.WithoutCancel(ctx), ep); e != nil {
|
|
| 864 |
+ log.G(ctx).Warnf("failed to recreate endpoint in store %s : %v", name, e)
|
|
| 865 | 865 |
} |
| 866 | 866 |
} |
| 867 | 867 |
}() |
| 868 | 868 |
|
| 869 | 869 |
if !n.getController().isSwarmNode() || n.Scope() != scope.Swarm || !n.driverIsMultihost() {
|
| 870 |
- n.updateSvcRecord(context.WithoutCancel(context.TODO()), ep, false) |
|
| 870 |
+ n.updateSvcRecord(context.WithoutCancel(ctx), ep, false) |
|
| 871 | 871 |
} |
| 872 | 872 |
|
| 873 | 873 |
if err = ep.deleteEndpoint(force); err != nil && !force {
|
| ... | ... |
@@ -877,7 +877,7 @@ func (ep *Endpoint) Delete(force bool) error {
|
| 877 | 877 |
ep.releaseAddress() |
| 878 | 878 |
|
| 879 | 879 |
if err := n.getEpCnt().DecEndpointCnt(); err != nil {
|
| 880 |
- log.G(context.TODO()).Warnf("failed to decrement endpoint count for ep %s: %v", ep.ID(), err)
|
|
| 880 |
+ log.G(ctx).Warnf("failed to decrement endpoint count for ep %s: %v", ep.ID(), err)
|
|
| 881 | 881 |
} |
| 882 | 882 |
|
| 883 | 883 |
return nil |
| ... | ... |
@@ -1208,7 +1208,7 @@ func (c *Controller) cleanupLocalEndpoints() error {
|
| 1208 | 1208 |
continue |
| 1209 | 1209 |
} |
| 1210 | 1210 |
log.G(context.TODO()).Infof("Removing stale endpoint %s (%s)", ep.name, ep.id)
|
| 1211 |
- if err := ep.Delete(true); err != nil {
|
|
| 1211 |
+ if err := ep.Delete(context.WithoutCancel(context.TODO()), true); err != nil {
|
|
| 1212 | 1212 |
log.G(context.TODO()).Warnf("Could not delete local endpoint %s during endpoint cleanup: %v", ep.name, err)
|
| 1213 | 1213 |
} |
| 1214 | 1214 |
} |
| ... | ... |
@@ -630,7 +630,7 @@ func TestIpamReleaseOnNetDriverFailures(t *testing.T) {
|
| 630 | 630 |
if err != nil {
|
| 631 | 631 |
t.Fatal(err) |
| 632 | 632 |
} |
| 633 |
- defer ep.Delete(false) //nolint:errcheck |
|
| 633 |
+ defer ep.Delete(context.Background(), false) //nolint:errcheck |
|
| 634 | 634 |
|
| 635 | 635 |
expectedIP, _ := types.ParseCIDR("10.35.0.1/16")
|
| 636 | 636 |
if !types.CompareIPNet(ep.Info().Iface().Address(), expectedIP) {
|
| ... | ... |
@@ -120,12 +120,12 @@ func TestNull(t *testing.T) {
|
| 120 | 120 |
t.Fatal(err) |
| 121 | 121 |
} |
| 122 | 122 |
|
| 123 |
- err = ep.Leave(cnt) |
|
| 123 |
+ err = ep.Leave(context.Background(), cnt) |
|
| 124 | 124 |
if err != nil {
|
| 125 | 125 |
t.Fatal(err) |
| 126 | 126 |
} |
| 127 | 127 |
|
| 128 |
- if err := ep.Delete(false); err != nil {
|
|
| 128 |
+ if err := ep.Delete(context.Background(), false); err != nil {
|
|
| 129 | 129 |
t.Fatal(err) |
| 130 | 130 |
} |
| 131 | 131 |
|
| ... | ... |
@@ -288,7 +288,7 @@ func TestDeleteNetworkWithActiveEndpoints(t *testing.T) {
|
| 288 | 288 |
} |
| 289 | 289 |
|
| 290 | 290 |
// Done testing. Now cleanup. |
| 291 |
- if err := ep.Delete(false); err != nil {
|
|
| 291 |
+ if err := ep.Delete(context.Background(), false); err != nil {
|
|
| 292 | 292 |
t.Fatal(err) |
| 293 | 293 |
} |
| 294 | 294 |
|
| ... | ... |
@@ -459,7 +459,7 @@ func TestUnknownEndpoint(t *testing.T) {
|
| 459 | 459 |
t.Fatal(err) |
| 460 | 460 |
} |
| 461 | 461 |
|
| 462 |
- err = ep.Delete(false) |
|
| 462 |
+ err = ep.Delete(context.Background(), false) |
|
| 463 | 463 |
if err != nil {
|
| 464 | 464 |
t.Fatal(err) |
| 465 | 465 |
} |
| ... | ... |
@@ -496,7 +496,7 @@ func TestNetworkEndpointsWalkers(t *testing.T) {
|
| 496 | 496 |
t.Fatal(err) |
| 497 | 497 |
} |
| 498 | 498 |
defer func() {
|
| 499 |
- if err := ep11.Delete(false); err != nil {
|
|
| 499 |
+ if err := ep11.Delete(context.Background(), false); err != nil {
|
|
| 500 | 500 |
t.Fatal(err) |
| 501 | 501 |
} |
| 502 | 502 |
}() |
| ... | ... |
@@ -506,7 +506,7 @@ func TestNetworkEndpointsWalkers(t *testing.T) {
|
| 506 | 506 |
t.Fatal(err) |
| 507 | 507 |
} |
| 508 | 508 |
defer func() {
|
| 509 |
- if err := ep12.Delete(false); err != nil {
|
|
| 509 |
+ if err := ep12.Delete(context.Background(), false); err != nil {
|
|
| 510 | 510 |
t.Fatal(err) |
| 511 | 511 |
} |
| 512 | 512 |
}() |
| ... | ... |
@@ -624,7 +624,7 @@ func TestDuplicateEndpoint(t *testing.T) {
|
| 624 | 624 |
t.Fatal(err) |
| 625 | 625 |
} |
| 626 | 626 |
defer func() {
|
| 627 |
- if err := ep.Delete(false); err != nil {
|
|
| 627 |
+ if err := ep.Delete(context.Background(), false); err != nil {
|
|
| 628 | 628 |
t.Fatal(err) |
| 629 | 629 |
} |
| 630 | 630 |
}() |
| ... | ... |
@@ -633,7 +633,7 @@ func TestDuplicateEndpoint(t *testing.T) {
|
| 633 | 633 |
defer func() {
|
| 634 | 634 |
// Cleanup ep2 as well, else network cleanup might fail for failure cases |
| 635 | 635 |
if ep2 != nil {
|
| 636 |
- if err := ep2.Delete(false); err != nil {
|
|
| 636 |
+ if err := ep2.Delete(context.Background(), false); err != nil {
|
|
| 637 | 637 |
t.Fatal(err) |
| 638 | 638 |
} |
| 639 | 639 |
} |
| ... | ... |
@@ -774,7 +774,7 @@ func TestNetworkQuery(t *testing.T) {
|
| 774 | 774 |
t.Fatal(err) |
| 775 | 775 |
} |
| 776 | 776 |
defer func() {
|
| 777 |
- if err := ep11.Delete(false); err != nil {
|
|
| 777 |
+ if err := ep11.Delete(context.Background(), false); err != nil {
|
|
| 778 | 778 |
t.Fatal(err) |
| 779 | 779 |
} |
| 780 | 780 |
}() |
| ... | ... |
@@ -784,7 +784,7 @@ func TestNetworkQuery(t *testing.T) {
|
| 784 | 784 |
t.Fatal(err) |
| 785 | 785 |
} |
| 786 | 786 |
defer func() {
|
| 787 |
- if err := ep12.Delete(false); err != nil {
|
|
| 787 |
+ if err := ep12.Delete(context.Background(), false); err != nil {
|
|
| 788 | 788 |
t.Fatal(err) |
| 789 | 789 |
} |
| 790 | 790 |
}() |
| ... | ... |
@@ -872,7 +872,7 @@ func TestEndpointDeleteWithActiveContainer(t *testing.T) {
|
| 872 | 872 |
t.Fatal(err) |
| 873 | 873 |
} |
| 874 | 874 |
defer func() {
|
| 875 |
- err = ep.Delete(false) |
|
| 875 |
+ err = ep.Delete(context.Background(), false) |
|
| 876 | 876 |
if err != nil {
|
| 877 | 877 |
t.Fatal(err) |
| 878 | 878 |
} |
| ... | ... |
@@ -893,13 +893,13 @@ func TestEndpointDeleteWithActiveContainer(t *testing.T) {
|
| 893 | 893 |
t.Fatal(err) |
| 894 | 894 |
} |
| 895 | 895 |
defer func() {
|
| 896 |
- err = ep.Leave(cnt) |
|
| 896 |
+ err = ep.Leave(context.Background(), cnt) |
|
| 897 | 897 |
if err != nil {
|
| 898 | 898 |
t.Fatal(err) |
| 899 | 899 |
} |
| 900 | 900 |
}() |
| 901 | 901 |
|
| 902 |
- err = ep.Delete(false) |
|
| 902 |
+ err = ep.Delete(context.Background(), false) |
|
| 903 | 903 |
if err == nil {
|
| 904 | 904 |
t.Fatal("Expected to fail. But instead succeeded")
|
| 905 | 905 |
} |
| ... | ... |
@@ -932,7 +932,7 @@ func TestEndpointMultipleJoins(t *testing.T) {
|
| 932 | 932 |
t.Fatal(err) |
| 933 | 933 |
} |
| 934 | 934 |
defer func() {
|
| 935 |
- if err := ep.Delete(false); err != nil {
|
|
| 935 |
+ if err := ep.Delete(context.Background(), false); err != nil {
|
|
| 936 | 936 |
t.Fatal(err) |
| 937 | 937 |
} |
| 938 | 938 |
}() |
| ... | ... |
@@ -966,7 +966,7 @@ func TestEndpointMultipleJoins(t *testing.T) {
|
| 966 | 966 |
t.Fatal(err) |
| 967 | 967 |
} |
| 968 | 968 |
defer func() {
|
| 969 |
- err = ep.Leave(sbx1) |
|
| 969 |
+ err = ep.Leave(context.Background(), sbx1) |
|
| 970 | 970 |
if err != nil {
|
| 971 | 971 |
t.Fatal(err) |
| 972 | 972 |
} |
| ... | ... |
@@ -1069,7 +1069,7 @@ func TestContainerInvalidLeave(t *testing.T) {
|
| 1069 | 1069 |
t.Fatal(err) |
| 1070 | 1070 |
} |
| 1071 | 1071 |
defer func() {
|
| 1072 |
- if err := ep.Delete(false); err != nil {
|
|
| 1072 |
+ if err := ep.Delete(context.Background(), false); err != nil {
|
|
| 1073 | 1073 |
t.Fatal(err) |
| 1074 | 1074 |
} |
| 1075 | 1075 |
}() |
| ... | ... |
@@ -1087,7 +1087,7 @@ func TestContainerInvalidLeave(t *testing.T) {
|
| 1087 | 1087 |
} |
| 1088 | 1088 |
}() |
| 1089 | 1089 |
|
| 1090 |
- err = ep.Leave(cnt) |
|
| 1090 |
+ err = ep.Leave(context.Background(), cnt) |
|
| 1091 | 1091 |
if err == nil {
|
| 1092 | 1092 |
t.Fatal("Expected to fail leave from an endpoint which has no active join")
|
| 1093 | 1093 |
} |
| ... | ... |
@@ -1095,7 +1095,7 @@ func TestContainerInvalidLeave(t *testing.T) {
|
| 1095 | 1095 |
t.Fatalf("Failed with unexpected error type: %T. Desc: %s", err, err.Error())
|
| 1096 | 1096 |
} |
| 1097 | 1097 |
|
| 1098 |
- if err = ep.Leave(nil); err == nil {
|
|
| 1098 |
+ if err = ep.Leave(context.Background(), nil); err == nil {
|
|
| 1099 | 1099 |
t.Fatalf("Expected to fail leave nil Sandbox")
|
| 1100 | 1100 |
} |
| 1101 | 1101 |
if _, ok := err.(types.InvalidParameterError); !ok {
|
| ... | ... |
@@ -1103,7 +1103,7 @@ func TestContainerInvalidLeave(t *testing.T) {
|
| 1103 | 1103 |
} |
| 1104 | 1104 |
|
| 1105 | 1105 |
fsbx := &libnetwork.Sandbox{}
|
| 1106 |
- if err = ep.Leave(fsbx); err == nil {
|
|
| 1106 |
+ if err = ep.Leave(context.Background(), fsbx); err == nil {
|
|
| 1107 | 1107 |
t.Fatalf("Expected to fail leave with invalid Sandbox")
|
| 1108 | 1108 |
} |
| 1109 | 1109 |
if _, ok := err.(types.InvalidParameterError); !ok {
|
| ... | ... |
@@ -1357,19 +1357,19 @@ func TestHost(t *testing.T) {
|
| 1357 | 1357 |
t.Fatal(err) |
| 1358 | 1358 |
} |
| 1359 | 1359 |
|
| 1360 |
- if err := ep1.Leave(sbx1); err != nil {
|
|
| 1360 |
+ if err := ep1.Leave(context.Background(), sbx1); err != nil {
|
|
| 1361 | 1361 |
t.Fatal(err) |
| 1362 | 1362 |
} |
| 1363 | 1363 |
|
| 1364 |
- if err := ep2.Leave(sbx2); err != nil {
|
|
| 1364 |
+ if err := ep2.Leave(context.Background(), sbx2); err != nil {
|
|
| 1365 | 1365 |
t.Fatal(err) |
| 1366 | 1366 |
} |
| 1367 | 1367 |
|
| 1368 |
- if err := ep1.Delete(false); err != nil {
|
|
| 1368 |
+ if err := ep1.Delete(context.Background(), false); err != nil {
|
|
| 1369 | 1369 |
t.Fatal(err) |
| 1370 | 1370 |
} |
| 1371 | 1371 |
|
| 1372 |
- if err := ep2.Delete(false); err != nil {
|
|
| 1372 |
+ if err := ep2.Delete(context.Background(), false); err != nil {
|
|
| 1373 | 1373 |
t.Fatal(err) |
| 1374 | 1374 |
} |
| 1375 | 1375 |
|
| ... | ... |
@@ -1397,11 +1397,11 @@ func TestHost(t *testing.T) {
|
| 1397 | 1397 |
t.Fatal(err) |
| 1398 | 1398 |
} |
| 1399 | 1399 |
|
| 1400 |
- if err := ep3.Leave(sbx2); err != nil {
|
|
| 1400 |
+ if err := ep3.Leave(context.Background(), sbx2); err != nil {
|
|
| 1401 | 1401 |
t.Fatal(err) |
| 1402 | 1402 |
} |
| 1403 | 1403 |
|
| 1404 |
- if err := ep3.Delete(false); err != nil {
|
|
| 1404 |
+ if err := ep3.Delete(context.Background(), false); err != nil {
|
|
| 1405 | 1405 |
t.Fatal(err) |
| 1406 | 1406 |
} |
| 1407 | 1407 |
} |
| ... | ... |
@@ -1449,7 +1449,7 @@ func TestBridgeIpv6FromMac(t *testing.T) {
|
| 1449 | 1449 |
t.Fatalf("Expected %v. Got: %v", expIP, iface.AddressIPv6())
|
| 1450 | 1450 |
} |
| 1451 | 1451 |
|
| 1452 |
- if err := ep.Delete(false); err != nil {
|
|
| 1452 |
+ if err := ep.Delete(context.Background(), false); err != nil {
|
|
| 1453 | 1453 |
t.Fatal(err) |
| 1454 | 1454 |
} |
| 1455 | 1455 |
|
| ... | ... |
@@ -1514,7 +1514,7 @@ func TestEndpointJoin(t *testing.T) {
|
| 1514 | 1514 |
t.Fatal(err) |
| 1515 | 1515 |
} |
| 1516 | 1516 |
defer func() {
|
| 1517 |
- if err := ep1.Delete(false); err != nil {
|
|
| 1517 |
+ if err := ep1.Delete(context.Background(), false); err != nil {
|
|
| 1518 | 1518 |
t.Fatal(err) |
| 1519 | 1519 |
} |
| 1520 | 1520 |
}() |
| ... | ... |
@@ -1576,7 +1576,7 @@ func TestEndpointJoin(t *testing.T) {
|
| 1576 | 1576 |
t.Fatal(err) |
| 1577 | 1577 |
} |
| 1578 | 1578 |
defer func() {
|
| 1579 |
- err = ep1.Leave(sb) |
|
| 1579 |
+ err = ep1.Leave(context.Background(), sb) |
|
| 1580 | 1580 |
if err != nil {
|
| 1581 | 1581 |
t.Fatal(err) |
| 1582 | 1582 |
} |
| ... | ... |
@@ -1630,7 +1630,7 @@ func TestEndpointJoin(t *testing.T) {
|
| 1630 | 1630 |
t.Fatal(err) |
| 1631 | 1631 |
} |
| 1632 | 1632 |
defer func() {
|
| 1633 |
- if err := ep2.Delete(false); err != nil {
|
|
| 1633 |
+ if err := ep2.Delete(context.Background(), false); err != nil {
|
|
| 1634 | 1634 |
t.Fatal(err) |
| 1635 | 1635 |
} |
| 1636 | 1636 |
}() |
| ... | ... |
@@ -1640,7 +1640,7 @@ func TestEndpointJoin(t *testing.T) {
|
| 1640 | 1640 |
t.Fatal(err) |
| 1641 | 1641 |
} |
| 1642 | 1642 |
defer func() {
|
| 1643 |
- err = ep2.Leave(sb) |
|
| 1643 |
+ err = ep2.Leave(context.Background(), sb) |
|
| 1644 | 1644 |
if err != nil {
|
| 1645 | 1645 |
t.Fatal(err) |
| 1646 | 1646 |
} |
| ... | ... |
@@ -1694,7 +1694,7 @@ func externalKeyTest(t *testing.T, reexec bool) {
|
| 1694 | 1694 |
t.Fatal(err) |
| 1695 | 1695 |
} |
| 1696 | 1696 |
defer func() {
|
| 1697 |
- err = ep.Delete(false) |
|
| 1697 |
+ err = ep.Delete(context.Background(), false) |
|
| 1698 | 1698 |
if err != nil {
|
| 1699 | 1699 |
t.Fatal(err) |
| 1700 | 1700 |
} |
| ... | ... |
@@ -1705,7 +1705,7 @@ func externalKeyTest(t *testing.T, reexec bool) {
|
| 1705 | 1705 |
t.Fatal(err) |
| 1706 | 1706 |
} |
| 1707 | 1707 |
defer func() {
|
| 1708 |
- err = ep2.Delete(false) |
|
| 1708 |
+ err = ep2.Delete(context.Background(), false) |
|
| 1709 | 1709 |
if err != nil {
|
| 1710 | 1710 |
t.Fatal(err) |
| 1711 | 1711 |
} |
| ... | ... |
@@ -1729,7 +1729,7 @@ func externalKeyTest(t *testing.T, reexec bool) {
|
| 1729 | 1729 |
t.Fatal(err) |
| 1730 | 1730 |
} |
| 1731 | 1731 |
defer func() {
|
| 1732 |
- err = ep.Leave(cnt) |
|
| 1732 |
+ err = ep.Leave(context.Background(), cnt) |
|
| 1733 | 1733 |
if err != nil {
|
| 1734 | 1734 |
t.Fatal(err) |
| 1735 | 1735 |
} |
| ... | ... |
@@ -1780,7 +1780,7 @@ func externalKeyTest(t *testing.T, reexec bool) {
|
| 1780 | 1780 |
t.Fatal(err) |
| 1781 | 1781 |
} |
| 1782 | 1782 |
defer func() {
|
| 1783 |
- err = ep2.Leave(sbox) |
|
| 1783 |
+ err = ep2.Leave(context.Background(), sbox) |
|
| 1784 | 1784 |
if err != nil {
|
| 1785 | 1785 |
t.Fatal(err) |
| 1786 | 1786 |
} |
| ... | ... |
@@ -1883,14 +1883,14 @@ func TestResolvConf(t *testing.T) {
|
| 1883 | 1883 |
ep, err := n.CreateEndpoint(context.Background(), "ep", tc.epOpts...) |
| 1884 | 1884 |
assert.NilError(t, err) |
| 1885 | 1885 |
defer func() {
|
| 1886 |
- err := ep.Delete(false) |
|
| 1886 |
+ err := ep.Delete(context.Background(), false) |
|
| 1887 | 1887 |
assert.Check(t, err) |
| 1888 | 1888 |
}() |
| 1889 | 1889 |
|
| 1890 | 1890 |
err = ep.Join(context.Background(), sb) |
| 1891 | 1891 |
assert.NilError(t, err) |
| 1892 | 1892 |
defer func() {
|
| 1893 |
- err := ep.Leave(sb) |
|
| 1893 |
+ err := ep.Leave(context.Background(), sb) |
|
| 1894 | 1894 |
assert.Check(t, err) |
| 1895 | 1895 |
}() |
| 1896 | 1896 |
|
| ... | ... |
@@ -1947,7 +1947,7 @@ func (pt parallelTester) Do(t *testing.T, thrNumber int) error {
|
| 1947 | 1947 |
return errors.Wrapf(err, "thread %d", thrNumber) |
| 1948 | 1948 |
} |
| 1949 | 1949 |
} |
| 1950 |
- if err := ep.Leave(sb); err != nil {
|
|
| 1950 |
+ if err := ep.Leave(context.Background(), sb); err != nil {
|
|
| 1951 | 1951 |
if _, ok := err.(types.ForbiddenError); !ok {
|
| 1952 | 1952 |
return errors.Wrapf(err, "thread %d", thrNumber) |
| 1953 | 1953 |
} |
| ... | ... |
@@ -1957,7 +1957,7 @@ func (pt parallelTester) Do(t *testing.T, thrNumber int) error {
|
| 1957 | 1957 |
if err := errors.WithStack(sb.Delete()); err != nil {
|
| 1958 | 1958 |
return err |
| 1959 | 1959 |
} |
| 1960 |
- return errors.WithStack(ep.Delete(false)) |
|
| 1960 |
+ return errors.WithStack(ep.Delete(context.Background(), false)) |
|
| 1961 | 1961 |
} |
| 1962 | 1962 |
|
| 1963 | 1963 |
func TestParallel(t *testing.T) {
|
| ... | ... |
@@ -2139,7 +2139,7 @@ func (n *Network) createLoadBalancerSandbox() (retErr error) {
|
| 2139 | 2139 |
} |
| 2140 | 2140 |
defer func() {
|
| 2141 | 2141 |
if retErr != nil {
|
| 2142 |
- if e := ep.Delete(true); e != nil {
|
|
| 2142 |
+ if e := ep.Delete(context.WithoutCancel(context.TODO()), true); e != nil {
|
|
| 2143 | 2143 |
log.G(context.TODO()).Warnf("could not delete endpoint %s on failure on failure (%v): %v", endpointName, retErr, e)
|
| 2144 | 2144 |
} |
| 2145 | 2145 |
} |
| ... | ... |
@@ -2176,7 +2176,7 @@ func (n *Network) deleteLoadBalancerSandbox() error {
|
| 2176 | 2176 |
} |
| 2177 | 2177 |
} |
| 2178 | 2178 |
|
| 2179 |
- if err := endpoint.Delete(true); err != nil {
|
|
| 2179 |
+ if err := endpoint.Delete(context.TODO(), true); err != nil {
|
|
| 2180 | 2180 |
log.G(context.TODO()).Warnf("Failed to delete endpoint %s (%s) in %s: %v", endpoint.Name(), endpoint.ID(), sandboxName, err)
|
| 2181 | 2181 |
// Ignore error and attempt to delete the sandbox. |
| 2182 | 2182 |
} |
| ... | ... |
@@ -171,12 +171,12 @@ func (sb *Sandbox) delete(force bool) error {
|
| 171 | 171 |
} |
| 172 | 172 |
|
| 173 | 173 |
if !force {
|
| 174 |
- if err := ep.Leave(sb); err != nil {
|
|
| 174 |
+ if err := ep.Leave(context.WithoutCancel(context.TODO()), sb); err != nil {
|
|
| 175 | 175 |
log.G(context.TODO()).Warnf("Failed detaching sandbox %s from endpoint %s: %v\n", sb.ID(), ep.ID(), err)
|
| 176 | 176 |
} |
| 177 | 177 |
} |
| 178 | 178 |
|
| 179 |
- if err := ep.Delete(force); err != nil {
|
|
| 179 |
+ if err := ep.Delete(context.WithoutCancel(context.TODO()), force); err != nil {
|
|
| 180 | 180 |
log.G(context.TODO()).Warnf("Failed deleting endpoint %s: %v\n", ep.ID(), err)
|
| 181 | 181 |
} |
| 182 | 182 |
} |
| ... | ... |
@@ -244,14 +244,14 @@ func (sb *Sandbox) Rename(name string) error {
|
| 244 | 244 |
|
| 245 | 245 |
// Refresh leaves all the endpoints, resets and re-applies the options, |
| 246 | 246 |
// re-joins all the endpoints without destroying the osl sandbox |
| 247 |
-func (sb *Sandbox) Refresh(options ...SandboxOption) error {
|
|
| 247 |
+func (sb *Sandbox) Refresh(ctx context.Context, options ...SandboxOption) error {
|
|
| 248 | 248 |
// Store connected endpoints |
| 249 | 249 |
epList := sb.Endpoints() |
| 250 | 250 |
|
| 251 | 251 |
// Detach from all endpoints |
| 252 | 252 |
for _, ep := range epList {
|
| 253 |
- if err := ep.Leave(sb); err != nil {
|
|
| 254 |
- log.G(context.TODO()).Warnf("Failed detaching sandbox %s from endpoint %s: %v\n", sb.ID(), ep.ID(), err)
|
|
| 253 |
+ if err := ep.Leave(context.WithoutCancel(ctx), sb); err != nil {
|
|
| 254 |
+ log.G(ctx).Warnf("Failed detaching sandbox %s from endpoint %s: %v\n", sb.ID(), ep.ID(), err)
|
|
| 255 | 255 |
} |
| 256 | 256 |
} |
| 257 | 257 |
|
| ... | ... |
@@ -266,8 +266,8 @@ func (sb *Sandbox) Refresh(options ...SandboxOption) error {
|
| 266 | 266 |
|
| 267 | 267 |
// Re-connect to all endpoints |
| 268 | 268 |
for _, ep := range epList {
|
| 269 |
- if err := ep.Join(context.WithoutCancel(context.TODO()), sb); err != nil {
|
|
| 270 |
- log.G(context.TODO()).Warnf("Failed attach sandbox %s to endpoint %s: %v\n", sb.ID(), ep.ID(), err)
|
|
| 269 |
+ if err := ep.Join(context.WithoutCancel(ctx), sb); err != nil {
|
|
| 270 |
+ log.G(ctx).Warnf("Failed attach sandbox %s to endpoint %s: %v\n", sb.ID(), ep.ID(), err)
|
|
| 271 | 271 |
} |
| 272 | 272 |
} |
| 273 | 273 |
|
| ... | ... |
@@ -163,14 +163,14 @@ func TestSandboxAddMultiPrio(t *testing.T) {
|
| 163 | 163 |
t.Fatal("Expected 3 endpoints to be connected to the sandbox.")
|
| 164 | 164 |
} |
| 165 | 165 |
|
| 166 |
- if err := ep3.Leave(sbx); err != nil {
|
|
| 166 |
+ if err := ep3.Leave(context.Background(), sbx); err != nil {
|
|
| 167 | 167 |
t.Fatal(err) |
| 168 | 168 |
} |
| 169 | 169 |
if ctrlr.sandboxes[sid].endpoints[0].ID() != ep2.ID() {
|
| 170 | 170 |
t.Fatal("Expected ep2 to be at the top of the heap after removing ep3. But did not find ep2 at the top of the heap")
|
| 171 | 171 |
} |
| 172 | 172 |
|
| 173 |
- if err := ep2.Leave(sbx); err != nil {
|
|
| 173 |
+ if err := ep2.Leave(context.Background(), sbx); err != nil {
|
|
| 174 | 174 |
t.Fatal(err) |
| 175 | 175 |
} |
| 176 | 176 |
if ctrlr.sandboxes[sid].endpoints[0].ID() != ep1.ID() {
|
| ... | ... |
@@ -265,7 +265,7 @@ func TestSandboxAddSamePrio(t *testing.T) {
|
| 265 | 265 |
t.Fatal("Expected epInternal to be at the bottom of the heap. But did not find epInternal at the bottom of the heap")
|
| 266 | 266 |
} |
| 267 | 267 |
|
| 268 |
- if err := epIPv6.Leave(sbx); err != nil {
|
|
| 268 |
+ if err := epIPv6.Leave(context.Background(), sbx); err != nil {
|
|
| 269 | 269 |
t.Fatal(err) |
| 270 | 270 |
} |
| 271 | 271 |
|
| ... | ... |
@@ -274,7 +274,7 @@ func TestSandboxAddSamePrio(t *testing.T) {
|
| 274 | 274 |
t.Fatal("Expected epNw0 to be at the top of the heap after removing epIPv6. But did not find epNw0 at the top of the heap")
|
| 275 | 275 |
} |
| 276 | 276 |
|
| 277 |
- if err := epNw1.Leave(sbx); err != nil {
|
|
| 277 |
+ if err := epNw1.Leave(context.Background(), sbx); err != nil {
|
|
| 278 | 278 |
t.Fatal(err) |
| 279 | 279 |
} |
| 280 | 280 |
|