From 748239777471ee5f3bdbb7cb77f426e01eb751ce Mon Sep 17 00:00:00 2001 From: Ashish Jain Date: Mon, 9 Aug 2021 10:54:41 +0530 Subject: [PATCH] EDGECLOUD-5230: Envoy crashing for UDP packet size larger than 1500 (#1443) * add debug cmd + use envoy version 1.18.x + update envoy yaml to use v3 api --- .../crmutil/controller-data.go | 4 + cloud-resource-manager/crmutil/exec.go | 72 +++++++++ cloud-resource-manager/proxy/envoy.go | 29 +++- cloud-resource-manager/proxy/nginx.go | 1 + cloudcommon/names.go | 2 +- d-match-engine/dme-proto/appcommon.pb.go | 144 +++++++++++------- docker_envoy/Dockerfile | 2 +- edgeproto/appinst.pb.go | 8 + edgeproto/objs.go | 1 + gencmd/alldata.cmd.go | 2 + gencmd/app-client.cmd.go | 12 ++ gencmd/appcommon.cmd.go | 2 + gencmd/appinst.cmd.go | 1 + util/ports.go | 25 ++- util/ports_test.go | 16 ++ 15 files changed, 254 insertions(+), 67 deletions(-) diff --git a/cloud-resource-manager/crmutil/controller-data.go b/cloud-resource-manager/crmutil/controller-data.go index f77682225..68a918d8b 100644 --- a/cloud-resource-manager/crmutil/controller-data.go +++ b/cloud-resource-manager/crmutil/controller-data.go @@ -112,6 +112,10 @@ func NewControllerData(pf platform.Platform, key *edgeproto.CloudletKey, nodeMgr cd.updateVMWorkers.Init("vmpool-updatevm", cd.UpdateVMPool) cd.updateTrustPolicyKeyworkers.Init("update-TrustPolicy", cd.UpdateTrustPolicy) cd.settings = *edgeproto.GetDefaultSettings() + + // debug functions + nodeMgr.Debug.AddDebugFunc("envoyversioncmd", cd.GetClusterEnvoyVersion) + return cd } diff --git a/cloud-resource-manager/crmutil/exec.go b/cloud-resource-manager/crmutil/exec.go index aa6397151..1f4a399f8 100644 --- a/cloud-resource-manager/crmutil/exec.go +++ b/cloud-resource-manager/crmutil/exec.go @@ -44,6 +44,78 @@ func (s *ExecReqHandler) RecvExecRequest(ctx context.Context, msg *edgeproto.Exe }() } +type EnvoyContainerVersion struct { + ContainerName string + EnvoyVersion string + Error string +} + +type RootLBEnvoyVersion struct { + NodeType string + NodeName string + EnvoyContainers []EnvoyContainerVersion +} + +func (cd *ControllerData) GetClusterEnvoyVersion(ctx context.Context, req *edgeproto.DebugRequest) string { + clusterInsts := []edgeproto.ClusterInst{} + cd.ClusterInstCache.Mux.Lock() + for _, v := range cd.ClusterInstCache.Objs { + clusterInsts = append(clusterInsts, *v.Obj) + } + cd.ClusterInstCache.Mux.Unlock() + nodes, err := cd.platform.ListCloudletMgmtNodes(ctx, clusterInsts, nil) + if err != nil { + return fmt.Sprintf("unable to get list of cluster nodes, %v", err) + } + if len(nodes) == 0 { + return fmt.Sprintf("no nodes found") + } + nodeVersions := []RootLBEnvoyVersion{} + for _, node := range nodes { + if !strings.Contains(node.Type, "rootlb") { + continue + } + client, err := cd.platform.GetNodePlatformClient(ctx, &node) + if err != nil { + return fmt.Sprintf("failed to get ssh client for node %s, %v", node.Name, err) + } + out, err := client.Output(`docker ps --format "{{.Names}}" --filter name="^envoy"`) + if err != nil { + log.SpanLog(ctx, log.DebugLevelInfra, "failed to find envoy containers on rootlb", "rootlb", node, "err", err, "out", out) + return fmt.Sprintf("failed to find envoy containers on rootlb %s, %v", node.Name, err) + } + nodeVersion := RootLBEnvoyVersion{ + NodeType: node.Type, + NodeName: node.Name, + } + for _, name := range strings.Split(out, "\n") { + name = strings.TrimSpace(name) + if name == "" { + continue + } + envoyContainerVers := EnvoyContainerVersion{ + ContainerName: name, + } + out, err := client.Output(`docker exec -it %s envoy --version`) + if err != nil { + log.SpanLog(ctx, log.DebugLevelInfra, "failed to find envoy container version on rootlb", "rootlb", node, "container", name, "err", err, "out", out) + envoyContainerVers.Error = err.Error() + nodeVersion.EnvoyContainers = append(nodeVersion.EnvoyContainers, envoyContainerVers) + continue + } + version := strings.TrimSpace(out) + envoyContainerVers.EnvoyVersion = version + nodeVersion.EnvoyContainers = append(nodeVersion.EnvoyContainers, envoyContainerVers) + } + nodeVersions = append(nodeVersions, nodeVersion) + } + out, err := json.Marshal(nodeVersions) + if err != nil { + return fmt.Sprintf("Failed to marshal node versions: %s, %v", string(out), err) + } + return string(out) +} + func (cd *ControllerData) ProcessExecReq(ctx context.Context, req *edgeproto.ExecRequest) (reterr error) { var err error diff --git a/cloud-resource-manager/proxy/envoy.go b/cloud-resource-manager/proxy/envoy.go index 97ee07760..d86082575 100644 --- a/cloud-resource-manager/proxy/envoy.go +++ b/cloud-resource-manager/proxy/envoy.go @@ -195,6 +195,7 @@ func createEnvoyYaml(ctx context.Context, client ssh.Client, yamldir, name, list ListenIP: listenIP, BackendIP: backendIP, BackendPort: internalPort, + MaxPktSize: p.MaxPktSize, } udpconns, err := getUDPConcurrentConnections() if err != nil { @@ -250,12 +251,14 @@ static_resources: filter_chains: - filters: - name: envoy.filters.network.tcp_proxy - config: + typed_config: + '@type': type.googleapis.com/envoy.extensions.filters.network.tcp_proxy.v3.TcpProxy stat_prefix: ingress_tcp cluster: backend{{.BackendPort}} access_log: - name: envoy.access_loggers.file - config: + typed_config: + '@type': type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog path: /tmp/access.log json_format: { "start_time": "%START_TIME%", @@ -283,12 +286,21 @@ static_resources: protocol: UDP address: {{.ListenIP}} port_value: {{.ListenPort}} + {{if ne .MaxPktSize 0 -}} + udp_listener_config: + downstream_socket_config: + max_rx_datagram_size: {{.MaxPktSize}} + {{- end}} listener_filters: name: envoy.filters.udp_listener.udp_proxy typed_config: '@type': type.googleapis.com/envoy.extensions.filters.udp.udp_proxy.v3.UdpProxyConfig stat_prefix: downstream{{.BackendPort}} cluster: udp_backend{{.BackendPort}} + {{if ne .MaxPktSize 0 -}} + upstream_socket_config: + max_rx_datagram_size: {{.MaxPktSize}} + {{- end}} reuse_port: true {{- end}} clusters: @@ -300,10 +312,15 @@ static_resources: thresholds: max_connections: {{.ConcurrentConns}} lb_policy: round_robin - hosts: - - socket_address: - address: {{.BackendIP}} - port_value: {{.BackendPort}} + load_assignment: + cluster_name: backend{{.BackendPort}} + endpoints: + lb_endpoints: + - endpoint: + address: + socket_address: + address: {{.BackendIP}} + port_value: {{.BackendPort}} {{if .HealthCheck -}} health_checks: - timeout: 1s diff --git a/cloud-resource-manager/proxy/nginx.go b/cloud-resource-manager/proxy/nginx.go index b47096634..44223682e 100644 --- a/cloud-resource-manager/proxy/nginx.go +++ b/cloud-resource-manager/proxy/nginx.go @@ -292,6 +292,7 @@ type UDPSpecDetail struct { BackendIP string BackendPort int32 ConcurrentConns uint64 + MaxPktSize int64 } var nginxConf = ` diff --git a/cloudcommon/names.go b/cloudcommon/names.go index bbe443cfc..1ce6580d8 100644 --- a/cloudcommon/names.go +++ b/cloudcommon/names.go @@ -135,7 +135,7 @@ const MaxClusterNameLength = 40 // Common cert name. Cannot use common name as filename since envoy doesn't know if the app is dedicated or not const CertName = "envoyTlsCerts" -const EnvoyImageDigest = "sha256:9bc06553ad6add6bfef1d8a1b04f09721415975e2507da0a2d5b914c066474df" +const EnvoyImageDigest = "sha256:2b07bb8dd35c2a4bb273652b62e85b0bd27d12da94fa11061a9c365d4352e7f9" // PlatformApps is the set of all special "platform" developers. Key // is DeveloperName:AppName. Currently only platos's Enabling layer is included. diff --git a/d-match-engine/dme-proto/appcommon.pb.go b/d-match-engine/dme-proto/appcommon.pb.go index 27a3ba0e7..4f9f324e3 100644 --- a/d-match-engine/dme-proto/appcommon.pb.go +++ b/d-match-engine/dme-proto/appcommon.pb.go @@ -247,7 +247,9 @@ type AppPort struct { // TLS termination for this port Tls bool `protobuf:"varint,7,opt,name=tls,proto3" json:"tls,omitempty"` // use nginx proxy for this port if you really need a transparent proxy (udp only) - Nginx bool `protobuf:"varint,8,opt,name=nginx,proto3" json:"nginx,omitempty"` + Nginx bool `protobuf:"varint,8,opt,name=nginx,proto3" json:"nginx,omitempty"` + // Maximum datagram size (udp only) + MaxPktSize int64 `protobuf:"varint,9,opt,name=max_pkt_size,json=maxPktSize,proto3" json:"max_pkt_size,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -401,59 +403,61 @@ func init() { func init() { proto.RegisterFile("appcommon.proto", fileDescriptor_fdc58d2114e550de) } var fileDescriptor_fdc58d2114e550de = []byte{ - // 828 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0xcd, 0x6e, 0xe3, 0x44, - 0x1c, 0x5f, 0xa7, 0xf9, 0xfc, 0xa7, 0x6d, 0xa6, 0xd3, 0x96, 0xf5, 0x76, 0x77, 0xd3, 0xb4, 0x20, - 0x51, 0xe5, 0x90, 0x95, 0x40, 0xe2, 0xc0, 0x05, 0xb9, 0xf1, 0x94, 0x46, 0x4d, 0x3c, 0x61, 0xe2, - 0x2c, 0xda, 0xd3, 0xc8, 0xb1, 0xa7, 0xa9, 0xd5, 0x64, 0x6c, 0x9c, 0x09, 0x6c, 0x9f, 0x01, 0x09, - 0xf1, 0x18, 0x3c, 0x06, 0xc7, 0x3d, 0xf2, 0x08, 0xd0, 0x2b, 0x07, 0x6e, 0x9c, 0xd1, 0xd8, 0x4e, - 0x37, 0x9b, 0x2e, 0xb7, 0xf1, 0xef, 0xeb, 0xff, 0x31, 0xf2, 0x40, 0xc3, 0x8b, 0x63, 0x3f, 0x9a, - 0xcf, 0x23, 0xd9, 0x89, 0x93, 0x48, 0x45, 0xd8, 0x0c, 0xc2, 0x85, 0x4a, 0xc2, 0xc9, 0x52, 0x89, - 0x80, 0xcf, 0x3d, 0xe5, 0xdf, 0x70, 0x21, 0xa7, 0xa1, 0x14, 0x47, 0xad, 0x69, 0x14, 0x4d, 0x67, - 0xe2, 0x55, 0xaa, 0x9b, 0x2c, 0xaf, 0x5f, 0x05, 0x62, 0xe1, 0x27, 0x61, 0xac, 0xa2, 0x24, 0xf3, - 0x9e, 0xfe, 0x6d, 0x40, 0xc5, 0x8a, 0xe3, 0x61,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7c, 0x25, 0x47, 0x25, 0x9d, 0xda, 0x65, - 0x83, 0xb5, 0x72, 0xe5, 0xdc, 0x7b, 0x0c, 0x87, 0x9a, 0x18, 0x3b, 0x36, 0x61, 0x7c, 0x2d, 0x05, - 0x55, 0x72, 0xc1, 0x3e, 0xd4, 0xb4, 0x20, 0xab, 0x58, 0x7d, 0xef, 0xda, 0x9c, 0x37, 0xdb, 0x6c, - 0x2d, 0x17, 0x3c, 0x87, 0xbd, 0xc7, 0x91, 0xc7, 0x19, 0xf9, 0xf5, 0x05, 0x6c, 0x0b, 0xb9, 0x9c, - 0xf3, 0x89, 0xe7, 0xdf, 0x0a, 0x19, 0xe0, 0x93, 0x4e, 0xf6, 0x46, 0x76, 0x56, 0x6f, 0x64, 0x87, - 0xc8, 0xe5, 0xfc, 0xb5, 0x37, 0x5b, 0x0a, 0x1a, 0xab, 0x30, 0x92, 0x0b, 0xf3, 0xfe, 0x97, 0xad, - 0xf4, 0x11, 0xa9, 0x6b, 0xe3, 0x79, 0xe6, 0x3b, 0x47, 0xef, 0xfe, 0x6a, 0x3e, 0x79, 0x77, 0xdf, - 0x34, 0xfe, 0xb8, 0x6f, 0x1a, 0x7f, 0xde, 0x37, 0x8d, 0x49, 0x39, 0x4d, 0xf8, 0xf2, 0xbf, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xee, 0x36, 0x39, 0xcb, 0xa0, 0x05, 0x00, 0x00, + // 856 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0xcd, 0x6e, 0xe2, 0x46, + 0x1c, 0x5f, 0x43, 0x08, 0xf0, 0x27, 0x09, 0x93, 0x49, 0xd2, 0xf5, 0x66, 0x77, 0x09, 0x49, 0x2b, + 0x15, 0x71, 0x60, 0xa5, 0x56, 0xea, 0xa1, 0x97, 0xca, 0xc1, 0x93, 0x06, 0x05, 0x6c, 0x77, 0x30, + 0x5b, 0xed, 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f2, 0xeb, 0x0b, 0xd8, 0xe1, 0x62, 0x11, 0xb1, 0xb1, 0xe7, 0x4f, + 0xb9, 0x08, 0xf0, 0x69, 0x27, 0x7f, 0x45, 0x3b, 0xab, 0x57, 0xb4, 0x43, 0xc4, 0x22, 0x7a, 0xed, + 0xcd, 0x16, 0xdc, 0x4e, 0x64, 0x18, 0x8b, 0xb9, 0x7e, 0xff, 0x6b, 0x31, 0x7b, 0x66, 0x6a, 0xca, + 0x78, 0x9e, 0xfb, 0xce, 0xd1, 0xbb, 0xbf, 0x1b, 0x4f, 0xde, 0xdd, 0x37, 0xb4, 0x3f, 0xef, 0x1b, + 0xda, 0x5f, 0xf7, 0x0d, 0x6d, 0xbc, 0x9d, 0x25, 0x7c, 0xf9, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x02, 0x0c, 0x26, 0x7f, 0xc2, 0x05, 0x00, 0x00, } func (m *AppPort) Marshal() (dAtA []byte, err error) { @@ -480,6 +484,11 @@ func (m *AppPort) MarshalToSizedBuffer(dAtA []byte) (int, error) { i -= len(m.XXX_unrecognized) copy(dAtA[i:], m.XXX_unrecognized) } + if m.MaxPktSize != 0 { + i = encodeVarintAppcommon(dAtA, i, uint64(m.MaxPktSize)) + i-- + dAtA[i] = 0x48 + } if m.Nginx { i-- if m.Nginx { @@ -658,6 +667,10 @@ func (m *AppPort) CopyInFields(src *AppPort) int { m.Nginx = src.Nginx changed++ } + if m.MaxPktSize != src.MaxPktSize { + m.MaxPktSize = src.MaxPktSize + changed++ + } return changed } @@ -669,6 +682,7 @@ func (m *AppPort) DeepCopyIn(src *AppPort) { m.EndPort = src.EndPort m.Tls = src.Tls m.Nginx = src.Nginx + m.MaxPktSize = src.MaxPktSize } // Helper method to check that enums have valid values @@ -1233,6 +1247,9 @@ func (m *AppPort) Size() (n int) { if m.Nginx { n += 2 } + if m.MaxPktSize != 0 { + n += 1 + sovAppcommon(uint64(m.MaxPktSize)) + } if m.XXX_unrecognized != nil { n += len(m.XXX_unrecognized) } @@ -1465,6 +1482,25 @@ func (m *AppPort) Unmarshal(dAtA []byte) error { } } m.Nginx = bool(v != 0) + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxPktSize", wireType) + } + m.MaxPktSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAppcommon + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxPktSize |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipAppcommon(dAtA[iNdEx:]) diff --git a/docker_envoy/Dockerfile b/docker_envoy/Dockerfile index 85e98a4ab..163dcf16b 100644 --- a/docker_envoy/Dockerfile +++ b/docker_envoy/Dockerfile @@ -1,3 +1,3 @@ -FROM envoyproxy/envoy:v1.15-latest +FROM envoyproxy/envoy:v1.18-latest RUN apt-get --assume-yes update && apt-get --assume-yes install curl ENV ENVOY_UID=0 ENVOY_GID=0 diff --git a/edgeproto/appinst.pb.go b/edgeproto/appinst.pb.go index 3a1a28ff0..b07fc6ba5 100644 --- a/edgeproto/appinst.pb.go +++ b/edgeproto/appinst.pb.go @@ -2464,6 +2464,7 @@ const AppInstFieldMappedPortsFqdnPrefix = "9.5" const AppInstFieldMappedPortsEndPort = "9.6" const AppInstFieldMappedPortsTls = "9.7" const AppInstFieldMappedPortsNginx = "9.8" +const AppInstFieldMappedPortsMaxPktSize = "9.9" const AppInstFieldFlavor = "12" const AppInstFieldFlavorName = "12.1" const AppInstFieldState = "14" @@ -2526,6 +2527,7 @@ var AppInstAllFields = []string{ AppInstFieldMappedPortsEndPort, AppInstFieldMappedPortsTls, AppInstFieldMappedPortsNginx, + AppInstFieldMappedPortsMaxPktSize, AppInstFieldFlavorName, AppInstFieldState, AppInstFieldErrors, @@ -2583,6 +2585,7 @@ var AppInstAllFieldsMap = map[string]struct{}{ AppInstFieldMappedPortsEndPort: struct{}{}, AppInstFieldMappedPortsTls: struct{}{}, AppInstFieldMappedPortsNginx: struct{}{}, + AppInstFieldMappedPortsMaxPktSize: struct{}{}, AppInstFieldFlavorName: struct{}{}, AppInstFieldState: struct{}{}, AppInstFieldErrors: struct{}{}, @@ -2640,6 +2643,7 @@ var AppInstAllFieldsStringMap = map[string]string{ AppInstFieldMappedPortsEndPort: "Mapped Ports End Port", AppInstFieldMappedPortsTls: "Mapped Ports Tls", AppInstFieldMappedPortsNginx: "Mapped Ports Nginx", + AppInstFieldMappedPortsMaxPktSize: "Mapped Ports Max Pkt Size", AppInstFieldFlavorName: "Flavor Name", AppInstFieldState: "State", AppInstFieldErrors: "Errors", @@ -2795,6 +2799,10 @@ func (m *AppInst) DiffFields(o *AppInst, fields map[string]struct{}) { fields[AppInstFieldMappedPortsNginx] = struct{}{} fields[AppInstFieldMappedPorts] = struct{}{} } + if m.MappedPorts[i0].MaxPktSize != o.MappedPorts[i0].MaxPktSize { + fields[AppInstFieldMappedPortsMaxPktSize] = struct{}{} + fields[AppInstFieldMappedPorts] = struct{}{} + } } } if m.Flavor.Name != o.Flavor.Name { diff --git a/edgeproto/objs.go b/edgeproto/objs.go index 72fe4748f..dc608517c 100644 --- a/edgeproto/objs.go +++ b/edgeproto/objs.go @@ -909,6 +909,7 @@ func ParseAppPorts(ports string) ([]dme.AppPort, error) { EndPort: int32(endport), Tls: portSpec.Tls, Nginx: portSpec.Nginx, + MaxPktSize: portSpec.MaxPktSize, } appports = append(appports, p) diff --git a/gencmd/alldata.cmd.go b/gencmd/alldata.cmd.go index 2bbef3f34..15b0d6a82 100644 --- a/gencmd/alldata.cmd.go +++ b/gencmd/alldata.cmd.go @@ -669,6 +669,7 @@ var AllDataOptionalArgs = []string{ "appinstances:#.mappedports:#.endport", "appinstances:#.mappedports:#.tls", "appinstances:#.mappedports:#.nginx", + "appinstances:#.mappedports:#.maxpktsize", "appinstances:#.flavor.name", "appinstances:#.state", "appinstances:#.errors", @@ -1097,6 +1098,7 @@ var AllDataComments = map[string]string{ "appinstances:#.mappedports:#.endport": "A non-zero end port indicates a port range from internal port to end port, inclusive.", "appinstances:#.mappedports:#.tls": "TLS termination for this port", "appinstances:#.mappedports:#.nginx": "use nginx proxy for this port if you really need a transparent proxy (udp only)", + "appinstances:#.mappedports:#.maxpktsize": "Maximum datagram size (udp only)", "appinstances:#.flavor.name": "Flavor name", "appinstances:#.state": "Current state of the AppInst on the Cloudlet, one of TrackedStateUnknown, NotPresent, CreateRequested, Creating, CreateError, Ready, UpdateRequested, Updating, UpdateError, DeleteRequested, Deleting, DeleteError, DeletePrepare, CrmInitok, CreatingDependencies, DeleteDone", "appinstances:#.errors": "Any errors trying to create, update, or delete the AppInst on the Cloudlet", diff --git a/gencmd/app-client.cmd.go b/gencmd/app-client.cmd.go index c2b19b957..35a78b992 100644 --- a/gencmd/app-client.cmd.go +++ b/gencmd/app-client.cmd.go @@ -746,6 +746,7 @@ var FindCloudletReplyOptionalArgs = []string{ "ports:#.endport", "ports:#.tls", "ports:#.nginx", + "ports:#.maxpktsize", "cloudletlocation.latitude", "cloudletlocation.longitude", "cloudletlocation.horizontalaccuracy", @@ -770,6 +771,7 @@ var FindCloudletReplyComments = map[string]string{ "ports:#.endport": "A non-zero end port indicates a port range from internal port to end port, inclusive.", "ports:#.tls": "TLS termination for this port", "ports:#.nginx": "use nginx proxy for this port if you really need a transparent proxy (udp only)", + "ports:#.maxpktsize": "Maximum datagram size (udp only)", "cloudletlocation.latitude": "latitude in WGS 84 coordinates", "cloudletlocation.longitude": "longitude in WGS 84 coordinates", "cloudletlocation.horizontalaccuracy": "horizontal accuracy (radius in meters)", @@ -942,6 +944,7 @@ var AppinstanceOptionalArgs = []string{ "ports:#.endport", "ports:#.tls", "ports:#.nginx", + "ports:#.maxpktsize", "orgname", "edgeeventscookie", } @@ -957,6 +960,7 @@ var AppinstanceComments = map[string]string{ "ports:#.endport": "A non-zero end port indicates a port range from internal port to end port, inclusive.", "ports:#.tls": "TLS termination for this port", "ports:#.nginx": "use nginx proxy for this port if you really need a transparent proxy (udp only)", + "ports:#.maxpktsize": "Maximum datagram size (udp only)", "orgname": "App Organization Name", "edgeeventscookie": "Session Cookie for specific EdgeEvents for specific AppInst", } @@ -985,6 +989,7 @@ var CloudletLocationOptionalArgs = []string{ "appinstances:#.ports:#.endport", "appinstances:#.ports:#.tls", "appinstances:#.ports:#.nginx", + "appinstances:#.ports:#.maxpktsize", "appinstances:#.orgname", "appinstances:#.edgeeventscookie", } @@ -1010,6 +1015,7 @@ var CloudletLocationComments = map[string]string{ "appinstances:#.ports:#.endport": "A non-zero end port indicates a port range from internal port to end port, inclusive.", "appinstances:#.ports:#.tls": "TLS termination for this port", "appinstances:#.ports:#.nginx": "use nginx proxy for this port if you really need a transparent proxy (udp only)", + "appinstances:#.ports:#.maxpktsize": "Maximum datagram size (udp only)", "appinstances:#.orgname": "App Organization Name", "appinstances:#.edgeeventscookie": "Session Cookie for specific EdgeEvents for specific AppInst", } @@ -1040,6 +1046,7 @@ var AppInstListReplyOptionalArgs = []string{ "cloudlets:#.appinstances:#.ports:#.endport", "cloudlets:#.appinstances:#.ports:#.tls", "cloudlets:#.appinstances:#.ports:#.nginx", + "cloudlets:#.appinstances:#.ports:#.maxpktsize", "cloudlets:#.appinstances:#.orgname", "cloudlets:#.appinstances:#.edgeeventscookie", "tags", @@ -1068,6 +1075,7 @@ var AppInstListReplyComments = map[string]string{ "cloudlets:#.appinstances:#.ports:#.endport": "A non-zero end port indicates a port range from internal port to end port, inclusive.", "cloudlets:#.appinstances:#.ports:#.tls": "TLS termination for this port", "cloudlets:#.appinstances:#.ports:#.nginx": "use nginx proxy for this port if you really need a transparent proxy (udp only)", + "cloudlets:#.appinstances:#.ports:#.maxpktsize": "Maximum datagram size (udp only)", "cloudlets:#.appinstances:#.orgname": "App Organization Name", "cloudlets:#.appinstances:#.edgeeventscookie": "Session Cookie for specific EdgeEvents for specific AppInst", "tags": "_(optional)_ Vendor specific data", @@ -1181,6 +1189,7 @@ var AppOfficialFqdnReplyOptionalArgs = []string{ "ports:#.endport", "ports:#.tls", "ports:#.nginx", + "ports:#.maxpktsize", "tags", } var AppOfficialFqdnReplyAliasArgs = []string{} @@ -1196,6 +1205,7 @@ var AppOfficialFqdnReplyComments = map[string]string{ "ports:#.endport": "A non-zero end port indicates a port range from internal port to end port, inclusive.", "ports:#.tls": "TLS termination for this port", "ports:#.nginx": "use nginx proxy for this port if you really need a transparent proxy (udp only)", + "ports:#.maxpktsize": "Maximum datagram size (udp only)", "tags": "_(optional)_ Vendor specific data", } var AppOfficialFqdnReplySpecialArgs = map[string]string{ @@ -1485,6 +1495,7 @@ var ServerEdgeEventOptionalArgs = []string{ "newcloudlet.ports:#.endport", "newcloudlet.ports:#.tls", "newcloudlet.ports:#.nginx", + "newcloudlet.ports:#.maxpktsize", "newcloudlet.cloudletlocation.latitude", "newcloudlet.cloudletlocation.longitude", "newcloudlet.cloudletlocation.horizontalaccuracy", @@ -1521,6 +1532,7 @@ var ServerEdgeEventComments = map[string]string{ "newcloudlet.ports:#.endport": "A non-zero end port indicates a port range from internal port to end port, inclusive.", "newcloudlet.ports:#.tls": "TLS termination for this port", "newcloudlet.ports:#.nginx": "use nginx proxy for this port if you really need a transparent proxy (udp only)", + "newcloudlet.ports:#.maxpktsize": "Maximum datagram size (udp only)", "newcloudlet.cloudletlocation.latitude": "latitude in WGS 84 coordinates", "newcloudlet.cloudletlocation.longitude": "longitude in WGS 84 coordinates", "newcloudlet.cloudletlocation.horizontalaccuracy": "horizontal accuracy (radius in meters)", diff --git a/gencmd/appcommon.cmd.go b/gencmd/appcommon.cmd.go index ea0ec2dc8..5554341a8 100644 --- a/gencmd/appcommon.cmd.go +++ b/gencmd/appcommon.cmd.go @@ -25,6 +25,7 @@ var AppPortOptionalArgs = []string{ "endport", "tls", "nginx", + "maxpktsize", } var AppPortAliasArgs = []string{} var AppPortComments = map[string]string{ @@ -35,6 +36,7 @@ var AppPortComments = map[string]string{ "endport": "A non-zero end port indicates a port range from internal port to end port, inclusive.", "tls": "TLS termination for this port", "nginx": "use nginx proxy for this port if you really need a transparent proxy (udp only)", + "maxpktsize": "Maximum datagram size (udp only)", } var AppPortSpecialArgs = map[string]string{} var DeviceInfoStaticRequiredArgs = []string{} diff --git a/gencmd/appinst.cmd.go b/gencmd/appinst.cmd.go index 0e8a918c7..3619c20ef 100644 --- a/gencmd/appinst.cmd.go +++ b/gencmd/appinst.cmd.go @@ -836,6 +836,7 @@ var AppInstComments = map[string]string{ "mappedports:#.endport": "A non-zero end port indicates a port range from internal port to end port, inclusive.", "mappedports:#.tls": "TLS termination for this port", "mappedports:#.nginx": "use nginx proxy for this port if you really need a transparent proxy (udp only)", + "mappedports:#.maxpktsize": "Maximum datagram size (udp only)", "flavor": "Flavor name", "state": "Current state of the AppInst on the Cloudlet, one of TrackedStateUnknown, NotPresent, CreateRequested, Creating, CreateError, Ready, UpdateRequested, Updating, UpdateError, DeleteRequested, Deleting, DeleteError, DeletePrepare, CrmInitok, CreatingDependencies, DeleteDone", "errors": "Any errors trying to create, update, or delete the AppInst on the Cloudlet, specify errors:empty=true to clear", diff --git a/util/ports.go b/util/ports.go index bb762c800..261766502 100644 --- a/util/ports.go +++ b/util/ports.go @@ -10,13 +10,16 @@ var maxTcpPorts int = 1000 var maxUdpPorts int = 10000 var maxEnvoyUdpPorts int = 1000 var MaxK8sUdpPorts int = 1000 +var minUDPPktSize int64 = 1500 +var maxUDPPktSize int64 = 50000 type PortSpec struct { - Proto string - Port string - EndPort string // mfw XXX ? why two type and parse rtns for AppPort? (3 actually kube.go is another) - Tls bool - Nginx bool + Proto string + Port string + EndPort string // mfw XXX ? why two type and parse rtns for AppPort? (3 actually kube.go is another) + Tls bool + Nginx bool + MaxPktSize int64 } func ParsePorts(accessPorts string) ([]PortSpec, error) { @@ -113,6 +116,18 @@ func ParsePorts(accessPorts string) ([]PortSpec, error) { return nil, fmt.Errorf("Invalid annotation \"nginx\" for %s ports", portSpec.Proto) } portSpec.Nginx = true + case "maxpktsize": + if portSpec.Proto != "udp" { + return nil, fmt.Errorf("Invalid annotation \"maxpktsize\" for %s ports, only valid for UDP protocol", portSpec.Proto) + } + maxPktSize, err := strconv.ParseInt(val, 10, 64) + if err != nil { + return nil, fmt.Errorf("unable to convert pkt size value: %s", val) + } + if maxPktSize < minUDPPktSize || maxPktSize > maxUDPPktSize { + return nil, fmt.Errorf("Invalid maxpktsize, should be between range %v to %v (exclusive)", minUDPPktSize, maxUDPPktSize) + } + portSpec.MaxPktSize = maxPktSize default: return nil, fmt.Errorf("unrecognized annotation %s for port %s", key+"="+val, pp[1]) } diff --git a/util/ports_test.go b/util/ports_test.go index 989a7febd..2d921f771 100644 --- a/util/ports_test.go +++ b/util/ports_test.go @@ -26,6 +26,10 @@ var accessPorts = []string{ "udp:10000-20000", // 17 "accessports", // 18 "http:80", // 19 + "udp:20-22,udp:23-25:nginx:maxpktsize=1600", // 20 + "udp:23-25:maxpktsize=1", // 21 + "udp:26:maxpktsize=50000", // 22 + "tcp:20:maxpktsize=50000", // 23 } func TestParsePorts(t *testing.T) { @@ -85,6 +89,18 @@ func TestParsePorts(t *testing.T) { require.NotNil(t, err, "Incorrect accessports format") case 19: require.NotNil(t, err, "Only tcp and udp are recognized as valid protocols") + case 20: + require.Nil(t, err, "valid accessPorts input") + require.Equal(t, int64(0), ports[0].MaxPktSize, "valid pkt size can be set for UDP") + require.Equal(t, int64(1600), ports[1].MaxPktSize, "valid pkt size can be set for UDP") + case 21: + require.NotNil(t, err, "Incorrect maxpktsize value") + case 22: + require.Nil(t, err, "valid accessPorts input") + require.Equal(t, int64(50000), ports[0].MaxPktSize, "valid pkt size can be set for UDP") + case 23: + require.NotNil(t, err, "maxpktsize not valid for tcp") + } }