Signed-off-by: Albin Kerouanton <albinker@gmail.com>
| ... | ... |
@@ -797,7 +797,7 @@ func (daemon *Daemon) connectToNetwork(ctx context.Context, cfg *config.Config, |
| 797 | 797 |
return err |
| 798 | 798 |
} |
| 799 | 799 |
|
| 800 |
- if err := ep.Join(sb, joinOptions...); err != nil {
|
|
| 800 |
+ if err := ep.Join(ctx, sb, joinOptions...); err != nil {
|
|
| 801 | 801 |
return err |
| 802 | 802 |
} |
| 803 | 803 |
|
| ... | ... |
@@ -8,11 +8,15 @@ import ( |
| 8 | 8 |
"github.com/docker/docker/libcontainerd/types" |
| 9 | 9 |
"github.com/docker/docker/oci" |
| 10 | 10 |
specs "github.com/opencontainers/runtime-spec/specs-go" |
| 11 |
+ "go.opentelemetry.io/otel" |
|
| 11 | 12 |
) |
| 12 | 13 |
|
| 13 | 14 |
// initializeCreatedTask performs any initialization that needs to be done to |
| 14 | 15 |
// prepare a freshly-created task to be started. |
| 15 | 16 |
func (daemon *Daemon) initializeCreatedTask(ctx context.Context, tsk types.Task, container *container.Container, spec *specs.Spec) error {
|
| 17 |
+ ctx, span := otel.Tracer("").Start(ctx, "daemon.initializeCreatedTask")
|
|
| 18 |
+ defer span.End() |
|
| 19 |
+ |
|
| 16 | 20 |
if !container.Config.NetworkDisabled {
|
| 17 | 21 |
nspath, ok := oci.NamespacePath(spec, specs.NetworkNamespace) |
| 18 | 22 |
if ok && nspath == "" { // the runtime has been instructed to create a new network namespace for tsk.
|
| ... | ... |
@@ -20,7 +24,7 @@ func (daemon *Daemon) initializeCreatedTask(ctx context.Context, tsk types.Task, |
| 20 | 20 |
if err != nil {
|
| 21 | 21 |
return errdefs.System(err) |
| 22 | 22 |
} |
| 23 |
- return sb.FinishConfig() |
|
| 23 |
+ return sb.FinishConfig(ctx) |
|
| 24 | 24 |
} |
| 25 | 25 |
} |
| 26 | 26 |
return nil |
| ... | ... |
@@ -55,7 +55,7 @@ func (d *manager) EndpointOperInfo(nid, eid string) (map[string]interface{}, err
|
| 55 | 55 |
return nil, types.NotImplementedErrorf("not implemented")
|
| 56 | 56 |
} |
| 57 | 57 |
|
| 58 |
-func (d *manager) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 58 |
+func (d *manager) Join(_ context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 59 | 59 |
return types.NotImplementedErrorf("not implemented")
|
| 60 | 60 |
} |
| 61 | 61 |
|
| ... | ... |
@@ -85,7 +85,7 @@ func (sb *Sandbox) setupDefaultGW() error {
|
| 85 | 85 |
} |
| 86 | 86 |
}() |
| 87 | 87 |
|
| 88 |
- if err = newEp.sbJoin(sb); err != nil {
|
|
| 88 |
+ if err = newEp.sbJoin(context.TODO(), sb); err != nil {
|
|
| 89 | 89 |
return fmt.Errorf("container %s: endpoint join on GW Network failed: %v", sb.containerID, err)
|
| 90 | 90 |
} |
| 91 | 91 |
|
| ... | ... |
@@ -49,7 +49,7 @@ type Driver interface {
|
| 49 | 49 |
EndpointOperInfo(nid, eid string) (map[string]interface{}, error)
|
| 50 | 50 |
|
| 51 | 51 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| 52 |
- Join(nid, eid string, sboxKey string, jinfo JoinInfo, options map[string]interface{}) error
|
|
| 52 |
+ Join(ctx context.Context, nid, eid string, sboxKey string, jinfo JoinInfo, options map[string]interface{}) error
|
|
| 53 | 53 |
|
| 54 | 54 |
// Leave method is invoked when a Sandbox detaches from an endpoint. |
| 55 | 55 |
Leave(nid, eid string) error |
| ... | ... |
@@ -1319,7 +1319,13 @@ func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, erro
|
| 1319 | 1319 |
} |
| 1320 | 1320 |
|
| 1321 | 1321 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| 1322 |
-func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 1322 |
+func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 1323 |
+ ctx, span := otel.Tracer("").Start(ctx, "libnetwork.drivers.bridge.Join", trace.WithAttributes(
|
|
| 1324 |
+ attribute.String("nid", nid),
|
|
| 1325 |
+ attribute.String("eid", eid),
|
|
| 1326 |
+ attribute.String("sboxKey", sboxKey)))
|
|
| 1327 |
+ defer span.End() |
|
| 1328 |
+ |
|
| 1323 | 1329 |
network, err := d.getNetwork(nid) |
| 1324 | 1330 |
if err != nil {
|
| 1325 | 1331 |
return err |
| ... | ... |
@@ -706,7 +706,7 @@ func testQueryEndpointInfo(t *testing.T, ulPxyEnabled bool) {
|
| 706 | 706 |
t.Fatalf("Failed to create an endpoint : %s", err.Error())
|
| 707 | 707 |
} |
| 708 | 708 |
|
| 709 |
- err = d.Join("net1", "ep1", "sbox", te, sbOptions)
|
|
| 709 |
+ err = d.Join(context.Background(), "net1", "ep1", "sbox", te, sbOptions) |
|
| 710 | 710 |
if err != nil {
|
| 711 | 711 |
t.Fatalf("Failed to join the endpoint: %v", err)
|
| 712 | 712 |
} |
| ... | ... |
@@ -809,7 +809,7 @@ func TestLinkContainers(t *testing.T) {
|
| 809 | 809 |
sbOptions := make(map[string]interface{})
|
| 810 | 810 |
sbOptions[netlabel.ExposedPorts] = exposedPorts |
| 811 | 811 |
|
| 812 |
- err = d.Join("net1", "ep1", "sbox", te1, sbOptions)
|
|
| 812 |
+ err = d.Join(context.Background(), "net1", "ep1", "sbox", te1, sbOptions) |
|
| 813 | 813 |
if err != nil {
|
| 814 | 814 |
t.Fatalf("Failed to join the endpoint: %v", err)
|
| 815 | 815 |
} |
| ... | ... |
@@ -840,7 +840,7 @@ func TestLinkContainers(t *testing.T) {
|
| 840 | 840 |
"ChildEndpoints": []string{"ep1"},
|
| 841 | 841 |
} |
| 842 | 842 |
|
| 843 |
- err = d.Join("net1", "ep2", "", te2, sbOptions)
|
|
| 843 |
+ err = d.Join(context.Background(), "net1", "ep2", "", te2, sbOptions) |
|
| 844 | 844 |
if err != nil {
|
| 845 | 845 |
t.Fatal("Failed to link ep1 and ep2")
|
| 846 | 846 |
} |
| ... | ... |
@@ -898,7 +898,7 @@ func TestLinkContainers(t *testing.T) {
|
| 898 | 898 |
"ChildEndpoints": []string{"ep1", "ep4"},
|
| 899 | 899 |
} |
| 900 | 900 |
|
| 901 |
- err = d.Join("net1", "ep2", "", te2, sbOptions)
|
|
| 901 |
+ err = d.Join(context.Background(), "net1", "ep2", "", te2, sbOptions) |
|
| 902 | 902 |
if err != nil {
|
| 903 | 903 |
t.Fatal(err) |
| 904 | 904 |
} |
| ... | ... |
@@ -1113,7 +1113,7 @@ func TestSetDefaultGw(t *testing.T) {
|
| 1113 | 1113 |
t.Fatalf("Failed to create endpoint: %v", err)
|
| 1114 | 1114 |
} |
| 1115 | 1115 |
|
| 1116 |
- err = d.Join("dummy", "ep", "sbox", te, nil)
|
|
| 1116 |
+ err = d.Join(context.Background(), "dummy", "ep", "sbox", te, nil) |
|
| 1117 | 1117 |
if err != nil {
|
| 1118 | 1118 |
t.Fatalf("Failed to join endpoint: %v", err)
|
| 1119 | 1119 |
} |
| ... | ... |
@@ -55,7 +55,7 @@ func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, erro
|
| 55 | 55 |
return nil, types.NotImplementedErrorf("not implemented")
|
| 56 | 56 |
} |
| 57 | 57 |
|
| 58 |
-func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 58 |
+func (d *driver) Join(_ context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 59 | 59 |
return types.NotImplementedErrorf("not implemented")
|
| 60 | 60 |
} |
| 61 | 61 |
|
| ... | ... |
@@ -49,7 +49,7 @@ func TestLinkCreate(t *testing.T) {
|
| 49 | 49 |
t.Fatalf("Failed to create a link: %s", err.Error())
|
| 50 | 50 |
} |
| 51 | 51 |
|
| 52 |
- err = d.Join("dummy", "ep", "sbox", te, nil)
|
|
| 52 |
+ err = d.Join(context.Background(), "dummy", "ep", "sbox", te, nil) |
|
| 53 | 53 |
if err != nil {
|
| 54 | 54 |
t.Fatalf("Failed to create a link: %s", err.Error())
|
| 55 | 55 |
} |
| ... | ... |
@@ -58,7 +58,7 @@ func TestPortMappingConfig(t *testing.T) {
|
| 58 | 58 |
t.Fatalf("Failed to create the endpoint: %s", err.Error())
|
| 59 | 59 |
} |
| 60 | 60 |
|
| 61 |
- if err = d.Join("dummy", "ep1", "sbox", te, sbOptions); err != nil {
|
|
| 61 |
+ if err = d.Join(context.Background(), "dummy", "ep1", "sbox", te, sbOptions); err != nil {
|
|
| 62 | 62 |
t.Fatalf("Failed to join the endpoint: %v", err)
|
| 63 | 63 |
} |
| 64 | 64 |
|
| ... | ... |
@@ -143,7 +143,7 @@ func TestPortMappingV6Config(t *testing.T) {
|
| 143 | 143 |
t.Fatalf("Failed to create the endpoint: %s", err.Error())
|
| 144 | 144 |
} |
| 145 | 145 |
|
| 146 |
- if err = d.Join("dummy", "ep1", "sbox", te, sbOptions); err != nil {
|
|
| 146 |
+ if err = d.Join(context.Background(), "dummy", "ep1", "sbox", te, sbOptions); err != nil {
|
|
| 147 | 147 |
t.Fatalf("Failed to join the endpoint: %v", err)
|
| 148 | 148 |
} |
| 149 | 149 |
|
| ... | ... |
@@ -68,7 +68,7 @@ func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, erro
|
| 68 | 68 |
} |
| 69 | 69 |
|
| 70 | 70 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| 71 |
-func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 71 |
+func (d *driver) Join(_ context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 72 | 72 |
return nil |
| 73 | 73 |
} |
| 74 | 74 |
|
| ... | ... |
@@ -12,6 +12,9 @@ import ( |
| 12 | 12 |
"github.com/docker/docker/libnetwork/netutils" |
| 13 | 13 |
"github.com/docker/docker/libnetwork/ns" |
| 14 | 14 |
"github.com/docker/docker/libnetwork/types" |
| 15 |
+ "go.opentelemetry.io/otel" |
|
| 16 |
+ "go.opentelemetry.io/otel/attribute" |
|
| 17 |
+ "go.opentelemetry.io/otel/trace" |
|
| 15 | 18 |
) |
| 16 | 19 |
|
| 17 | 20 |
type staticRoute struct {
|
| ... | ... |
@@ -26,7 +29,13 @@ const ( |
| 26 | 26 |
) |
| 27 | 27 |
|
| 28 | 28 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| 29 |
-func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 29 |
+func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 30 |
+ ctx, span := otel.Tracer("").Start(ctx, "libnetwork.drivers.ipvlan.Join", trace.WithAttributes(
|
|
| 31 |
+ attribute.String("nid", nid),
|
|
| 32 |
+ attribute.String("eid", eid),
|
|
| 33 |
+ attribute.String("sboxKey", sboxKey)))
|
|
| 34 |
+ defer span.End() |
|
| 35 |
+ |
|
| 30 | 36 |
n, err := d.getNetwork(nid) |
| 31 | 37 |
if err != nil {
|
| 32 | 38 |
return err |
| ... | ... |
@@ -63,7 +72,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, |
| 63 | 63 |
if err := jinfo.AddStaticRoute(defaultRoute.Destination, defaultRoute.RouteType, defaultRoute.NextHop); err != nil {
|
| 64 | 64 |
return fmt.Errorf("failed to set an ipvlan l3/l3s mode ipv4 default gateway: %v", err)
|
| 65 | 65 |
} |
| 66 |
- log.G(context.TODO()).Debugf("Ipvlan Endpoint Joined with IPv4_Addr: %s, Ipvlan_Mode: %s, Parent: %s",
|
|
| 66 |
+ log.G(ctx).Debugf("Ipvlan Endpoint Joined with IPv4_Addr: %s, Ipvlan_Mode: %s, Parent: %s",
|
|
| 67 | 67 |
ep.addr.IP.String(), n.config.IpvlanMode, n.config.Parent) |
| 68 | 68 |
// If the endpoint has a v6 address, set a v6 default route |
| 69 | 69 |
if ep.addrv6 != nil {
|
| ... | ... |
@@ -74,7 +83,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, |
| 74 | 74 |
if err = jinfo.AddStaticRoute(default6Route.Destination, default6Route.RouteType, default6Route.NextHop); err != nil {
|
| 75 | 75 |
return fmt.Errorf("failed to set an ipvlan l3/l3s mode ipv6 default gateway: %v", err)
|
| 76 | 76 |
} |
| 77 |
- log.G(context.TODO()).Debugf("Ipvlan Endpoint Joined with IPv6_Addr: %s, Ipvlan_Mode: %s, Parent: %s",
|
|
| 77 |
+ log.G(ctx).Debugf("Ipvlan Endpoint Joined with IPv6_Addr: %s, Ipvlan_Mode: %s, Parent: %s",
|
|
| 78 | 78 |
ep.addrv6.IP.String(), n.config.IpvlanMode, n.config.Parent) |
| 79 | 79 |
} |
| 80 | 80 |
case modeL2: |
| ... | ... |
@@ -92,7 +101,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, |
| 92 | 92 |
if err != nil {
|
| 93 | 93 |
return err |
| 94 | 94 |
} |
| 95 |
- log.G(context.TODO()).Debugf("Ipvlan Endpoint Joined with IPv4_Addr: %s, Gateway: %s, Ipvlan_Mode: %s, Parent: %s",
|
|
| 95 |
+ log.G(ctx).Debugf("Ipvlan Endpoint Joined with IPv4_Addr: %s, Gateway: %s, Ipvlan_Mode: %s, Parent: %s",
|
|
| 96 | 96 |
ep.addr.IP.String(), v4gw.String(), n.config.IpvlanMode, n.config.Parent) |
| 97 | 97 |
} |
| 98 | 98 |
// parse and correlate the endpoint v6 address with the available v6 subnets |
| ... | ... |
@@ -109,17 +118,17 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, |
| 109 | 109 |
if err != nil {
|
| 110 | 110 |
return err |
| 111 | 111 |
} |
| 112 |
- log.G(context.TODO()).Debugf("Ipvlan Endpoint Joined with IPv6_Addr: %s, Gateway: %s, Ipvlan_Mode: %s, Parent: %s",
|
|
| 112 |
+ log.G(ctx).Debugf("Ipvlan Endpoint Joined with IPv6_Addr: %s, Gateway: %s, Ipvlan_Mode: %s, Parent: %s",
|
|
| 113 | 113 |
ep.addrv6.IP.String(), v6gw.String(), n.config.IpvlanMode, n.config.Parent) |
| 114 | 114 |
} |
| 115 | 115 |
} |
| 116 | 116 |
} else {
|
| 117 | 117 |
if len(n.config.Ipv4Subnets) > 0 {
|
| 118 |
- log.G(context.TODO()).Debugf("Ipvlan Endpoint Joined with IPv4_Addr: %s, IpVlan_Mode: %s, Parent: %s",
|
|
| 118 |
+ log.G(ctx).Debugf("Ipvlan Endpoint Joined with IPv4_Addr: %s, IpVlan_Mode: %s, Parent: %s",
|
|
| 119 | 119 |
ep.addr.IP.String(), n.config.IpvlanMode, n.config.Parent) |
| 120 | 120 |
} |
| 121 | 121 |
if len(n.config.Ipv6Subnets) > 0 {
|
| 122 |
- log.G(context.TODO()).Debugf("Ipvlan Endpoint Joined with IPv6_Addr: %s IpVlan_Mode: %s, Parent: %s",
|
|
| 122 |
+ log.G(ctx).Debugf("Ipvlan Endpoint Joined with IPv6_Addr: %s IpVlan_Mode: %s, Parent: %s",
|
|
| 123 | 123 |
ep.addrv6.IP.String(), n.config.IpvlanMode, n.config.Parent) |
| 124 | 124 |
} |
| 125 | 125 |
// If n.config.Internal was set locally by the driver because there's no parent |
| ... | ... |
@@ -55,7 +55,7 @@ func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, erro
|
| 55 | 55 |
return nil, types.NotImplementedErrorf("not implemented")
|
| 56 | 56 |
} |
| 57 | 57 |
|
| 58 |
-func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 58 |
+func (d *driver) Join(_ context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 59 | 59 |
return types.NotImplementedErrorf("not implemented")
|
| 60 | 60 |
} |
| 61 | 61 |
|
| ... | ... |
@@ -11,10 +11,19 @@ import ( |
| 11 | 11 |
"github.com/docker/docker/libnetwork/driverapi" |
| 12 | 12 |
"github.com/docker/docker/libnetwork/netutils" |
| 13 | 13 |
"github.com/docker/docker/libnetwork/ns" |
| 14 |
+ "go.opentelemetry.io/otel" |
|
| 15 |
+ "go.opentelemetry.io/otel/attribute" |
|
| 16 |
+ "go.opentelemetry.io/otel/trace" |
|
| 14 | 17 |
) |
| 15 | 18 |
|
| 16 | 19 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| 17 |
-func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 20 |
+func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 21 |
+ ctx, span := otel.Tracer("").Start(ctx, "libnetwork.drivers.macvlan.Join", trace.WithAttributes(
|
|
| 22 |
+ attribute.String("nid", nid),
|
|
| 23 |
+ attribute.String("eid", eid),
|
|
| 24 |
+ attribute.String("sboxKey", sboxKey)))
|
|
| 25 |
+ defer span.End() |
|
| 26 |
+ |
|
| 18 | 27 |
n, err := d.getNetwork(nid) |
| 19 | 28 |
if err != nil {
|
| 20 | 29 |
return err |
| ... | ... |
@@ -54,7 +63,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, |
| 54 | 54 |
if err != nil {
|
| 55 | 55 |
return err |
| 56 | 56 |
} |
| 57 |
- log.G(context.TODO()).Debugf("Macvlan Endpoint Joined with IPv4_Addr: %s, Gateway: %s, MacVlan_Mode: %s, Parent: %s",
|
|
| 57 |
+ log.G(ctx).Debugf("Macvlan Endpoint Joined with IPv4_Addr: %s, Gateway: %s, MacVlan_Mode: %s, Parent: %s",
|
|
| 58 | 58 |
ep.addr.IP.String(), v4gw.String(), n.config.MacvlanMode, n.config.Parent) |
| 59 | 59 |
} |
| 60 | 60 |
// parse and match the endpoint address with the available v6 subnets |
| ... | ... |
@@ -71,16 +80,16 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, |
| 71 | 71 |
if err != nil {
|
| 72 | 72 |
return err |
| 73 | 73 |
} |
| 74 |
- log.G(context.TODO()).Debugf("Macvlan Endpoint Joined with IPv6_Addr: %s Gateway: %s MacVlan_Mode: %s, Parent: %s",
|
|
| 74 |
+ log.G(ctx).Debugf("Macvlan Endpoint Joined with IPv6_Addr: %s Gateway: %s MacVlan_Mode: %s, Parent: %s",
|
|
| 75 | 75 |
ep.addrv6.IP.String(), v6gw.String(), n.config.MacvlanMode, n.config.Parent) |
| 76 | 76 |
} |
| 77 | 77 |
} else {
|
| 78 | 78 |
if len(n.config.Ipv4Subnets) > 0 {
|
| 79 |
- log.G(context.TODO()).Debugf("Macvlan Endpoint Joined with IPv4_Addr: %s, MacVlan_Mode: %s, Parent: %s",
|
|
| 79 |
+ log.G(ctx).Debugf("Macvlan Endpoint Joined with IPv4_Addr: %s, MacVlan_Mode: %s, Parent: %s",
|
|
| 80 | 80 |
ep.addr.IP.String(), n.config.MacvlanMode, n.config.Parent) |
| 81 | 81 |
} |
| 82 | 82 |
if len(n.config.Ipv6Subnets) > 0 {
|
| 83 |
- log.G(context.TODO()).Debugf("Macvlan Endpoint Joined with IPv6_Addr: %s MacVlan_Mode: %s, Parent: %s",
|
|
| 83 |
+ log.G(ctx).Debugf("Macvlan Endpoint Joined with IPv6_Addr: %s MacVlan_Mode: %s, Parent: %s",
|
|
| 84 | 84 |
ep.addrv6.IP.String(), n.config.MacvlanMode, n.config.Parent) |
| 85 | 85 |
} |
| 86 | 86 |
// If n.config.Internal was set locally by the driver because there's no parent |
| ... | ... |
@@ -55,7 +55,7 @@ func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, erro
|
| 55 | 55 |
return nil, types.NotImplementedErrorf("not implemented")
|
| 56 | 56 |
} |
| 57 | 57 |
|
| 58 |
-func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 58 |
+func (d *driver) Join(_ context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 59 | 59 |
return types.NotImplementedErrorf("not implemented")
|
| 60 | 60 |
} |
| 61 | 61 |
|
| ... | ... |
@@ -68,7 +68,7 @@ func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, erro
|
| 68 | 68 |
} |
| 69 | 69 |
|
| 70 | 70 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| 71 |
-func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 71 |
+func (d *driver) Join(_ context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 72 | 72 |
return nil |
| 73 | 73 |
} |
| 74 | 74 |
|
| ... | ... |
@@ -14,10 +14,19 @@ import ( |
| 14 | 14 |
"github.com/docker/docker/libnetwork/osl" |
| 15 | 15 |
"github.com/docker/docker/libnetwork/types" |
| 16 | 16 |
"github.com/gogo/protobuf/proto" |
| 17 |
+ "go.opentelemetry.io/otel" |
|
| 18 |
+ "go.opentelemetry.io/otel/attribute" |
|
| 19 |
+ "go.opentelemetry.io/otel/trace" |
|
| 17 | 20 |
) |
| 18 | 21 |
|
| 19 | 22 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| 20 |
-func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 23 |
+func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 24 |
+ ctx, span := otel.Tracer("").Start(ctx, "libnetwork.drivers.overlay.Join", trace.WithAttributes(
|
|
| 25 |
+ attribute.String("nid", nid),
|
|
| 26 |
+ attribute.String("eid", eid),
|
|
| 27 |
+ attribute.String("sboxKey", sboxKey)))
|
|
| 28 |
+ defer span.End() |
|
| 29 |
+ |
|
| 21 | 30 |
if err := validateID(nid, eid); err != nil {
|
| 22 | 31 |
return err |
| 23 | 32 |
} |
| ... | ... |
@@ -74,7 +83,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, |
| 74 | 74 |
return err |
| 75 | 75 |
} |
| 76 | 76 |
|
| 77 |
- if err = sbox.AddInterface(overlayIfName, "veth", osl.WithMaster(s.brName)); err != nil {
|
|
| 77 |
+ if err = sbox.AddInterface(ctx, overlayIfName, "veth", osl.WithMaster(s.brName)); err != nil {
|
|
| 78 | 78 |
return fmt.Errorf("could not add veth pair inside the network sandbox: %v", err)
|
| 79 | 79 |
} |
| 80 | 80 |
|
| ... | ... |
@@ -96,7 +105,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, |
| 96 | 96 |
continue |
| 97 | 97 |
} |
| 98 | 98 |
if err = jinfo.AddStaticRoute(sub.subnetIP, types.NEXTHOP, s.gwIP.IP); err != nil {
|
| 99 |
- log.G(context.TODO()).Errorf("Adding subnet %s static route in network %q failed\n", s.subnetIP, n.id)
|
|
| 99 |
+ log.G(ctx).Errorf("Adding subnet %s static route in network %q failed\n", s.subnetIP, n.id)
|
|
| 100 | 100 |
} |
| 101 | 101 |
} |
| 102 | 102 |
|
| ... | ... |
@@ -110,7 +119,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, |
| 110 | 110 |
d.peerAdd(nid, eid, ep.addr.IP, ep.addr.Mask, ep.mac, d.advertiseAddress, true) |
| 111 | 111 |
|
| 112 | 112 |
if err = d.checkEncryption(nid, nil, true, true); err != nil {
|
| 113 |
- log.G(context.TODO()).Warn(err) |
|
| 113 |
+ log.G(ctx).Warn(err) |
|
| 114 | 114 |
} |
| 115 | 115 |
|
| 116 | 116 |
buf, err := proto.Marshal(&PeerRecord{
|
| ... | ... |
@@ -123,7 +132,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, |
| 123 | 123 |
} |
| 124 | 124 |
|
| 125 | 125 |
if err := jinfo.AddTableEntry(ovPeerTable, eid, buf); err != nil {
|
| 126 |
- log.G(context.TODO()).Errorf("overlay: Failed adding table entry to joininfo: %v", err)
|
|
| 126 |
+ log.G(ctx).Errorf("overlay: Failed adding table entry to joininfo: %v", err)
|
|
| 127 | 127 |
} |
| 128 | 128 |
|
| 129 | 129 |
return nil |
| ... | ... |
@@ -426,7 +426,7 @@ func (n *network) setupSubnetSandbox(s *subnet, brName, vxlanName string) error |
| 426 | 426 |
// create a bridge and vxlan device for this subnet and move it to the sandbox |
| 427 | 427 |
sbox := n.sbox |
| 428 | 428 |
|
| 429 |
- if err := sbox.AddInterface(brName, "br", osl.WithIPv4Address(s.gwIP), osl.WithIsBridge(true)); err != nil {
|
|
| 429 |
+ if err := sbox.AddInterface(context.TODO(), brName, "br", osl.WithIPv4Address(s.gwIP), osl.WithIsBridge(true)); err != nil {
|
|
| 430 | 430 |
return fmt.Errorf("bridge creation in sandbox failed for subnet %q: %v", s.subnetIP.String(), err)
|
| 431 | 431 |
} |
| 432 | 432 |
|
| ... | ... |
@@ -438,7 +438,7 @@ func (n *network) setupSubnetSandbox(s *subnet, brName, vxlanName string) error |
| 438 | 438 |
return err |
| 439 | 439 |
} |
| 440 | 440 |
|
| 441 |
- if err := sbox.AddInterface(vxlanName, "vxlan", osl.WithMaster(brName)); err != nil {
|
|
| 441 |
+ if err := sbox.AddInterface(context.TODO(), vxlanName, "vxlan", osl.WithMaster(brName)); err != nil {
|
|
| 442 | 442 |
// If adding vxlan device to the overlay namespace fails, remove the bridge interface we |
| 443 | 443 |
// already added to the namespace. This allows the caller to try the setup again. |
| 444 | 444 |
for _, iface := range sbox.Interfaces() {
|
| ... | ... |
@@ -190,7 +190,7 @@ func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, erro
|
| 190 | 190 |
} |
| 191 | 191 |
|
| 192 | 192 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| 193 |
-func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 193 |
+func (d *driver) Join(_ context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 194 | 194 |
return types.NotImplementedErrorf("not implemented")
|
| 195 | 195 |
} |
| 196 | 196 |
|
| ... | ... |
@@ -258,7 +258,7 @@ func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, erro
|
| 258 | 258 |
} |
| 259 | 259 |
|
| 260 | 260 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| 261 |
-func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) (retErr error) {
|
|
| 261 |
+func (d *driver) Join(_ context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) (retErr error) {
|
|
| 262 | 262 |
join := &api.JoinRequest{
|
| 263 | 263 |
NetworkID: nid, |
| 264 | 264 |
EndpointID: eid, |
| ... | ... |
@@ -452,7 +452,7 @@ func TestRemoteDriver(t *testing.T) {
|
| 452 | 452 |
} |
| 453 | 453 |
|
| 454 | 454 |
joinOpts := map[string]interface{}{"foo": "fooValue"}
|
| 455 |
- err = d.Join(netID, endID, "sandbox-key", ep, joinOpts) |
|
| 455 |
+ err = d.Join(context.Background(), netID, endID, "sandbox-key", ep, joinOpts) |
|
| 456 | 456 |
if err != nil {
|
| 457 | 457 |
t.Fatal(err) |
| 458 | 458 |
} |
| ... | ... |
@@ -9,10 +9,19 @@ import ( |
| 9 | 9 |
"github.com/docker/docker/libnetwork/driverapi" |
| 10 | 10 |
"github.com/docker/docker/libnetwork/types" |
| 11 | 11 |
"github.com/gogo/protobuf/proto" |
| 12 |
+ "go.opentelemetry.io/otel" |
|
| 13 |
+ "go.opentelemetry.io/otel/attribute" |
|
| 14 |
+ "go.opentelemetry.io/otel/trace" |
|
| 12 | 15 |
) |
| 13 | 16 |
|
| 14 | 17 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| 15 |
-func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 18 |
+func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 19 |
+ ctx, span := otel.Tracer("").Start(ctx, "libnetwork.drivers.windows_overlay.Join", trace.WithAttributes(
|
|
| 20 |
+ attribute.String("nid", nid),
|
|
| 21 |
+ attribute.String("eid", eid),
|
|
| 22 |
+ attribute.String("sboxKey", sboxKey)))
|
|
| 23 |
+ defer span.End() |
|
| 24 |
+ |
|
| 16 | 25 |
if err := validateID(nid, eid); err != nil {
|
| 17 | 26 |
return err |
| 18 | 27 |
} |
| ... | ... |
@@ -37,7 +46,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, |
| 37 | 37 |
} |
| 38 | 38 |
|
| 39 | 39 |
if err := jinfo.AddTableEntry(ovPeerTable, eid, buf); err != nil {
|
| 40 |
- log.G(context.TODO()).Errorf("overlay: Failed adding table entry to joininfo: %v", err)
|
|
| 40 |
+ log.G(ctx).Errorf("overlay: Failed adding table entry to joininfo: %v", err)
|
|
| 41 | 41 |
} |
| 42 | 42 |
|
| 43 | 43 |
if ep.disablegateway {
|
| ... | ... |
@@ -835,7 +835,13 @@ func (d *driver) EndpointOperInfo(nid, eid string) (map[string]interface{}, erro
|
| 835 | 835 |
} |
| 836 | 836 |
|
| 837 | 837 |
// Join method is invoked when a Sandbox is attached to an endpoint. |
| 838 |
-func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 838 |
+func (d *driver) Join(ctx context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 839 |
+ ctx, span := otel.Tracer("").Start(ctx, fmt.Sprintf("libnetwork.drivers.windows_%s.Join", d.name), trace.WithAttributes(
|
|
| 840 |
+ attribute.String("nid", nid),
|
|
| 841 |
+ attribute.String("eid", eid),
|
|
| 842 |
+ attribute.String("sboxKey", sboxKey)))
|
|
| 843 |
+ defer span.End() |
|
| 844 |
+ |
|
| 839 | 845 |
network, err := d.getNetwork(nid) |
| 840 | 846 |
if err != nil {
|
| 841 | 847 |
return err |
| ... | ... |
@@ -20,6 +20,7 @@ import ( |
| 20 | 20 |
"github.com/docker/docker/libnetwork/options" |
| 21 | 21 |
"github.com/docker/docker/libnetwork/scope" |
| 22 | 22 |
"github.com/docker/docker/libnetwork/types" |
| 23 |
+ "go.opentelemetry.io/otel" |
|
| 23 | 24 |
) |
| 24 | 25 |
|
| 25 | 26 |
// ByNetworkType sorts a [Endpoint] slice based on the network-type |
| ... | ... |
@@ -469,7 +470,7 @@ func (ep *Endpoint) getNetworkFromStore() (*Network, error) {
|
| 469 | 469 |
|
| 470 | 470 |
// Join joins the sandbox to the endpoint and populates into the sandbox |
| 471 | 471 |
// the network resources allocated for the endpoint. |
| 472 |
-func (ep *Endpoint) Join(sb *Sandbox, options ...EndpointOption) error {
|
|
| 472 |
+func (ep *Endpoint) Join(ctx context.Context, sb *Sandbox, options ...EndpointOption) error {
|
|
| 473 | 473 |
if sb == nil || sb.ID() == "" || sb.Key() == "" {
|
| 474 | 474 |
return types.InvalidParameterErrorf("invalid Sandbox passed to endpoint join: %v", sb)
|
| 475 | 475 |
} |
| ... | ... |
@@ -477,10 +478,13 @@ func (ep *Endpoint) Join(sb *Sandbox, options ...EndpointOption) error {
|
| 477 | 477 |
sb.joinLeaveStart() |
| 478 | 478 |
defer sb.joinLeaveEnd() |
| 479 | 479 |
|
| 480 |
- return ep.sbJoin(sb, options...) |
|
| 480 |
+ return ep.sbJoin(ctx, sb, options...) |
|
| 481 | 481 |
} |
| 482 | 482 |
|
| 483 |
-func (ep *Endpoint) sbJoin(sb *Sandbox, options ...EndpointOption) (err error) {
|
|
| 483 |
+func (ep *Endpoint) sbJoin(ctx context.Context, sb *Sandbox, options ...EndpointOption) (err error) {
|
|
| 484 |
+ ctx, span := otel.Tracer("").Start(ctx, "libnetwork.sbJoin")
|
|
| 485 |
+ defer span.End() |
|
| 486 |
+ |
|
| 484 | 487 |
n, err := ep.getNetworkFromStore() |
| 485 | 488 |
if err != nil {
|
| 486 | 489 |
return fmt.Errorf("failed to get network from store during join: %v", err)
|
| ... | ... |
@@ -518,25 +522,25 @@ func (ep *Endpoint) sbJoin(sb *Sandbox, options ...EndpointOption) (err error) {
|
| 518 | 518 |
return fmt.Errorf("failed to get driver during join: %v", err)
|
| 519 | 519 |
} |
| 520 | 520 |
|
| 521 |
- err = d.Join(nid, epid, sb.Key(), ep, sb.Labels()) |
|
| 521 |
+ err = d.Join(ctx, nid, epid, sb.Key(), ep, sb.Labels()) |
|
| 522 | 522 |
if err != nil {
|
| 523 | 523 |
return err |
| 524 | 524 |
} |
| 525 | 525 |
defer func() {
|
| 526 | 526 |
if err != nil {
|
| 527 | 527 |
if e := d.Leave(nid, epid); e != nil {
|
| 528 |
- log.G(context.TODO()).Warnf("driver leave failed while rolling back join: %v", e)
|
|
| 528 |
+ log.G(ctx).Warnf("driver leave failed while rolling back join: %v", e)
|
|
| 529 | 529 |
} |
| 530 | 530 |
} |
| 531 | 531 |
}() |
| 532 | 532 |
|
| 533 | 533 |
if !n.getController().isAgent() {
|
| 534 | 534 |
if !n.getController().isSwarmNode() || n.Scope() != scope.Swarm || !n.driverIsMultihost() {
|
| 535 |
- n.updateSvcRecord(ep, true) |
|
| 535 |
+ n.updateSvcRecord(context.WithoutCancel(ctx), ep, true) |
|
| 536 | 536 |
} |
| 537 | 537 |
} |
| 538 | 538 |
|
| 539 |
- if err := sb.updateHostsFile(ep.getEtcHostsAddrs()); err != nil {
|
|
| 539 |
+ if err := sb.updateHostsFile(ctx, ep.getEtcHostsAddrs()); err != nil {
|
|
| 540 | 540 |
return err |
| 541 | 541 |
} |
| 542 | 542 |
|
| ... | ... |
@@ -550,11 +554,11 @@ func (ep *Endpoint) sbJoin(sb *Sandbox, options ...EndpointOption) (err error) {
|
| 550 | 550 |
} |
| 551 | 551 |
}() |
| 552 | 552 |
|
| 553 |
- if err = sb.populateNetworkResources(ep); err != nil {
|
|
| 553 |
+ if err = sb.populateNetworkResources(ctx, ep); err != nil {
|
|
| 554 | 554 |
return err |
| 555 | 555 |
} |
| 556 | 556 |
|
| 557 |
- if err = addEpToResolver(context.TODO(), n.Name(), ep.Name(), &sb.config, ep.iface, n.Resolvers()); err != nil {
|
|
| 557 |
+ if err = addEpToResolver(ctx, n.Name(), ep.Name(), &sb.config, ep.iface, n.Resolvers()); err != nil {
|
|
| 558 | 558 |
return errdefs.System(err) |
| 559 | 559 |
} |
| 560 | 560 |
|
| ... | ... |
@@ -569,7 +573,7 @@ func (ep *Endpoint) sbJoin(sb *Sandbox, options ...EndpointOption) (err error) {
|
| 569 | 569 |
defer func() {
|
| 570 | 570 |
if err != nil {
|
| 571 | 571 |
if e := ep.deleteDriverInfoFromCluster(); e != nil {
|
| 572 |
- log.G(context.TODO()).Errorf("Could not delete endpoint state for endpoint %s from cluster on join failure: %v", ep.Name(), e)
|
|
| 572 |
+ log.G(ctx).Errorf("Could not delete endpoint state for endpoint %s from cluster on join failure: %v", ep.Name(), e)
|
|
| 573 | 573 |
} |
| 574 | 574 |
} |
| 575 | 575 |
}() |
| ... | ... |
@@ -593,7 +597,7 @@ func (ep *Endpoint) sbJoin(sb *Sandbox, options ...EndpointOption) (err error) {
|
| 593 | 593 |
moveExtConn := currentExtEp != extEp |
| 594 | 594 |
if moveExtConn {
|
| 595 | 595 |
if extEp != nil {
|
| 596 |
- log.G(context.TODO()).Debugf("Revoking external connectivity on endpoint %s (%s)", extEp.Name(), extEp.ID())
|
|
| 596 |
+ log.G(ctx).Debugf("Revoking external connectivity on endpoint %s (%s)", extEp.Name(), extEp.ID())
|
|
| 597 | 597 |
extN, err := extEp.getNetworkFromStore() |
| 598 | 598 |
if err != nil {
|
| 599 | 599 |
return fmt.Errorf("failed to get network from store for revoking external connectivity during join: %v", err)
|
| ... | ... |
@@ -610,14 +614,14 @@ func (ep *Endpoint) sbJoin(sb *Sandbox, options ...EndpointOption) (err error) {
|
| 610 | 610 |
defer func() {
|
| 611 | 611 |
if err != nil {
|
| 612 | 612 |
if e := extD.ProgramExternalConnectivity(extEp.network.ID(), extEp.ID(), sb.Labels()); e != nil {
|
| 613 |
- log.G(context.TODO()).Warnf("Failed to roll-back external connectivity on endpoint %s (%s): %v",
|
|
| 613 |
+ log.G(ctx).Warnf("Failed to roll-back external connectivity on endpoint %s (%s): %v",
|
|
| 614 | 614 |
extEp.Name(), extEp.ID(), e) |
| 615 | 615 |
} |
| 616 | 616 |
} |
| 617 | 617 |
}() |
| 618 | 618 |
} |
| 619 | 619 |
if !n.internal {
|
| 620 |
- log.G(context.TODO()).Debugf("Programming external connectivity on endpoint %s (%s)", ep.Name(), ep.ID())
|
|
| 620 |
+ log.G(ctx).Debugf("Programming external connectivity on endpoint %s (%s)", ep.Name(), ep.ID())
|
|
| 621 | 621 |
if err = d.ProgramExternalConnectivity(n.ID(), ep.ID(), sb.Labels()); err != nil {
|
| 622 | 622 |
return types.InternalErrorf( |
| 623 | 623 |
"driver failed programming external connectivity on endpoint %s (%s): %v", |
| ... | ... |
@@ -628,7 +632,7 @@ func (ep *Endpoint) sbJoin(sb *Sandbox, options ...EndpointOption) (err error) {
|
| 628 | 628 |
|
| 629 | 629 |
if !sb.needDefaultGW() {
|
| 630 | 630 |
if e := sb.clearDefaultGW(); e != nil {
|
| 631 |
- log.G(context.TODO()).Warnf("Failure while disconnecting sandbox %s (%s) from gateway network: %v",
|
|
| 631 |
+ log.G(ctx).Warnf("Failure while disconnecting sandbox %s (%s) from gateway network: %v",
|
|
| 632 | 632 |
sb.ID(), sb.ContainerID(), e) |
| 633 | 633 |
} |
| 634 | 634 |
} |
| ... | ... |
@@ -671,10 +675,10 @@ func (ep *Endpoint) UpdateDNSNames(dnsNames []string) error {
|
| 671 | 671 |
return types.InternalErrorf("could not add service state for endpoint %s to cluster on UpdateDNSNames: %v", ep.Name(), err)
|
| 672 | 672 |
} |
| 673 | 673 |
} else {
|
| 674 |
- nw.updateSvcRecord(ep, false) |
|
| 674 |
+ nw.updateSvcRecord(context.WithoutCancel(context.TODO()), ep, false) |
|
| 675 | 675 |
|
| 676 | 676 |
ep.dnsNames = dnsNames |
| 677 |
- nw.updateSvcRecord(ep, true) |
|
| 677 |
+ nw.updateSvcRecord(context.WithoutCancel(context.TODO()), ep, true) |
|
| 678 | 678 |
} |
| 679 | 679 |
|
| 680 | 680 |
// Update the store with the updated name |
| ... | ... |
@@ -863,7 +867,7 @@ func (ep *Endpoint) Delete(force bool) error {
|
| 863 | 863 |
}() |
| 864 | 864 |
|
| 865 | 865 |
if !n.getController().isSwarmNode() || n.Scope() != scope.Swarm || !n.driverIsMultihost() {
|
| 866 |
- n.updateSvcRecord(ep, false) |
|
| 866 |
+ n.updateSvcRecord(context.WithoutCancel(context.TODO()), ep, false) |
|
| 867 | 867 |
} |
| 868 | 868 |
|
| 869 | 869 |
if err = ep.deleteEndpoint(force); err != nil && !force {
|
| ... | ... |
@@ -387,7 +387,7 @@ func TestSRVServiceQuery(t *testing.T) {
|
| 387 | 387 |
} |
| 388 | 388 |
}() |
| 389 | 389 |
|
| 390 |
- err = ep.Join(sb) |
|
| 390 |
+ err = ep.Join(context.Background(), sb) |
|
| 391 | 391 |
if err != nil {
|
| 392 | 392 |
t.Fatal(err) |
| 393 | 393 |
} |
| ... | ... |
@@ -486,7 +486,7 @@ func TestServiceVIPReuse(t *testing.T) {
|
| 486 | 486 |
} |
| 487 | 487 |
}() |
| 488 | 488 |
|
| 489 |
- err = ep.Join(sb) |
|
| 489 |
+ err = ep.Join(context.Background(), sb) |
|
| 490 | 490 |
if err != nil {
|
| 491 | 491 |
t.Fatal(err) |
| 492 | 492 |
} |
| ... | ... |
@@ -673,7 +673,7 @@ func (b *badDriver) EndpointOperInfo(nid, eid string) (map[string]interface{}, e
|
| 673 | 673 |
return nil, nil |
| 674 | 674 |
} |
| 675 | 675 |
|
| 676 |
-func (b *badDriver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 676 |
+func (b *badDriver) Join(_ context.Context, nid, eid string, sboxKey string, jinfo driverapi.JoinInfo, options map[string]interface{}) error {
|
|
| 677 | 677 |
return fmt.Errorf("I will not allow any join")
|
| 678 | 678 |
} |
| 679 | 679 |
|
| ... | ... |
@@ -115,7 +115,7 @@ func TestNull(t *testing.T) {
|
| 115 | 115 |
t.Fatal(err) |
| 116 | 116 |
} |
| 117 | 117 |
|
| 118 |
- err = ep.Join(cnt) |
|
| 118 |
+ err = ep.Join(context.Background(), cnt) |
|
| 119 | 119 |
if err != nil {
|
| 120 | 120 |
t.Fatal(err) |
| 121 | 121 |
} |
| ... | ... |
@@ -888,7 +888,7 @@ func TestEndpointDeleteWithActiveContainer(t *testing.T) {
|
| 888 | 888 |
} |
| 889 | 889 |
}() |
| 890 | 890 |
|
| 891 |
- err = ep.Join(cnt) |
|
| 891 |
+ err = ep.Join(context.Background(), cnt) |
|
| 892 | 892 |
if err != nil {
|
| 893 | 893 |
t.Fatal(err) |
| 894 | 894 |
} |
| ... | ... |
@@ -961,7 +961,7 @@ func TestEndpointMultipleJoins(t *testing.T) {
|
| 961 | 961 |
} |
| 962 | 962 |
}() |
| 963 | 963 |
|
| 964 |
- err = ep.Join(sbx1) |
|
| 964 |
+ err = ep.Join(context.Background(), sbx1) |
|
| 965 | 965 |
if err != nil {
|
| 966 | 966 |
t.Fatal(err) |
| 967 | 967 |
} |
| ... | ... |
@@ -972,7 +972,7 @@ func TestEndpointMultipleJoins(t *testing.T) {
|
| 972 | 972 |
} |
| 973 | 973 |
}() |
| 974 | 974 |
|
| 975 |
- err = ep.Join(sbx2) |
|
| 975 |
+ err = ep.Join(context.Background(), sbx2) |
|
| 976 | 976 |
if err == nil {
|
| 977 | 977 |
t.Fatal("Expected to fail multiple joins for the same endpoint")
|
| 978 | 978 |
} |
| ... | ... |
@@ -1030,12 +1030,12 @@ func TestLeaveAll(t *testing.T) {
|
| 1030 | 1030 |
t.Fatal(err) |
| 1031 | 1031 |
} |
| 1032 | 1032 |
|
| 1033 |
- err = ep1.Join(cnt) |
|
| 1033 |
+ err = ep1.Join(context.Background(), cnt) |
|
| 1034 | 1034 |
if err != nil {
|
| 1035 | 1035 |
t.Fatalf("Failed to join ep1: %v", err)
|
| 1036 | 1036 |
} |
| 1037 | 1037 |
|
| 1038 |
- err = ep2.Join(cnt) |
|
| 1038 |
+ err = ep2.Join(context.Background(), cnt) |
|
| 1039 | 1039 |
if err != nil {
|
| 1040 | 1040 |
t.Fatalf("Failed to join ep2: %v", err)
|
| 1041 | 1041 |
} |
| ... | ... |
@@ -1166,12 +1166,12 @@ func TestEndpointUpdateParent(t *testing.T) {
|
| 1166 | 1166 |
} |
| 1167 | 1167 |
}() |
| 1168 | 1168 |
|
| 1169 |
- err = ep1.Join(sbx1) |
|
| 1169 |
+ err = ep1.Join(context.Background(), sbx1) |
|
| 1170 | 1170 |
if err != nil {
|
| 1171 | 1171 |
t.Fatal(err) |
| 1172 | 1172 |
} |
| 1173 | 1173 |
|
| 1174 |
- err = ep2.Join(sbx2) |
|
| 1174 |
+ err = ep2.Join(context.Background(), sbx2) |
|
| 1175 | 1175 |
if err != nil {
|
| 1176 | 1176 |
t.Fatal(err) |
| 1177 | 1177 |
} |
| ... | ... |
@@ -1344,7 +1344,7 @@ func TestHost(t *testing.T) {
|
| 1344 | 1344 |
t.Fatal(err) |
| 1345 | 1345 |
} |
| 1346 | 1346 |
|
| 1347 |
- if err := ep1.Join(sbx1); err != nil {
|
|
| 1347 |
+ if err := ep1.Join(context.Background(), sbx1); err != nil {
|
|
| 1348 | 1348 |
t.Fatal(err) |
| 1349 | 1349 |
} |
| 1350 | 1350 |
|
| ... | ... |
@@ -1353,7 +1353,7 @@ func TestHost(t *testing.T) {
|
| 1353 | 1353 |
t.Fatal(err) |
| 1354 | 1354 |
} |
| 1355 | 1355 |
|
| 1356 |
- if err := ep2.Join(sbx2); err != nil {
|
|
| 1356 |
+ if err := ep2.Join(context.Background(), sbx2); err != nil {
|
|
| 1357 | 1357 |
t.Fatal(err) |
| 1358 | 1358 |
} |
| 1359 | 1359 |
|
| ... | ... |
@@ -1393,7 +1393,7 @@ func TestHost(t *testing.T) {
|
| 1393 | 1393 |
t.Fatal(err) |
| 1394 | 1394 |
} |
| 1395 | 1395 |
|
| 1396 |
- if err := ep3.Join(sbx2); err != nil {
|
|
| 1396 |
+ if err := ep3.Join(context.Background(), sbx2); err != nil {
|
|
| 1397 | 1397 |
t.Fatal(err) |
| 1398 | 1398 |
} |
| 1399 | 1399 |
|
| ... | ... |
@@ -1541,7 +1541,7 @@ func TestEndpointJoin(t *testing.T) {
|
| 1541 | 1541 |
} |
| 1542 | 1542 |
|
| 1543 | 1543 |
// test invalid joins |
| 1544 |
- err = ep1.Join(nil) |
|
| 1544 |
+ err = ep1.Join(context.Background(), nil) |
|
| 1545 | 1545 |
if err == nil {
|
| 1546 | 1546 |
t.Fatalf("Expected to fail join with nil Sandbox")
|
| 1547 | 1547 |
} |
| ... | ... |
@@ -1550,7 +1550,7 @@ func TestEndpointJoin(t *testing.T) {
|
| 1550 | 1550 |
} |
| 1551 | 1551 |
|
| 1552 | 1552 |
fsbx := &libnetwork.Sandbox{}
|
| 1553 |
- if err = ep1.Join(fsbx); err == nil {
|
|
| 1553 |
+ if err = ep1.Join(context.Background(), fsbx); err == nil {
|
|
| 1554 | 1554 |
t.Fatalf("Expected to fail join with invalid Sandbox")
|
| 1555 | 1555 |
} |
| 1556 | 1556 |
if _, ok := err.(types.InvalidParameterError); !ok {
|
| ... | ... |
@@ -1571,7 +1571,7 @@ func TestEndpointJoin(t *testing.T) {
|
| 1571 | 1571 |
} |
| 1572 | 1572 |
}() |
| 1573 | 1573 |
|
| 1574 |
- err = ep1.Join(sb) |
|
| 1574 |
+ err = ep1.Join(context.Background(), sb) |
|
| 1575 | 1575 |
if err != nil {
|
| 1576 | 1576 |
t.Fatal(err) |
| 1577 | 1577 |
} |
| ... | ... |
@@ -1635,7 +1635,7 @@ func TestEndpointJoin(t *testing.T) {
|
| 1635 | 1635 |
} |
| 1636 | 1636 |
}() |
| 1637 | 1637 |
|
| 1638 |
- err = ep2.Join(sb) |
|
| 1638 |
+ err = ep2.Join(context.Background(), sb) |
|
| 1639 | 1639 |
if err != nil {
|
| 1640 | 1640 |
t.Fatal(err) |
| 1641 | 1641 |
} |
| ... | ... |
@@ -1724,7 +1724,7 @@ func externalKeyTest(t *testing.T, reexec bool) {
|
| 1724 | 1724 |
}() |
| 1725 | 1725 |
|
| 1726 | 1726 |
// Join endpoint to sandbox before SetKey |
| 1727 |
- err = ep.Join(cnt) |
|
| 1727 |
+ err = ep.Join(context.Background(), cnt) |
|
| 1728 | 1728 |
if err != nil {
|
| 1729 | 1729 |
t.Fatal(err) |
| 1730 | 1730 |
} |
| ... | ... |
@@ -1775,7 +1775,7 @@ func externalKeyTest(t *testing.T, reexec bool) {
|
| 1775 | 1775 |
} |
| 1776 | 1776 |
|
| 1777 | 1777 |
// Join endpoint to sandbox after SetKey |
| 1778 |
- err = ep2.Join(sbox) |
|
| 1778 |
+ err = ep2.Join(context.Background(), sbox) |
|
| 1779 | 1779 |
if err != nil {
|
| 1780 | 1780 |
t.Fatal(err) |
| 1781 | 1781 |
} |
| ... | ... |
@@ -1887,7 +1887,7 @@ func TestResolvConf(t *testing.T) {
|
| 1887 | 1887 |
assert.Check(t, err) |
| 1888 | 1888 |
}() |
| 1889 | 1889 |
|
| 1890 |
- err = ep.Join(sb) |
|
| 1890 |
+ err = ep.Join(context.Background(), sb) |
|
| 1891 | 1891 |
assert.NilError(t, err) |
| 1892 | 1892 |
defer func() {
|
| 1893 | 1893 |
err := ep.Leave(sb) |
| ... | ... |
@@ -1942,7 +1942,7 @@ func (pt parallelTester) Do(t *testing.T, thrNumber int) error {
|
| 1942 | 1942 |
} |
| 1943 | 1943 |
|
| 1944 | 1944 |
for i := 0; i < pt.iterCnt; i++ {
|
| 1945 |
- if err := ep.Join(sb); err != nil {
|
|
| 1945 |
+ if err := ep.Join(context.Background(), sb); err != nil {
|
|
| 1946 | 1946 |
if _, ok := err.(types.ForbiddenError); !ok {
|
| 1947 | 1947 |
return errors.Wrapf(err, "thread %d", thrNumber) |
| 1948 | 1948 |
} |
| ... | ... |
@@ -2069,7 +2069,7 @@ func TestBridge(t *testing.T) {
|
| 2069 | 2069 |
} |
| 2070 | 2070 |
}() |
| 2071 | 2071 |
|
| 2072 |
- err = ep.Join(sb) |
|
| 2072 |
+ err = ep.Join(context.Background(), sb) |
|
| 2073 | 2073 |
if err != nil {
|
| 2074 | 2074 |
t.Fatal(err) |
| 2075 | 2075 |
} |
| ... | ... |
@@ -1227,10 +1227,10 @@ func (n *Network) createEndpoint(ctx context.Context, name string, options ...En |
| 1227 | 1227 |
} |
| 1228 | 1228 |
|
| 1229 | 1229 |
if !n.getController().isSwarmNode() || n.Scope() != scope.Swarm || !n.driverIsMultihost() {
|
| 1230 |
- n.updateSvcRecord(ep, true) |
|
| 1230 |
+ n.updateSvcRecord(context.WithoutCancel(ctx), ep, true) |
|
| 1231 | 1231 |
defer func() {
|
| 1232 | 1232 |
if err != nil {
|
| 1233 |
- n.updateSvcRecord(ep, false) |
|
| 1233 |
+ n.updateSvcRecord(context.WithoutCancel(ctx), ep, false) |
|
| 1234 | 1234 |
} |
| 1235 | 1235 |
}() |
| 1236 | 1236 |
} |
| ... | ... |
@@ -1302,7 +1302,12 @@ func (n *Network) EndpointByID(id string) (*Endpoint, error) {
|
| 1302 | 1302 |
} |
| 1303 | 1303 |
|
| 1304 | 1304 |
// updateSvcRecord adds or deletes local DNS records for a given Endpoint. |
| 1305 |
-func (n *Network) updateSvcRecord(ep *Endpoint, isAdd bool) {
|
|
| 1305 |
+func (n *Network) updateSvcRecord(ctx context.Context, ep *Endpoint, isAdd bool) {
|
|
| 1306 |
+ ctx, span := otel.Tracer("").Start(ctx, "libnetwork.updateSvcRecord", trace.WithAttributes(
|
|
| 1307 |
+ attribute.String("ep.name", ep.name),
|
|
| 1308 |
+ attribute.Bool("isAdd", isAdd)))
|
|
| 1309 |
+ defer span.End() |
|
| 1310 |
+ |
|
| 1306 | 1311 |
iface := ep.Iface() |
| 1307 | 1312 |
if iface == nil || iface.Address() == nil {
|
| 1308 | 1313 |
return |
| ... | ... |
@@ -2140,7 +2145,7 @@ func (n *Network) createLoadBalancerSandbox() (retErr error) {
|
| 2140 | 2140 |
} |
| 2141 | 2141 |
}() |
| 2142 | 2142 |
|
| 2143 |
- if err := ep.Join(sb, nil); err != nil {
|
|
| 2143 |
+ if err := ep.Join(context.TODO(), sb, nil); err != nil {
|
|
| 2144 | 2144 |
return err |
| 2145 | 2145 |
} |
| 2146 | 2146 |
|
| ... | ... |
@@ -16,6 +16,9 @@ import ( |
| 16 | 16 |
"github.com/pkg/errors" |
| 17 | 17 |
"github.com/vishvananda/netlink" |
| 18 | 18 |
"github.com/vishvananda/netns" |
| 19 |
+ "go.opentelemetry.io/otel" |
|
| 20 |
+ "go.opentelemetry.io/otel/attribute" |
|
| 21 |
+ "go.opentelemetry.io/otel/trace" |
|
| 19 | 22 |
) |
| 20 | 23 |
|
| 21 | 24 |
// newInterface creates a new interface in the given namespace using the |
| ... | ... |
@@ -159,12 +162,33 @@ func (n *Namespace) findDst(srcName string, isBridge bool) string {
|
| 159 | 159 |
return "" |
| 160 | 160 |
} |
| 161 | 161 |
|
| 162 |
+func moveLink(ctx context.Context, nlhHost *netlink.Handle, iface netlink.Link, i *Interface, path string) error {
|
|
| 163 |
+ ctx, span := otel.Tracer("").Start(ctx, "libnetwork.osl.moveLink", trace.WithAttributes(
|
|
| 164 |
+ attribute.String("ifaceName", i.DstName())))
|
|
| 165 |
+ defer span.End() |
|
| 166 |
+ |
|
| 167 |
+ newNs, err := netns.GetFromPath(path) |
|
| 168 |
+ if err != nil {
|
|
| 169 |
+ return fmt.Errorf("failed get network namespace %q: %v", path, err)
|
|
| 170 |
+ } |
|
| 171 |
+ defer newNs.Close() |
|
| 172 |
+ if err := nlhHost.LinkSetNsFd(iface, int(newNs)); err != nil {
|
|
| 173 |
+ return fmt.Errorf("failed to set namespace on link %q: %v", i.srcName, err)
|
|
| 174 |
+ } |
|
| 175 |
+ return nil |
|
| 176 |
+} |
|
| 177 |
+ |
|
| 162 | 178 |
// AddInterface adds an existing Interface to the sandbox. The operation will rename |
| 163 | 179 |
// from the Interface SrcName to DstName as it moves, and reconfigure the |
| 164 | 180 |
// interface according to the specified settings. The caller is expected |
| 165 | 181 |
// to only provide a prefix for DstName. The AddInterface api will auto-generate |
| 166 | 182 |
// an appropriate suffix for the DstName to disambiguate. |
| 167 |
-func (n *Namespace) AddInterface(srcName, dstPrefix string, options ...IfaceOption) error {
|
|
| 183 |
+func (n *Namespace) AddInterface(ctx context.Context, srcName, dstPrefix string, options ...IfaceOption) error {
|
|
| 184 |
+ ctx, span := otel.Tracer("").Start(ctx, "libnetwork.osl.AddInterface", trace.WithAttributes(
|
|
| 185 |
+ attribute.String("srcName", srcName),
|
|
| 186 |
+ attribute.String("dstPrefix", dstPrefix)))
|
|
| 187 |
+ defer span.End() |
|
| 188 |
+ |
|
| 168 | 189 |
i, err := newInterface(n, srcName, dstPrefix, options...) |
| 169 | 190 |
if err != nil {
|
| 170 | 191 |
return err |
| ... | ... |
@@ -205,13 +229,8 @@ func (n *Namespace) AddInterface(srcName, dstPrefix string, options ...IfaceOpti |
| 205 | 205 |
// namespace only if the namespace is not a default |
| 206 | 206 |
// type |
| 207 | 207 |
if !isDefault {
|
| 208 |
- newNs, err := netns.GetFromPath(path) |
|
| 209 |
- if err != nil {
|
|
| 210 |
- return fmt.Errorf("failed get network namespace %q: %v", path, err)
|
|
| 211 |
- } |
|
| 212 |
- defer newNs.Close() |
|
| 213 |
- if err := nlhHost.LinkSetNsFd(iface, int(newNs)); err != nil {
|
|
| 214 |
- return fmt.Errorf("failed to set namespace on link %q: %v", i.srcName, err)
|
|
| 208 |
+ if err := moveLink(ctx, nlhHost, iface, i, path); err != nil {
|
|
| 209 |
+ return err |
|
| 215 | 210 |
} |
| 216 | 211 |
} |
| 217 | 212 |
} |
| ... | ... |
@@ -228,16 +247,16 @@ func (n *Namespace) AddInterface(srcName, dstPrefix string, options ...IfaceOpti |
| 228 | 228 |
} |
| 229 | 229 |
|
| 230 | 230 |
// Configure the interface now this is moved in the proper namespace. |
| 231 |
- if err := n.configureInterface(nlh, iface, i); err != nil {
|
|
| 231 |
+ if err := n.configureInterface(ctx, nlh, iface, i); err != nil {
|
|
| 232 | 232 |
// If configuring the device fails move it back to the host namespace |
| 233 | 233 |
// and change the name back to the source name. This allows the caller |
| 234 | 234 |
// to properly cleanup the interface. Its important especially for |
| 235 | 235 |
// interfaces with global attributes, ex: vni id for vxlan interfaces. |
| 236 | 236 |
if nerr := nlh.LinkSetName(iface, i.SrcName()); nerr != nil {
|
| 237 |
- log.G(context.TODO()).Errorf("renaming interface (%s->%s) failed, %v after config error %v", i.DstName(), i.SrcName(), nerr, err)
|
|
| 237 |
+ log.G(ctx).Errorf("renaming interface (%s->%s) failed, %v after config error %v", i.DstName(), i.SrcName(), nerr, err)
|
|
| 238 | 238 |
} |
| 239 | 239 |
if nerr := nlh.LinkSetNsFd(iface, ns.ParseHandlerInt()); nerr != nil {
|
| 240 |
- log.G(context.TODO()).Errorf("moving interface %s to host ns failed, %v, after config error %v", i.SrcName(), nerr, err)
|
|
| 240 |
+ log.G(ctx).Errorf("moving interface %s to host ns failed, %v, after config error %v", i.SrcName(), nerr, err)
|
|
| 241 | 241 |
} |
| 242 | 242 |
return err |
| 243 | 243 |
} |
| ... | ... |
@@ -245,7 +264,11 @@ func (n *Namespace) AddInterface(srcName, dstPrefix string, options ...IfaceOpti |
| 245 | 245 |
// Up the interface. |
| 246 | 246 |
cnt := 0 |
| 247 | 247 |
for err = nlh.LinkSetUp(iface); err != nil && cnt < 3; cnt++ {
|
| 248 |
- log.G(context.TODO()).Debugf("retrying link setup because of: %v", err)
|
|
| 248 |
+ ctx, span2 := otel.Tracer("").Start(ctx, "libnetwork.osl.retryingLinkUp", trace.WithAttributes(
|
|
| 249 |
+ attribute.String("srcName", srcName),
|
|
| 250 |
+ attribute.String("dstPrefix", dstPrefix)))
|
|
| 251 |
+ defer span2.End() |
|
| 252 |
+ log.G(ctx).Debugf("retrying link setup because of: %v", err)
|
|
| 249 | 253 |
time.Sleep(10 * time.Millisecond) |
| 250 | 254 |
err = nlh.LinkSetUp(iface) |
| 251 | 255 |
} |
| ... | ... |
@@ -317,7 +340,11 @@ func (n *Namespace) RemoveInterface(i *Interface) error {
|
| 317 | 317 |
return nil |
| 318 | 318 |
} |
| 319 | 319 |
|
| 320 |
-func (n *Namespace) configureInterface(nlh *netlink.Handle, iface netlink.Link, i *Interface) error {
|
|
| 320 |
+func (n *Namespace) configureInterface(ctx context.Context, nlh *netlink.Handle, iface netlink.Link, i *Interface) error {
|
|
| 321 |
+ ctx, span := otel.Tracer("").Start(ctx, "libnetwork.osl.configureInterface", trace.WithAttributes(
|
|
| 322 |
+ attribute.String("ifaceName", iface.Attrs().Name)))
|
|
| 323 |
+ defer span.End() |
|
| 324 |
+ |
|
| 321 | 325 |
ifaceName := iface.Attrs().Name |
| 322 | 326 |
ifaceConfigurators := []struct {
|
| 323 | 327 |
Fn func(*netlink.Handle, netlink.Link, *Interface) error |
| ... | ... |
@@ -1,6 +1,7 @@ |
| 1 | 1 |
package osl |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "context" |
|
| 4 | 5 |
"crypto/rand" |
| 5 | 6 |
"encoding/hex" |
| 6 | 7 |
"io" |
| ... | ... |
@@ -393,7 +394,7 @@ func TestSandboxCreate(t *testing.T) {
|
| 393 | 393 |
} |
| 394 | 394 |
|
| 395 | 395 |
for _, i := range tbox.Interfaces() {
|
| 396 |
- err = s.AddInterface(i.SrcName(), i.DstName(), |
|
| 396 |
+ err = s.AddInterface(context.Background(), i.SrcName(), i.DstName(), |
|
| 397 | 397 |
WithIsBridge(i.Bridge()), |
| 398 | 398 |
WithIPv4Address(i.Address()), |
| 399 | 399 |
WithIPv6Address(i.AddressIPv6())) |
| ... | ... |
@@ -492,7 +493,7 @@ func TestAddRemoveInterface(t *testing.T) {
|
| 492 | 492 |
} |
| 493 | 493 |
|
| 494 | 494 |
for _, i := range tbox.Interfaces() {
|
| 495 |
- err = s.AddInterface(i.SrcName(), i.DstName(), |
|
| 495 |
+ err = s.AddInterface(context.Background(), i.SrcName(), i.DstName(), |
|
| 496 | 496 |
WithIsBridge(i.Bridge()), |
| 497 | 497 |
WithIPv4Address(i.Address()), |
| 498 | 498 |
WithIPv6Address(i.AddressIPv6()), |
| ... | ... |
@@ -512,7 +513,7 @@ func TestAddRemoveInterface(t *testing.T) {
|
| 512 | 512 |
verifySandbox(t, s, []string{"1", "2"})
|
| 513 | 513 |
|
| 514 | 514 |
i := tbox.Interfaces()[0] |
| 515 |
- err = s.AddInterface(i.SrcName(), i.DstName(), |
|
| 515 |
+ err = s.AddInterface(context.Background(), i.SrcName(), i.DstName(), |
|
| 516 | 516 |
WithIsBridge(i.Bridge()), |
| 517 | 517 |
WithIPv4Address(i.Address()), |
| 518 | 518 |
WithIPv6Address(i.AddressIPv6()), |
| ... | ... |
@@ -51,7 +51,7 @@ func TestDNSIPQuery(t *testing.T) {
|
| 51 | 51 |
|
| 52 | 52 |
// we need the endpoint only to populate ep_list for the sandbox as part of resolve_name |
| 53 | 53 |
// it is not set as a target for name resolution and does not serve any other purpose |
| 54 |
- err = ep.Join(sb) |
|
| 54 |
+ err = ep.Join(context.Background(), sb) |
|
| 55 | 55 |
if err != nil {
|
| 56 | 56 |
t.Fatal(err) |
| 57 | 57 |
} |
| ... | ... |
@@ -266,7 +266,7 @@ 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(sb); err != nil {
|
|
| 269 |
+ if err := ep.Join(context.WithoutCancel(context.TODO()), sb); err != nil {
|
|
| 270 | 270 |
log.G(context.TODO()).Warnf("Failed attach sandbox %s to endpoint %s: %v\n", sb.ID(), ep.ID(), err)
|
| 271 | 271 |
} |
| 272 | 272 |
} |
| ... | ... |
@@ -17,6 +17,7 @@ import ( |
| 17 | 17 |
"github.com/docker/docker/libnetwork/internal/resolvconf" |
| 18 | 18 |
"github.com/docker/docker/libnetwork/types" |
| 19 | 19 |
"github.com/pkg/errors" |
| 20 |
+ "go.opentelemetry.io/otel" |
|
| 20 | 21 |
) |
| 21 | 22 |
|
| 22 | 23 |
const ( |
| ... | ... |
@@ -30,12 +31,12 @@ const ( |
| 30 | 30 |
// finishInitDNS is to be called after the container namespace has been created, |
| 31 | 31 |
// before it the user process is started. The container's support for IPv6 can be |
| 32 | 32 |
// determined at this point. |
| 33 |
-func (sb *Sandbox) finishInitDNS() error {
|
|
| 33 |
+func (sb *Sandbox) finishInitDNS(ctx context.Context) error {
|
|
| 34 | 34 |
if err := sb.buildHostsFile(); err != nil {
|
| 35 | 35 |
return errdefs.System(err) |
| 36 | 36 |
} |
| 37 | 37 |
for _, ep := range sb.Endpoints() {
|
| 38 |
- if err := sb.updateHostsFile(ep.getEtcHostsAddrs()); err != nil {
|
|
| 38 |
+ if err := sb.updateHostsFile(ctx, ep.getEtcHostsAddrs()); err != nil {
|
|
| 39 | 39 |
return errdefs.System(err) |
| 40 | 40 |
} |
| 41 | 41 |
} |
| ... | ... |
@@ -133,7 +134,10 @@ func (sb *Sandbox) buildHostsFile() error {
|
| 133 | 133 |
return sb.updateParentHosts() |
| 134 | 134 |
} |
| 135 | 135 |
|
| 136 |
-func (sb *Sandbox) updateHostsFile(ifaceIPs []string) error {
|
|
| 136 |
+func (sb *Sandbox) updateHostsFile(ctx context.Context, ifaceIPs []string) error {
|
|
| 137 |
+ ctx, span := otel.Tracer("").Start(ctx, "libnetwork.updateHostsFile")
|
|
| 138 |
+ defer span.End() |
|
| 139 |
+ |
|
| 137 | 140 |
if len(ifaceIPs) == 0 {
|
| 138 | 141 |
return nil |
| 139 | 142 |
} |
| ... | ... |
@@ -16,7 +16,7 @@ func (sb *Sandbox) restoreHostsPath() {}
|
| 16 | 16 |
|
| 17 | 17 |
func (sb *Sandbox) restoreResolvConfPath() {}
|
| 18 | 18 |
|
| 19 |
-func (sb *Sandbox) updateHostsFile(ifaceIP []string) error {
|
|
| 19 |
+func (sb *Sandbox) updateHostsFile(_ context.Context, ifaceIP []string) error {
|
|
| 20 | 20 |
return nil |
| 21 | 21 |
} |
| 22 | 22 |
|
| ... | ... |
@@ -10,6 +10,9 @@ import ( |
| 10 | 10 |
"github.com/docker/docker/libnetwork/netutils" |
| 11 | 11 |
"github.com/docker/docker/libnetwork/osl" |
| 12 | 12 |
"github.com/docker/docker/libnetwork/types" |
| 13 |
+ "go.opentelemetry.io/otel" |
|
| 14 |
+ "go.opentelemetry.io/otel/attribute" |
|
| 15 |
+ "go.opentelemetry.io/otel/trace" |
|
| 13 | 16 |
) |
| 14 | 17 |
|
| 15 | 18 |
// Linux-specific container configuration flags. |
| ... | ... |
@@ -165,12 +168,12 @@ func (sb *Sandbox) SetKey(basePath string) error {
|
| 165 | 165 |
// determined yet, as sysctls haven't been applied by the runtime. Calling |
| 166 | 166 |
// FinishInit after the container task has been created, when sysctls have been |
| 167 | 167 |
// applied will regenerate these files. |
| 168 |
- if err := sb.finishInitDNS(); err != nil {
|
|
| 168 |
+ if err := sb.finishInitDNS(context.TODO()); err != nil {
|
|
| 169 | 169 |
return err |
| 170 | 170 |
} |
| 171 | 171 |
|
| 172 | 172 |
for _, ep := range sb.Endpoints() {
|
| 173 |
- if err = sb.populateNetworkResources(ep); err != nil {
|
|
| 173 |
+ if err = sb.populateNetworkResources(context.TODO(), ep); err != nil {
|
|
| 174 | 174 |
return err |
| 175 | 175 |
} |
| 176 | 176 |
} |
| ... | ... |
@@ -181,7 +184,7 @@ func (sb *Sandbox) SetKey(basePath string) error {
|
| 181 | 181 |
// FinishConfig completes Sandbox configuration. If called after the container task has been |
| 182 | 182 |
// created, and sysctl settings applied, the configuration will be based on the container's |
| 183 | 183 |
// IPv6 support. |
| 184 |
-func (sb *Sandbox) FinishConfig() error {
|
|
| 184 |
+func (sb *Sandbox) FinishConfig(ctx context.Context) error {
|
|
| 185 | 185 |
if sb.config.useDefaultSandBox {
|
| 186 | 186 |
return nil |
| 187 | 187 |
} |
| ... | ... |
@@ -196,7 +199,7 @@ func (sb *Sandbox) FinishConfig() error {
|
| 196 | 196 |
// If sysctl changes have been made, IPv6 may have been enabled/disabled since last checked. |
| 197 | 197 |
osSbox.RefreshIPv6LoEnabled() |
| 198 | 198 |
|
| 199 |
- return sb.finishInitDNS() |
|
| 199 |
+ return sb.finishInitDNS(ctx) |
|
| 200 | 200 |
} |
| 201 | 201 |
|
| 202 | 202 |
// IPv6 support can always be determined for host networking. For other network |
| ... | ... |
@@ -283,7 +286,11 @@ func (sb *Sandbox) restoreOslSandbox() error {
|
| 283 | 283 |
return sb.osSbox.Restore(interfaces, routes, gwep.joinInfo.gw, gwep.joinInfo.gw6) |
| 284 | 284 |
} |
| 285 | 285 |
|
| 286 |
-func (sb *Sandbox) populateNetworkResources(ep *Endpoint) error {
|
|
| 286 |
+func (sb *Sandbox) populateNetworkResources(ctx context.Context, ep *Endpoint) error {
|
|
| 287 |
+ ctx, span := otel.Tracer("").Start(ctx, "libnetwork.Sandbox.populateNetworkResources", trace.WithAttributes(
|
|
| 288 |
+ attribute.String("endpoint.Name", ep.Name())))
|
|
| 289 |
+ defer span.End() |
|
| 290 |
+ |
|
| 287 | 291 |
sb.mu.Lock() |
| 288 | 292 |
if sb.osSbox == nil {
|
| 289 | 293 |
sb.mu.Unlock() |
| ... | ... |
@@ -319,7 +326,7 @@ func (sb *Sandbox) populateNetworkResources(ep *Endpoint) error {
|
| 319 | 319 |
ifaceOptions = append(ifaceOptions, osl.WithSysctls(sysctls)) |
| 320 | 320 |
} |
| 321 | 321 |
|
| 322 |
- if err := sb.osSbox.AddInterface(i.srcName, i.dstPrefix, ifaceOptions...); err != nil {
|
|
| 322 |
+ if err := sb.osSbox.AddInterface(ctx, i.srcName, i.dstPrefix, ifaceOptions...); err != nil {
|
|
| 323 | 323 |
return fmt.Errorf("failed to add interface %s to sandbox: %v", i.srcName, err)
|
| 324 | 324 |
} |
| 325 | 325 |
|
| ... | ... |
@@ -272,7 +272,7 @@ func (c *Controller) sandboxCleanup(activeSandboxes map[string]interface{}) erro
|
| 272 | 272 |
if !c.isAgent() {
|
| 273 | 273 |
n := ep.getNetwork() |
| 274 | 274 |
if !c.isSwarmNode() || n.Scope() != scope.Swarm || !n.driverIsMultihost() {
|
| 275 |
- n.updateSvcRecord(ep, true) |
|
| 275 |
+ n.updateSvcRecord(context.WithoutCancel(context.TODO()), ep, true) |
|
| 276 | 276 |
} |
| 277 | 277 |
} |
| 278 | 278 |
} |
| ... | ... |
@@ -143,15 +143,15 @@ func TestSandboxAddMultiPrio(t *testing.T) {
|
| 143 | 143 |
t.Fatal(err) |
| 144 | 144 |
} |
| 145 | 145 |
|
| 146 |
- if err := ep1.Join(sbx, JoinOptionPriority(1)); err != nil {
|
|
| 146 |
+ if err := ep1.Join(context.Background(), sbx, JoinOptionPriority(1)); err != nil {
|
|
| 147 | 147 |
t.Fatal(err) |
| 148 | 148 |
} |
| 149 | 149 |
|
| 150 |
- if err := ep2.Join(sbx, JoinOptionPriority(2)); err != nil {
|
|
| 150 |
+ if err := ep2.Join(context.Background(), sbx, JoinOptionPriority(2)); err != nil {
|
|
| 151 | 151 |
t.Fatal(err) |
| 152 | 152 |
} |
| 153 | 153 |
|
| 154 |
- if err := ep3.Join(sbx, JoinOptionPriority(3)); err != nil {
|
|
| 154 |
+ if err := ep3.Join(context.Background(), sbx, JoinOptionPriority(3)); err != nil {
|
|
| 155 | 155 |
t.Fatal(err) |
| 156 | 156 |
} |
| 157 | 157 |
|
| ... | ... |
@@ -178,7 +178,7 @@ func TestSandboxAddMultiPrio(t *testing.T) {
|
| 178 | 178 |
} |
| 179 | 179 |
|
| 180 | 180 |
// Re-add ep3 back |
| 181 |
- if err := ep3.Join(sbx, JoinOptionPriority(3)); err != nil {
|
|
| 181 |
+ if err := ep3.Join(context.Background(), sbx, JoinOptionPriority(3)); err != nil {
|
|
| 182 | 182 |
t.Fatal(err) |
| 183 | 183 |
} |
| 184 | 184 |
|
| ... | ... |
@@ -234,19 +234,19 @@ func TestSandboxAddSamePrio(t *testing.T) {
|
| 234 | 234 |
t.Fatal(err) |
| 235 | 235 |
} |
| 236 | 236 |
|
| 237 |
- if err := epNw1.Join(sbx); err != nil {
|
|
| 237 |
+ if err := epNw1.Join(context.Background(), sbx); err != nil {
|
|
| 238 | 238 |
t.Fatal(err) |
| 239 | 239 |
} |
| 240 | 240 |
|
| 241 |
- if err := epIPv6.Join(sbx); err != nil {
|
|
| 241 |
+ if err := epIPv6.Join(context.Background(), sbx); err != nil {
|
|
| 242 | 242 |
t.Fatal(err) |
| 243 | 243 |
} |
| 244 | 244 |
|
| 245 |
- if err := epInternal.Join(sbx); err != nil {
|
|
| 245 |
+ if err := epInternal.Join(context.Background(), sbx); err != nil {
|
|
| 246 | 246 |
t.Fatal(err) |
| 247 | 247 |
} |
| 248 | 248 |
|
| 249 |
- if err := epNw0.Join(sbx); err != nil {
|
|
| 249 |
+ if err := epNw0.Join(context.Background(), sbx); err != nil {
|
|
| 250 | 250 |
t.Fatal(err) |
| 251 | 251 |
} |
| 252 | 252 |
|
| ... | ... |
@@ -1,6 +1,10 @@ |
| 1 | 1 |
package libnetwork |
| 2 | 2 |
|
| 3 |
-import "github.com/docker/docker/libnetwork/osl" |
|
| 3 |
+import ( |
|
| 4 |
+ "context" |
|
| 5 |
+ |
|
| 6 |
+ "github.com/docker/docker/libnetwork/osl" |
|
| 7 |
+) |
|
| 4 | 8 |
|
| 5 | 9 |
// Windows-specific container configuration flags. |
| 6 | 10 |
type containerConfigOS struct {
|
| ... | ... |
@@ -29,7 +33,7 @@ func (sb *Sandbox) restoreOslSandbox() error {
|
| 29 | 29 |
return nil |
| 30 | 30 |
} |
| 31 | 31 |
|
| 32 |
-func (sb *Sandbox) populateNetworkResources(*Endpoint) error {
|
|
| 32 |
+func (sb *Sandbox) populateNetworkResources(context.Context, *Endpoint) error {
|
|
| 33 | 33 |
// not implemented on Windows (Sandbox.osSbox is always nil) |
| 34 | 34 |
return nil |
| 35 | 35 |
} |