nolint:revive
(link, cidr string, isNoSpace bool)
| 847 | |
| 848 | //nolint:revive |
| 849 | func dockerdArgs(link, cidr string, isNoSpace bool) ([]string, error) { |
| 850 | // We need to adjust the MTU for the host otherwise packets will fail delivery. |
| 851 | // 1500 is the standard, but certain deployments (like GKE) use custom MTU values. |
| 852 | // See: https://www.atlantis-press.com/journals/ijndc/125936177/view#sec-s3.1 |
| 853 | |
| 854 | mtu, err := xunix.NetlinkMTU(link) |
| 855 | if err != nil { |
| 856 | return nil, xerrors.Errorf("custom mtu: %w", err) |
| 857 | } |
| 858 | |
| 859 | // We set the Docker Bridge IP explicitly here for a number of reasons: |
| 860 | // 1) It sometimes picks the 172.17.x.x address which conflicts with that of the Docker daemon in the inner container. |
| 861 | // 2) It defaults to a /16 network which is way more than we need for envbox. |
| 862 | // 3) The default may conflict with existing internal network resources, and an operator may wish to override it. |
| 863 | dockerBip, prefixLen := dockerutil.BridgeIPFromCIDR(cidr) |
| 864 | |
| 865 | args := []string{ |
| 866 | "--debug", |
| 867 | "--log-level=debug", |
| 868 | fmt.Sprintf("--mtu=%d", mtu), |
| 869 | "--userns-remap=coder", |
| 870 | "--storage-driver=overlay2", |
| 871 | fmt.Sprintf("--bip=%s/%d", dockerBip, prefixLen), |
| 872 | } |
| 873 | |
| 874 | if isNoSpace { |
| 875 | args = append(args, |
| 876 | fmt.Sprintf("--data-root=%s", noSpaceDataDir), |
| 877 | fmt.Sprintf("--storage-driver=%s", noSpaceDockerDriver), |
| 878 | ) |
| 879 | } |
| 880 | |
| 881 | return args, nil |
| 882 | } |
| 883 | |
| 884 | // TODO This is bad code. |
| 885 | func filterElements(ss []string, filters ...string) []string { |
no test coverage detected