From 7974f5b7092bf140ebd6bebec5df90f1dc71e59b Mon Sep 17 00:00:00 2001 From: Manuel Alejandro de Brito Fontes Date: Tue, 21 Feb 2023 08:10:52 -0300 Subject: [PATCH] Override network mtu value --- pkg/compose/create.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/compose/create.go b/pkg/compose/create.go index f82f8f23ffd..1f6d02ef709 100644 --- a/pkg/compose/create.go +++ b/pkg/compose/create.go @@ -40,6 +40,7 @@ import ( "github.com/docker/go-units" "github.com/pkg/errors" "github.com/sirupsen/logrus" + "github.com/vishvananda/netlink" "github.com/compose-spec/compose-go/types" @@ -1167,6 +1168,19 @@ func (s *composeService) resolveOrCreateNetwork(ctx context.Context, n *types.Ne } createOpts.IPAM.Config = append(createOpts.IPAM.Config, config) } + + // override MTU value and set custom MTU one. + // This is required for gitpod.io due to the veth change + // https://github.com/gitpod-io/gitpod/pull/8955 + if createOpts.Options == nil { + createOpts.Options = make(map[string]string) + } + + netIface, err := netlink.LinkByName("ceth0") + if err == nil { + createOpts.Options["com.docker.network.driver.mtu"] = fmt.Sprintf("%v", netIface.Attrs().MTU) + } + networkEventName := fmt.Sprintf("Network %s", n.Name) w := progress.ContextWriter(ctx) w.Event(progress.CreatingEvent(networkEventName))