Signed-off-by: Albin Kerouanton <albinker@gmail.com>
| ... | ... |
@@ -71,7 +71,7 @@ func (d *manager) IsBuiltIn() bool {
|
| 71 | 71 |
return true |
| 72 | 72 |
} |
| 73 | 73 |
|
| 74 |
-func (d *manager) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 74 |
+func (d *manager) ProgramExternalConnectivity(_ context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 75 | 75 |
return types.NotImplementedErrorf("not implemented")
|
| 76 | 76 |
} |
| 77 | 77 |
|
| ... | ... |
@@ -56,7 +56,7 @@ type Driver interface {
|
| 56 | 56 |
|
| 57 | 57 |
// ProgramExternalConnectivity invokes the driver method which does the necessary |
| 58 | 58 |
// programming to allow the external connectivity dictated by the passed options |
| 59 |
- ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error
|
|
| 59 |
+ ProgramExternalConnectivity(ctx context.Context, nid, eid string, options map[string]interface{}) error
|
|
| 60 | 60 |
|
| 61 | 61 |
// RevokeExternalConnectivity asks the driver to remove any external connectivity |
| 62 | 62 |
// programming that was done so far |
| ... | ... |
@@ -1391,7 +1391,12 @@ func (d *driver) Leave(nid, eid string) error {
|
| 1391 | 1391 |
return nil |
| 1392 | 1392 |
} |
| 1393 | 1393 |
|
| 1394 |
-func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 1394 |
+func (d *driver) ProgramExternalConnectivity(ctx context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 1395 |
+ ctx, span := otel.Tracer("").Start(ctx, "libnetwork.drivers.bridge.ProgramExternalConnectivity", trace.WithAttributes(
|
|
| 1396 |
+ attribute.String("nid", nid),
|
|
| 1397 |
+ attribute.String("eid", eid)))
|
|
| 1398 |
+ defer span.End() |
|
| 1399 |
+ |
|
| 1395 | 1400 |
network, err := d.getNetwork(nid) |
| 1396 | 1401 |
if err != nil {
|
| 1397 | 1402 |
return err |
| ... | ... |
@@ -1427,7 +1432,7 @@ func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string |
| 1427 | 1427 |
defer func() {
|
| 1428 | 1428 |
if err != nil {
|
| 1429 | 1429 |
if e := network.releasePorts(endpoint); e != nil {
|
| 1430 |
- log.G(context.TODO()).Errorf("Failed to release ports allocated for the bridge endpoint %s on failure %v because of %v",
|
|
| 1430 |
+ log.G(ctx).Errorf("Failed to release ports allocated for the bridge endpoint %s on failure %v because of %v",
|
|
| 1431 | 1431 |
eid, err, e) |
| 1432 | 1432 |
} |
| 1433 | 1433 |
endpoint.portMapping = nil |
| ... | ... |
@@ -711,7 +711,7 @@ func testQueryEndpointInfo(t *testing.T, ulPxyEnabled bool) {
|
| 711 | 711 |
t.Fatalf("Failed to join the endpoint: %v", err)
|
| 712 | 712 |
} |
| 713 | 713 |
|
| 714 |
- err = d.ProgramExternalConnectivity("net1", "ep1", sbOptions)
|
|
| 714 |
+ err = d.ProgramExternalConnectivity(context.Background(), "net1", "ep1", sbOptions) |
|
| 715 | 715 |
if err != nil {
|
| 716 | 716 |
t.Fatalf("Failed to program external connectivity: %v", err)
|
| 717 | 717 |
} |
| ... | ... |
@@ -814,7 +814,7 @@ func TestLinkContainers(t *testing.T) {
|
| 814 | 814 |
t.Fatalf("Failed to join the endpoint: %v", err)
|
| 815 | 815 |
} |
| 816 | 816 |
|
| 817 |
- err = d.ProgramExternalConnectivity("net1", "ep1", sbOptions)
|
|
| 817 |
+ err = d.ProgramExternalConnectivity(context.Background(), "net1", "ep1", sbOptions) |
|
| 818 | 818 |
if err != nil {
|
| 819 | 819 |
t.Fatalf("Failed to program external connectivity: %v", err)
|
| 820 | 820 |
} |
| ... | ... |
@@ -845,7 +845,7 @@ func TestLinkContainers(t *testing.T) {
|
| 845 | 845 |
t.Fatal("Failed to link ep1 and ep2")
|
| 846 | 846 |
} |
| 847 | 847 |
|
| 848 |
- err = d.ProgramExternalConnectivity("net1", "ep2", sbOptions)
|
|
| 848 |
+ err = d.ProgramExternalConnectivity(context.Background(), "net1", "ep2", sbOptions) |
|
| 849 | 849 |
if err != nil {
|
| 850 | 850 |
t.Fatalf("Failed to program external connectivity: %v", err)
|
| 851 | 851 |
} |
| ... | ... |
@@ -902,7 +902,7 @@ func TestLinkContainers(t *testing.T) {
|
| 902 | 902 |
if err != nil {
|
| 903 | 903 |
t.Fatal(err) |
| 904 | 904 |
} |
| 905 |
- err = d.ProgramExternalConnectivity("net1", "ep2", sbOptions)
|
|
| 905 |
+ err = d.ProgramExternalConnectivity(context.Background(), "net1", "ep2", sbOptions) |
|
| 906 | 906 |
if err != nil {
|
| 907 | 907 |
out, _ = iptable.Raw("-L", DockerChain)
|
| 908 | 908 |
for _, pm := range exposedPorts {
|
| ... | ... |
@@ -71,7 +71,7 @@ func (d *driver) IsBuiltIn() bool {
|
| 71 | 71 |
return true |
| 72 | 72 |
} |
| 73 | 73 |
|
| 74 |
-func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 74 |
+func (d *driver) ProgramExternalConnectivity(_ context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 75 | 75 |
return types.NotImplementedErrorf("not implemented")
|
| 76 | 76 |
} |
| 77 | 77 |
|
| ... | ... |
@@ -62,7 +62,7 @@ func TestPortMappingConfig(t *testing.T) {
|
| 62 | 62 |
t.Fatalf("Failed to join the endpoint: %v", err)
|
| 63 | 63 |
} |
| 64 | 64 |
|
| 65 |
- if err = d.ProgramExternalConnectivity("dummy", "ep1", sbOptions); err != nil {
|
|
| 65 |
+ if err = d.ProgramExternalConnectivity(context.Background(), "dummy", "ep1", sbOptions); err != nil {
|
|
| 66 | 66 |
t.Fatalf("Failed to program external connectivity: %v", err)
|
| 67 | 67 |
} |
| 68 | 68 |
|
| ... | ... |
@@ -147,7 +147,7 @@ func TestPortMappingV6Config(t *testing.T) {
|
| 147 | 147 |
t.Fatalf("Failed to join the endpoint: %v", err)
|
| 148 | 148 |
} |
| 149 | 149 |
|
| 150 |
- if err = d.ProgramExternalConnectivity("dummy", "ep1", sbOptions); err != nil {
|
|
| 150 |
+ if err = d.ProgramExternalConnectivity(context.Background(), "dummy", "ep1", sbOptions); err != nil {
|
|
| 151 | 151 |
t.Fatalf("Failed to program external connectivity: %v", err)
|
| 152 | 152 |
} |
| 153 | 153 |
|
| ... | ... |
@@ -77,7 +77,7 @@ func (d *driver) Leave(nid, eid string) error {
|
| 77 | 77 |
return nil |
| 78 | 78 |
} |
| 79 | 79 |
|
| 80 |
-func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 80 |
+func (d *driver) ProgramExternalConnectivity(_ context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 81 | 81 |
return nil |
| 82 | 82 |
} |
| 83 | 83 |
|
| ... | ... |
@@ -3,6 +3,7 @@ |
| 3 | 3 |
package ipvlan |
| 4 | 4 |
|
| 5 | 5 |
import ( |
| 6 |
+ "context" |
|
| 6 | 7 |
"net" |
| 7 | 8 |
"sync" |
| 8 | 9 |
|
| ... | ... |
@@ -95,7 +96,7 @@ func (d *driver) IsBuiltIn() bool {
|
| 95 | 95 |
return true |
| 96 | 96 |
} |
| 97 | 97 |
|
| 98 |
-func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 98 |
+func (d *driver) ProgramExternalConnectivity(_ context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 99 | 99 |
return nil |
| 100 | 100 |
} |
| 101 | 101 |
|
| ... | ... |
@@ -71,7 +71,7 @@ func (d *driver) IsBuiltIn() bool {
|
| 71 | 71 |
return true |
| 72 | 72 |
} |
| 73 | 73 |
|
| 74 |
-func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 74 |
+func (d *driver) ProgramExternalConnectivity(_ context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 75 | 75 |
return types.NotImplementedErrorf("not implemented")
|
| 76 | 76 |
} |
| 77 | 77 |
|
| ... | ... |
@@ -3,6 +3,7 @@ |
| 3 | 3 |
package macvlan |
| 4 | 4 |
|
| 5 | 5 |
import ( |
| 6 |
+ "context" |
|
| 6 | 7 |
"net" |
| 7 | 8 |
"sync" |
| 8 | 9 |
|
| ... | ... |
@@ -89,7 +90,7 @@ func (d *driver) IsBuiltIn() bool {
|
| 89 | 89 |
return true |
| 90 | 90 |
} |
| 91 | 91 |
|
| 92 |
-func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 92 |
+func (d *driver) ProgramExternalConnectivity(_ context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 93 | 93 |
return nil |
| 94 | 94 |
} |
| 95 | 95 |
|
| ... | ... |
@@ -71,7 +71,7 @@ func (d *driver) IsBuiltIn() bool {
|
| 71 | 71 |
return true |
| 72 | 72 |
} |
| 73 | 73 |
|
| 74 |
-func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 74 |
+func (d *driver) ProgramExternalConnectivity(_ context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 75 | 75 |
return types.NotImplementedErrorf("not implemented")
|
| 76 | 76 |
} |
| 77 | 77 |
|
| ... | ... |
@@ -77,7 +77,7 @@ func (d *driver) Leave(nid, eid string) error {
|
| 77 | 77 |
return nil |
| 78 | 78 |
} |
| 79 | 79 |
|
| 80 |
-func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 80 |
+func (d *driver) ProgramExternalConnectivity(_ context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 81 | 81 |
return nil |
| 82 | 82 |
} |
| 83 | 83 |
|
| ... | ... |
@@ -235,7 +235,7 @@ func (d *driver) DeleteNetwork(nid string) error {
|
| 235 | 235 |
return nil |
| 236 | 236 |
} |
| 237 | 237 |
|
| 238 |
-func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 238 |
+func (d *driver) ProgramExternalConnectivity(_ context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 239 | 239 |
return nil |
| 240 | 240 |
} |
| 241 | 241 |
|
| ... | ... |
@@ -207,7 +207,7 @@ func (d *driver) IsBuiltIn() bool {
|
| 207 | 207 |
return true |
| 208 | 208 |
} |
| 209 | 209 |
|
| 210 |
-func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 210 |
+func (d *driver) ProgramExternalConnectivity(_ context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 211 | 211 |
return types.NotImplementedErrorf("not implemented")
|
| 212 | 212 |
} |
| 213 | 213 |
|
| ... | ... |
@@ -334,7 +334,7 @@ func (d *driver) Leave(nid, eid string) error {
|
| 334 | 334 |
} |
| 335 | 335 |
|
| 336 | 336 |
// ProgramExternalConnectivity is invoked to program the rules to allow external connectivity for the endpoint. |
| 337 |
-func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 337 |
+func (d *driver) ProgramExternalConnectivity(_ context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 338 | 338 |
data := &api.ProgramExternalConnectivityRequest{
|
| 339 | 339 |
NetworkID: nid, |
| 340 | 340 |
EndpointID: eid, |
| ... | ... |
@@ -211,7 +211,7 @@ func (d *driver) DeleteNetwork(nid string) error {
|
| 211 | 211 |
return nil |
| 212 | 212 |
} |
| 213 | 213 |
|
| 214 |
-func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 214 |
+func (d *driver) ProgramExternalConnectivity(_ context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 215 | 215 |
return nil |
| 216 | 216 |
} |
| 217 | 217 |
|
| ... | ... |
@@ -895,7 +895,7 @@ func (d *driver) Leave(nid, eid string) error {
|
| 895 | 895 |
return nil |
| 896 | 896 |
} |
| 897 | 897 |
|
| 898 |
-func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 898 |
+func (d *driver) ProgramExternalConnectivity(_ context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 899 | 899 |
return nil |
| 900 | 900 |
} |
| 901 | 901 |
|
| ... | ... |
@@ -613,7 +613,7 @@ func (ep *Endpoint) sbJoin(ctx context.Context, sb *Sandbox, options ...Endpoint |
| 613 | 613 |
} |
| 614 | 614 |
defer func() {
|
| 615 | 615 |
if err != nil {
|
| 616 |
- if e := extD.ProgramExternalConnectivity(extEp.network.ID(), extEp.ID(), sb.Labels()); e != nil {
|
|
| 616 |
+ if e := extD.ProgramExternalConnectivity(context.WithoutCancel(ctx), extEp.network.ID(), extEp.ID(), sb.Labels()); e != nil {
|
|
| 617 | 617 |
log.G(ctx).Warnf("Failed to roll-back external connectivity on endpoint %s (%s): %v",
|
| 618 | 618 |
extEp.Name(), extEp.ID(), e) |
| 619 | 619 |
} |
| ... | ... |
@@ -622,7 +622,7 @@ func (ep *Endpoint) sbJoin(ctx context.Context, sb *Sandbox, options ...Endpoint |
| 622 | 622 |
} |
| 623 | 623 |
if !n.internal {
|
| 624 | 624 |
log.G(ctx).Debugf("Programming external connectivity on endpoint %s (%s)", ep.Name(), ep.ID())
|
| 625 |
- if err = d.ProgramExternalConnectivity(n.ID(), ep.ID(), sb.Labels()); err != nil {
|
|
| 625 |
+ if err = d.ProgramExternalConnectivity(ctx, n.ID(), ep.ID(), sb.Labels()); err != nil {
|
|
| 626 | 626 |
return types.InternalErrorf( |
| 627 | 627 |
"driver failed programming external connectivity on endpoint %s (%s): %v", |
| 628 | 628 |
ep.Name(), ep.ID(), err) |
| ... | ... |
@@ -807,7 +807,7 @@ 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(extEp.network.ID(), extEp.ID(), sb.Labels()); err != nil {
|
|
| 810 |
+ if err := extD.ProgramExternalConnectivity(context.WithoutCancel(context.TODO()), extEp.network.ID(), extEp.ID(), sb.Labels()); err != nil {
|
|
| 811 | 811 |
log.G(context.TODO()).Warnf("driver failed programming external connectivity on endpoint %s: (%s) %v",
|
| 812 | 812 |
extEp.Name(), extEp.ID(), err) |
| 813 | 813 |
} |
| ... | ... |
@@ -689,7 +689,7 @@ func (b *badDriver) IsBuiltIn() bool {
|
| 689 | 689 |
return false |
| 690 | 690 |
} |
| 691 | 691 |
|
| 692 |
-func (b *badDriver) ProgramExternalConnectivity(nid, eid string, options map[string]interface{}) error {
|
|
| 692 |
+func (b *badDriver) ProgramExternalConnectivity(_ context.Context, nid, eid string, options map[string]interface{}) error {
|
|
| 693 | 693 |
return nil |
| 694 | 694 |
} |
| 695 | 695 |
|