From 1bc2241d6c8b4a2f81f7e376e8ba8682b64d6c07 Mon Sep 17 00:00:00 2001 From: Shriram Rajagopalan Date: Thu, 1 Aug 2019 13:57:07 -0400 Subject: [PATCH] Switch from istio_proxy_version to istio_version (#15886) * nuke proxy version Signed-off-by: Shriram Rajagopalan * lint Signed-off-by: Shriram Rajagopalan * bump makefile version Signed-off-by: Shriram Rajagopalan * sem ver check Signed-off-by: Shriram Rajagopalan * fixes Signed-off-by: Shriram Rajagopalan * fixes Signed-off-by: Shriram Rajagopalan * fix test Signed-off-by: Shriram Rajagopalan --- Makefile | 2 +- .../auth/productpage_config_dump.json | 1 - pilot/docker/Dockerfile.proxy_debug | 2 - pilot/docker/Dockerfile.proxytproxy | 2 - pilot/docker/Dockerfile.proxyv2 | 2 - pilot/pkg/model/context.go | 85 ++++++++++++-- pilot/pkg/model/context_test.go | 111 +++++++++++++++++- pilot/pkg/networking/core/v1alpha3/gateway.go | 6 +- .../pkg/networking/core/v1alpha3/listener.go | 4 +- .../core/v1alpha3/listener_builder_test.go | 2 +- .../networking/core/v1alpha3/listener_test.go | 4 +- .../networking/core/v1alpha3/networkfilter.go | 11 +- .../networking/core/v1alpha3/route/route.go | 18 ++- .../core/v1alpha3/route/route_test.go | 2 +- pilot/pkg/networking/util/util.go | 14 ++- pilot/pkg/networking/util/util_test.go | 70 ----------- pilot/pkg/proxy/envoy/v2/debug.go | 2 - pilot/pkg/proxy/envoy/v2/eds_sh_test.go | 4 +- pilot/pkg/proxy/envoy/v2/init_test.go | 2 +- pilot/pkg/proxy/envoy/v2/lds_test.go | 24 ++-- pilot/pkg/proxy/envoy/v2/xds_test.go | 2 +- .../serviceregistry/memory/discovery_mock.go | 9 +- pkg/adsc/adsc.go | 2 +- pkg/bootstrap/bootstrap_config_test.go | 17 ++- pkg/bootstrap/testdata/running_golden.json | 1 - .../echo/common/testdata/config_dump.json | 1 - tests/integration/pilot/sidecar_api_test.go | 17 +-- tools/packaging/common/istio-start.sh | 2 +- 28 files changed, 251 insertions(+), 168 deletions(-) diff --git a/Makefile b/Makefile index 7a0c6af5c1c1..c9f7563e3226 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ export ISTIO_GO SHELL := /bin/bash -o pipefail # Current version, updated after a release. -VERSION ?= 1.0-dev +VERSION ?= 1.3-dev # locations where artifacts are stored ISTIO_DOCKER_HUB ?= docker.io/istio diff --git a/istioctl/cmd/testdata/auth/productpage_config_dump.json b/istioctl/cmd/testdata/auth/productpage_config_dump.json index 13a266df61f4..072ed4eaafab 100644 --- a/istioctl/cmd/testdata/auth/productpage_config_dump.json +++ b/istioctl/cmd/testdata/auth/productpage_config_dump.json @@ -16,7 +16,6 @@ "INSTANCE_IPS": "10.52.2.21,fe80::54f8:2cff:fe2b:2dd3", "POD_NAME": "productpage-v1-5cb458d74f-56sx7", "istio": "sidecar", - "ISTIO_PROXY_VERSION": "1.1.0", "ISTIO_PROXY_SHA": "istio-proxy:55c80965eab994e6bfa2227e3942fa89928d0d70", "app": "productpage" }, diff --git a/pilot/docker/Dockerfile.proxy_debug b/pilot/docker/Dockerfile.proxy_debug index 08ea9b936761..b229fa432cbd 100644 --- a/pilot/docker/Dockerfile.proxy_debug +++ b/pilot/docker/Dockerfile.proxy_debug @@ -11,8 +11,6 @@ LABEL istio-api-vcs-ref=$ISTIO_API_SHA \ # Install Envoy. COPY envoy /usr/local/bin/envoy -# Environment variables indicating this proxy's version/capabilities as opaque string -ENV ISTIO_META_ISTIO_PROXY_VERSION "1.1.3" # Environment variable indicating the exact proxy sha - for debugging or version-specific configs ENV ISTIO_META_ISTIO_PROXY_SHA $proxy_version # Environment variable indicating the exact build, for debugging diff --git a/pilot/docker/Dockerfile.proxytproxy b/pilot/docker/Dockerfile.proxytproxy index 8a2660ca6c40..b683907cf8bd 100644 --- a/pilot/docker/Dockerfile.proxytproxy +++ b/pilot/docker/Dockerfile.proxytproxy @@ -8,8 +8,6 @@ ARG ENVOY_SHA=unknown LABEL istio-api-vcs-ref=$ISTIO_API_SHA \ envoy-vcs-ref=$ENVOY_SHA -# Environment variables indicating this proxy's version/capabilities as opaque string -ENV ISTIO_META_ISTIO_PROXY_VERSION "1.1.3" # Environment variable indicating the exact proxy sha - for debugging or version-specific configs ENV ISTIO_META_ISTIO_PROXY_SHA $proxy_version # Environment variable indicating the exact build, for debugging diff --git a/pilot/docker/Dockerfile.proxyv2 b/pilot/docker/Dockerfile.proxyv2 index f23263edf1f0..8de1689be9e2 100644 --- a/pilot/docker/Dockerfile.proxyv2 +++ b/pilot/docker/Dockerfile.proxyv2 @@ -43,8 +43,6 @@ LABEL istio-api-vcs-ref=$ISTIO_API_SHA \ # Install Envoy. COPY envoy /usr/local/bin/envoy -# Environment variables indicating this proxy's version/capabilities as opaque string -ENV ISTIO_META_ISTIO_PROXY_VERSION "1.1.3" # Environment variable indicating the exact proxy sha - for debugging or version-specific configs ENV ISTIO_META_ISTIO_PROXY_SHA $proxy_version # Environment variable indicating the exact build, for debugging diff --git a/pilot/pkg/model/context.go b/pilot/pkg/model/context.go index 5f12683dd4e8..b0f4159ee938 100644 --- a/pilot/pkg/model/context.go +++ b/pilot/pkg/model/context.go @@ -17,6 +17,7 @@ package model import ( "fmt" "net" + "regexp" "strconv" "strings" @@ -119,6 +120,54 @@ type Proxy struct { // labels associated with the workload WorkloadLabels config.LabelsCollection + + // Istio version associated with the Proxy + IstioVersion *IstioVersion +} + +var ( + istioVersionRegexp = regexp.MustCompile(`^([1-9]+)\.([0-9]+)(\.([0-9]+))?`) +) + +// IstioVersion encodes the Istio version of the proxy. This is a low key way to +// do semver style comparisons and generate the appropriate envoy config +type IstioVersion struct { + Major int + Minor int + Patch int +} + +var ( + MaxIstioVersion = &IstioVersion{Major: 65535, Minor: 65535, Patch: 65535} +) + +// Compare returns -1/0/1 if version is less than, equal or greater than inv +// To compare only on major, call this function with { X, -1, -1}. +// to compare only on major & minor, call this function with {X, Y, -1}. +func (pversion *IstioVersion) Compare(inv *IstioVersion) int { + if pversion.Major > inv.Major { + return 1 + } else if pversion.Major < inv.Major { + return -1 + } + + // check minors + if inv.Minor > -1 { + if pversion.Minor > inv.Minor { + return 1 + } else if pversion.Minor < inv.Minor { + return -1 + } + // check patch + if inv.Patch > -1 { + if pversion.Patch > inv.Patch { + return 1 + } else if pversion.Patch < inv.Patch { + return -1 + } + } + } + return 0 } // NodeType decides the responsibility of the proxy serves in the mesh @@ -157,12 +206,6 @@ func (node *Proxy) ServiceNode() string { } -// GetProxyVersion returns the proxy version string identifier, and whether it is present. -func (node *Proxy) GetProxyVersion() (string, bool) { - version, found := node.Metadata[NodeMetadataIstioProxyVersion] - return version, found -} - // GetIstioVersion returns the Istio version of the proxy, and whether it is present func (node *Proxy) GetIstioVersion() (string, bool) { version, found := node.Metadata[NodeMetadataIstioVersion] @@ -318,9 +361,36 @@ func ParseServiceNodeWithMetadata(s string, metadata map[string]string) (*Proxy, out.ID = parts[2] out.DNSDomain = parts[3] + out.IstioVersion = ParseIstioVersion(metadata[NodeMetadataIstioVersion]) return out, nil } +// ParseIstioVersion parses a version string and returns IstioVersion struct +func ParseIstioVersion(ver string) *IstioVersion { + if strings.HasPrefix(ver, "master-") { + // This proxy is from a master branch build. Assume latest version + return MaxIstioVersion + } + + // strip the release- prefix if any and extract the version string + ver = istioVersionRegexp.FindString(strings.TrimPrefix(ver, "release-")) + + if ver == "" { + // return very large values assuming latest version + return MaxIstioVersion + } + + parts := strings.Split(ver, ".") + // we are guaranteed to have atleast major and minor based on the regex + major, _ := strconv.Atoi(parts[0]) + minor, _ := strconv.Atoi(parts[1]) + patch := 0 + if len(parts) > 2 { + patch, _ = strconv.Atoi(parts[2]) + } + return &IstioVersion{Major: major, Minor: minor, Patch: patch} +} + // GetOrDefaultFromMap returns either the value found for key or the default value if the map is nil // or does not contain the key. Useful when retrieving node metadata fields. func GetOrDefaultFromMap(stringMap map[string]string, key, defaultVal string) string { @@ -393,9 +463,6 @@ func isValidIPAddress(ip string) bool { // Pile all node metadata constants here const ( - // NodeMetadataIstioProxyVersion specifies the Envoy version associated with the proxy - NodeMetadataIstioProxyVersion = "ISTIO_PROXY_VERSION" - // NodeMetadataIstioVersion specifies the Istio version associated with the proxy NodeMetadataIstioVersion = "ISTIO_VERSION" diff --git a/pilot/pkg/model/context_test.go b/pilot/pkg/model/context_test.go index c259abd42720..c6f6b91f8cb0 100644 --- a/pilot/pkg/model/context_test.go +++ b/pilot/pkg/model/context_test.go @@ -25,7 +25,7 @@ import ( ) func TestServiceNode(t *testing.T) { - nodes := []struct { + cases := []struct { in *model.Proxy out string }{ @@ -35,10 +35,11 @@ func TestServiceNode(t *testing.T) { }, { in: &model.Proxy{ - Type: model.Router, - ID: "random", - IPAddresses: []string{"10.3.3.3"}, - DNSDomain: "local", + Type: model.Router, + ID: "random", + IPAddresses: []string{"10.3.3.3"}, + DNSDomain: "local", + IstioVersion: model.MaxIstioVersion, }, out: "router~10.3.3.3~random~local", }, @@ -51,12 +52,13 @@ func TestServiceNode(t *testing.T) { Metadata: map[string]string{ "INSTANCE_IPS": "10.3.3.3,10.4.4.4,10.5.5.5,10.6.6.6", }, + IstioVersion: model.MaxIstioVersion, }, out: "sidecar~10.3.3.3~random~local", }, } - for _, node := range nodes { + for _, node := range cases { out := node.in.ServiceNode() if out != node.out { t.Errorf("%#v.ServiceNode() => Got %s, want %s", node.in, out, node.out) @@ -87,3 +89,100 @@ func TestGetOrDefaultFromMap(t *testing.T) { assert.Equal(t, "expectedDefaultKey2Value", model.GetOrDefaultFromMap(meta, "key2", "expectedDefaultKey2Value")) assert.Equal(t, "expectedDefaultFromNilMap", model.GetOrDefaultFromMap(nil, "key", "expectedDefaultFromNilMap")) } + +func TestProxyVersion_Compare(t *testing.T) { + type fields struct { + Major int + Minor int + Patch int + } + type args struct { + inv *model.IstioVersion + } + tests := []struct { + name string + fields fields + args args + want int + }{ + { + name: "greater major", + fields: fields{Major: 2, Minor: 1, Patch: 1}, + args: args{&model.IstioVersion{Major: 1, Minor: 2, Patch: 1}}, + want: 1, + }, + { + name: "equal at minor", + fields: fields{Major: 2, Minor: 1, Patch: 1}, + args: args{&model.IstioVersion{Major: 2, Minor: 1, Patch: -1}}, + want: 0, + }, + { + name: "less at patch", + fields: fields{Major: 2, Minor: 1, Patch: 0}, + args: args{&model.IstioVersion{Major: 2, Minor: 1, Patch: 1}}, + want: -1, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + pversion := &model.IstioVersion{ + Major: tt.fields.Major, + Minor: tt.fields.Minor, + Patch: tt.fields.Patch, + } + if got := pversion.Compare(tt.args.inv); got != tt.want { + t.Errorf("ProxyVersion.Compare() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_parseIstioVersion(t *testing.T) { + type args struct { + ver string + } + tests := []struct { + name string + args args + want *model.IstioVersion + }{ + { + name: "major.minor.patch", + args: args{ver: "1.2.3"}, + want: &model.IstioVersion{Major: 1, Minor: 2, Patch: 3}, + }, + { + name: "major.minor", + args: args{ver: "1.2"}, + want: &model.IstioVersion{Major: 1, Minor: 2, Patch: 0}, + }, + { + name: "release-major.minor-date", + args: args{ver: "release-1.2-123214234"}, + want: &model.IstioVersion{Major: 1, Minor: 2, Patch: 0}, + }, + { + name: "master-date", + args: args{ver: "master-123214234"}, + want: model.MaxIstioVersion, + }, + { + name: "junk-major.minor.patch", + args: args{ver: "junk-1.2.3214234"}, + want: model.MaxIstioVersion, + }, + { + name: "junk-garbage", + args: args{ver: "junk-garbage"}, + want: model.MaxIstioVersion, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := model.ParseIstioVersion(tt.args.ver); !reflect.DeepEqual(got, tt.want) { + t.Errorf("parseIstioVersion() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/pilot/pkg/networking/core/v1alpha3/gateway.go b/pilot/pkg/networking/core/v1alpha3/gateway.go index 049652d2351c..d7483ff22767 100644 --- a/pilot/pkg/networking/core/v1alpha3/gateway.go +++ b/pilot/pkg/networking/core/v1alpha3/gateway.go @@ -371,9 +371,9 @@ func (configgen *ConfigGeneratorImpl) createGatewayHTTPFilterChainOpts( // We know that this is a HTTPS server because this function is called only for ports of type HTTP/HTTPS // where HTTPS server's TLS mode is not passthrough and not nil enableIngressSdsAgent := false - // If proxy version is over 1.1, and proxy sends metadata USER_SDS, then create SDS config for + // If proxy sends metadata USER_SDS, then create SDS config for // gateway listener. - if enableSds, found := node.Metadata["USER_SDS"]; found && util.IsProxyVersionGE11(node) { + if enableSds, found := node.Metadata["USER_SDS"]; found { enableIngressSdsAgent, _ = strconv.ParseBool(enableSds) } return &filterChainOpts{ @@ -533,7 +533,7 @@ func (configgen *ConfigGeneratorImpl) createGatewayTCPFilterChainOpts( enableIngressSdsAgent := false // If proxy version is over 1.1, and proxy sends metadata USER_SDS, then create SDS config for // gateway listener. - if enableSds, found := node.Metadata["USER_SDS"]; found && util.IsProxyVersionGE11(node) { + if enableSds, found := node.Metadata["USER_SDS"]; found { enableIngressSdsAgent, _ = strconv.ParseBool(enableSds) } return []*filterChainOpts{ diff --git a/pilot/pkg/networking/core/v1alpha3/listener.go b/pilot/pkg/networking/core/v1alpha3/listener.go index 8885ce0f38ce..aef2e8314941 100644 --- a/pilot/pkg/networking/core/v1alpha3/listener.go +++ b/pilot/pkg/networking/core/v1alpha3/listener.go @@ -1515,9 +1515,7 @@ func buildHTTPConnectionManager(node *model.Proxy, env *model.Environment, httpO Name: xdsutil.FileAccessLog, } - if util.IsProxyVersionGE11(node) { - buildAccessLog(fl, env) - } + buildAccessLog(fl, env) if util.IsXDSMarshalingToAnyEnabled(node) { acc.ConfigType = &accesslog.AccessLog_TypedConfig{TypedConfig: util.MessageToAny(fl)} diff --git a/pilot/pkg/networking/core/v1alpha3/listener_builder_test.go b/pilot/pkg/networking/core/v1alpha3/listener_builder_test.go index 1e3f0d688847..fa204ae594a9 100644 --- a/pilot/pkg/networking/core/v1alpha3/listener_builder_test.go +++ b/pilot/pkg/networking/core/v1alpha3/listener_builder_test.go @@ -42,7 +42,7 @@ func getDefaultProxy() model.Proxy { DNSDomain: "default.example.org", Metadata: map[string]string{ model.NodeMetadataConfigNamespace: "not-default", - "ISTIO_PROXY_VERSION": "1.1", + "ISTIO_VERSION": "1.3", }, ConfigNamespace: "not-default", } diff --git a/pilot/pkg/networking/core/v1alpha3/listener_test.go b/pilot/pkg/networking/core/v1alpha3/listener_test.go index 72d1fee50b09..4d63a00235b3 100644 --- a/pilot/pkg/networking/core/v1alpha3/listener_test.go +++ b/pilot/pkg/networking/core/v1alpha3/listener_test.go @@ -54,7 +54,7 @@ var ( DNSDomain: "default.example.org", Metadata: map[string]string{ model.NodeMetadataConfigNamespace: "not-default", - "ISTIO_PROXY_VERSION": "1.1", + "ISTIO_VERSION": "1.3", }, ConfigNamespace: "not-default", } @@ -65,7 +65,7 @@ var ( DNSDomain: "default.example.org", Metadata: map[string]string{ model.NodeMetadataConfigNamespace: "not-default", - "ISTIO_PROXY_VERSION": "1.1", + "ISTIO_VERSION": "1.3", model.NodeMetadataHTTP10: "1", }, ConfigNamespace: "not-default", diff --git a/pilot/pkg/networking/core/v1alpha3/networkfilter.go b/pilot/pkg/networking/core/v1alpha3/networkfilter.go index 7f43b9bd3937..3a880031d029 100644 --- a/pilot/pkg/networking/core/v1alpha3/networkfilter.go +++ b/pilot/pkg/networking/core/v1alpha3/networkfilter.go @@ -64,9 +64,8 @@ func setAccessLog(env *model.Environment, node *model.Proxy, config *tcp_proxy.T acc := &accesslog.AccessLog{ Name: xdsutil.FileAccessLog, } - if util.IsProxyVersionGE11(node) { - buildAccessLog(fl, env) - } + buildAccessLog(fl, env) + if util.IsXDSMarshalingToAnyEnabled(node) { acc.ConfigType = &accesslog.AccessLog_TypedConfig{TypedConfig: util.MessageToAny(fl)} } else { @@ -187,14 +186,14 @@ func buildNetworkFiltersStack(node *model.Proxy, port *model.Port, tcpFilter *li case protocol.Mongo: filterstack = append(filterstack, buildMongoFilter(statPrefix, util.IsXDSMarshalingToAnyEnabled(node)), tcpFilter) case protocol.Redis: - if util.IsProxyVersionGE11(node) && features.EnableRedisFilter.Get() { + if features.EnableRedisFilter.Get() { // redis filter has route config, it is a terminating filter, no need append tcp filter. filterstack = append(filterstack, buildRedisFilter(statPrefix, clusterName, util.IsXDSMarshalingToAnyEnabled(node))) } else { filterstack = append(filterstack, tcpFilter) } case protocol.MySQL: - if util.IsProxyVersionGE11(node) && features.EnableMysqlFilter.Get() { + if features.EnableMysqlFilter.Get() { filterstack = append(filterstack, buildMySQLFilter(statPrefix, util.IsXDSMarshalingToAnyEnabled(node))) } filterstack = append(filterstack, tcpFilter) @@ -212,7 +211,7 @@ func buildOutboundNetworkFilters(env *model.Environment, node *model.Proxy, routes []*networking.RouteDestination, push *model.PushContext, port *model.Port, configMeta model.ConfigMeta) []*listener.Filter { - if !util.IsProxyVersionGE11(node) || len(routes) == 1 { + if len(routes) == 1 { service := node.SidecarScope.ServiceForHostname(config.Hostname(routes[0].Destination.Host), push.ServiceByHostnameAndNamespace) clusterName := istio_route.GetDestinationCluster(routes[0].Destination, service, port.Port) return buildOutboundNetworkFiltersWithSingleDestination(env, node, clusterName, port) diff --git a/pilot/pkg/networking/core/v1alpha3/route/route.go b/pilot/pkg/networking/core/v1alpha3/route/route.go index 68f5c49a0840..a81a7dfdd0fa 100644 --- a/pilot/pkg/networking/core/v1alpha3/route/route.go +++ b/pilot/pkg/networking/core/v1alpha3/route/route.go @@ -619,7 +619,7 @@ func translateHeaderMatch(name string, in *networking.StringMatch) route.HeaderM } // translateCORSPolicy translates CORS policy -func translateCORSPolicy(in *networking.CorsPolicy, node *model.Proxy) *route.CorsPolicy { +func translateCORSPolicy(in *networking.CorsPolicy, _ *model.Proxy) *route.CorsPolicy { if in == nil { return nil } @@ -629,17 +629,13 @@ func translateCORSPolicy(in *networking.CorsPolicy, node *model.Proxy) *route.Co AllowOrigin: in.AllowOrigin, } - if util.IsProxyVersionGE11(node) { - out.EnabledSpecifier = &route.CorsPolicy_FilterEnabled{ - FilterEnabled: &core.RuntimeFractionalPercent{ - DefaultValue: &xdstype.FractionalPercent{ - Numerator: 100, - Denominator: xdstype.FractionalPercent_HUNDRED, - }, + out.EnabledSpecifier = &route.CorsPolicy_FilterEnabled{ + FilterEnabled: &core.RuntimeFractionalPercent{ + DefaultValue: &xdstype.FractionalPercent{ + Numerator: 100, + Denominator: xdstype.FractionalPercent_HUNDRED, }, - } - } else { - out.EnabledSpecifier = &route.CorsPolicy_Enabled{Enabled: &types.BoolValue{Value: true}} + }, } out.AllowCredentials = in.AllowCredentials diff --git a/pilot/pkg/networking/core/v1alpha3/route/route_test.go b/pilot/pkg/networking/core/v1alpha3/route/route_test.go index 4f4b15cf98a7..3a949176534c 100644 --- a/pilot/pkg/networking/core/v1alpha3/route/route_test.go +++ b/pilot/pkg/networking/core/v1alpha3/route/route_test.go @@ -52,7 +52,7 @@ func TestBuildHTTPRoutes(t *testing.T) { IPAddresses: []string{"1.1.1.1"}, ID: "someID", DNSDomain: "foo.com", - Metadata: map[string]string{"ISTIO_PROXY_VERSION": "1.1"}, + Metadata: map[string]string{"ISTIO_VERSION": "1.3"}, } gatewayNames := map[string]bool{"some-gateway": true} diff --git a/pilot/pkg/networking/util/util.go b/pilot/pkg/networking/util/util.go index 90b0c139c3eb..896e87b95b97 100644 --- a/pilot/pkg/networking/util/util.go +++ b/pilot/pkg/networking/util/util.go @@ -261,15 +261,19 @@ func SortVirtualHosts(hosts []*route.VirtualHost) { }) } -// IsProxyVersionGE11 checks whether the given Proxy version is greater than or equals 1.1. -func IsProxyVersionGE11(node *model.Proxy) bool { - ver, _ := node.GetProxyVersion() - return ver >= "1.1" +// IsIstioVersionGE12 checks whether the given Istio version is greater than or equals 1.2. +func IsIstioVersionGE12(node *model.Proxy) bool { + return node.IstioVersion.Compare(&model.IstioVersion{Major: 1, Minor: 2, Patch: -1}) >= 0 +} + +// IsIstioVersionGE13 checks whether the given Istio version is greater than or equals 1.3. +func IsIstioVersionGE13(node *model.Proxy) bool { + return node.IstioVersion.Compare(&model.IstioVersion{Major: 1, Minor: 3, Patch: -1}) >= 0 } // IsXDSMarshalingToAnyEnabled controls whether "marshaling to Any" feature is enabled. func IsXDSMarshalingToAnyEnabled(node *model.Proxy) bool { - return IsProxyVersionGE11(node) && !features.DisableXDSMarshalingToAny + return !features.DisableXDSMarshalingToAny } // ResolveHostsInNetworksConfig will go through the Gateways addresses for all diff --git a/pilot/pkg/networking/util/util_test.go b/pilot/pkg/networking/util/util_test.go index 0c627f732989..9ada8014bbeb 100644 --- a/pilot/pkg/networking/util/util_test.go +++ b/pilot/pkg/networking/util/util_test.go @@ -126,76 +126,6 @@ func TestGetNetworkEndpointAddress(t *testing.T) { } } -func TestIsProxyVersionGE11(t *testing.T) { - tests := []struct { - name string - node *model.Proxy - want bool - }{ - { - "the given Proxy version is 1.x", - &model.Proxy{ - Metadata: map[string]string{ - "ISTIO_PROXY_VERSION": "1.0", - }, - }, - false, - }, - { - "the given Proxy version is not 1.x", - &model.Proxy{ - Metadata: map[string]string{ - "ISTIO_PROXY_VERSION": "0.8", - }, - }, - false, - }, - { - "the given Proxy version is 1.1", - &model.Proxy{ - Metadata: map[string]string{ - "ISTIO_PROXY_VERSION": "1.1", - }, - }, - true, - }, - { - "the given Proxy version is 1.1.1", - &model.Proxy{ - Metadata: map[string]string{ - "ISTIO_PROXY_VERSION": "1.1.1", - }, - }, - true, - }, - { - "the given Proxy version is 2.0", - &model.Proxy{ - Metadata: map[string]string{ - "ISTIO_PROXY_VERSION": "2.0", - }, - }, - true, - }, - { - "the given Proxy version is 10.0", - &model.Proxy{ - Metadata: map[string]string{ - "ISTIO_PROXY_VERSION": "2.0", - }, - }, - true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := IsProxyVersionGE11(tt.node); got != tt.want { - t.Errorf("IsProxyVersionGE11() = %v, want %v", got, tt.want) - } - }) - } -} - func TestResolveHostsInNetworksConfig(t *testing.T) { tests := []struct { name string diff --git a/pilot/pkg/proxy/envoy/v2/debug.go b/pilot/pkg/proxy/envoy/v2/debug.go index 2548386d4a0e..bba4dacedf9e 100644 --- a/pilot/pkg/proxy/envoy/v2/debug.go +++ b/pilot/pkg/proxy/envoy/v2/debug.go @@ -89,11 +89,9 @@ func Syncz(w http.ResponseWriter, _ *http.Request) { for _, con := range adsClients { con.mu.RLock() if con.modelNode != nil { - proxyVersion, _ := con.modelNode.GetProxyVersion() istioVersion, _ := con.modelNode.GetIstioVersion() syncz = append(syncz, SyncStatus{ ProxyID: con.modelNode.ID, - ProxyVersion: proxyVersion, IstioVersion: istioVersion, ClusterSent: con.ClusterNonceSent, ClusterAcked: con.ClusterNonceAcked, diff --git a/pilot/pkg/proxy/envoy/v2/eds_sh_test.go b/pilot/pkg/proxy/envoy/v2/eds_sh_test.go index bc8f43126ace..7eaaf279b057 100644 --- a/pilot/pkg/proxy/envoy/v2/eds_sh_test.go +++ b/pilot/pkg/proxy/envoy/v2/eds_sh_test.go @@ -155,8 +155,8 @@ func verifySplitHorizonResponse(t *testing.T, network string, sidecarID string, defer cancel() metadata := &proto.Struct{Fields: map[string]*proto.Value{ - "ISTIO_PROXY_VERSION": {Kind: &proto.Value_StringValue{StringValue: "1.1"}}, - "NETWORK": {Kind: &proto.Value_StringValue{StringValue: network}}, + "ISTIO_VERSION": {Kind: &proto.Value_StringValue{StringValue: "1.3"}}, + "NETWORK": {Kind: &proto.Value_StringValue{StringValue: network}}, }} err = sendCDSReqWithMetadata(sidecarID, metadata, edsstr) diff --git a/pilot/pkg/proxy/envoy/v2/init_test.go b/pilot/pkg/proxy/envoy/v2/init_test.go index 699ba7db1aeb..d0baa2a7e41e 100644 --- a/pilot/pkg/proxy/envoy/v2/init_test.go +++ b/pilot/pkg/proxy/envoy/v2/init_test.go @@ -39,7 +39,7 @@ import ( ) var nodeMetadata = &proto.Struct{Fields: map[string]*proto.Value{ - "ISTIO_PROXY_VERSION": {Kind: &proto.Value_StringValue{StringValue: "1.1"}}, // actual value doesn't matter + "ISTIO_VERSION": {Kind: &proto.Value_StringValue{StringValue: "1.3"}}, // actual value doesn't matter }} // Extract cluster load assignment from a discovery response. diff --git a/pilot/pkg/proxy/envoy/v2/lds_test.go b/pilot/pkg/proxy/envoy/v2/lds_test.go index c7e315fe411b..aa61fa180e9e 100644 --- a/pilot/pkg/proxy/envoy/v2/lds_test.go +++ b/pilot/pkg/proxy/envoy/v2/lds_test.go @@ -209,9 +209,9 @@ func TestLDSWithDefaultSidecar(t *testing.T) { adsResponse, err := adsc.Dial(util.MockPilotGrpcAddr, "", &adsc.Config{ Meta: map[string]string{ - model.NodeMetadataConfigNamespace: "ns1", - model.NodeMetadataInstanceIPs: "100.1.1.2", // as service instance of http2.ns1 - model.NodeMetadataIstioProxyVersion: "1.1.0", + model.NodeMetadataConfigNamespace: "ns1", + model.NodeMetadataInstanceIPs: "100.1.1.2", // as service instance of http2.ns1 + model.NodeMetadataIstioVersion: "1.3.0", }, IP: "100.1.1.2", Namespace: "ns1", @@ -281,9 +281,9 @@ func TestLDSWithIngressGateway(t *testing.T) { adsResponse, err := adsc.Dial(util.MockPilotGrpcAddr, "", &adsc.Config{ Meta: map[string]string{ - model.NodeMetadataConfigNamespace: "istio-system", - model.NodeMetadataInstanceIPs: "99.1.1.1", // as service instance of ingress gateway - model.NodeMetadataIstioProxyVersion: "1.1.0", + model.NodeMetadataConfigNamespace: "istio-system", + model.NodeMetadataInstanceIPs: "99.1.1.1", // as service instance of ingress gateway + model.NodeMetadataIstioVersion: "1.3.0", }, IP: "99.1.1.1", Namespace: "istio-system", @@ -407,9 +407,9 @@ func TestLDSWithSidecarForWorkloadWithoutService(t *testing.T) { adsResponse, err := adsc.Dial(util.MockPilotGrpcAddr, "", &adsc.Config{ Meta: map[string]string{ - model.NodeMetadataConfigNamespace: "consumerns", - model.NodeMetadataInstanceIPs: "98.1.1.1", // as service instance of ingress gateway - model.NodeMetadataIstioProxyVersion: "1.1.0", + model.NodeMetadataConfigNamespace: "consumerns", + model.NodeMetadataInstanceIPs: "98.1.1.1", // as service instance of ingress gateway + model.NodeMetadataIstioVersion: "1.3.0", }, IP: "98.1.1.1", Namespace: "consumerns", // namespace must match the namespace of the sidecar in the configs.yaml @@ -510,9 +510,9 @@ func TestLDSEnvoyFilterWithWorkloadSelector(t *testing.T) { t.Run(test.name, func(t *testing.T) { adsResponse, err := adsc.Dial(util.MockPilotGrpcAddr, "", &adsc.Config{ Meta: map[string]string{ - model.NodeMetadataConfigNamespace: "consumerns", - model.NodeMetadataInstanceIPs: test.ip, // as service instance of ingress gateway - model.NodeMetadataIstioProxyVersion: "1.1.0", + model.NodeMetadataConfigNamespace: "consumerns", + model.NodeMetadataInstanceIPs: test.ip, // as service instance of ingress gateway + model.NodeMetadataIstioVersion: "1.3.0", }, IP: test.ip, Namespace: "consumerns", // namespace must match the namespace of the sidecar in the configs.yaml diff --git a/pilot/pkg/proxy/envoy/v2/xds_test.go b/pilot/pkg/proxy/envoy/v2/xds_test.go index 1f3a70c90d47..dd58bc2d3ff9 100644 --- a/pilot/pkg/proxy/envoy/v2/xds_test.go +++ b/pilot/pkg/proxy/envoy/v2/xds_test.go @@ -109,7 +109,7 @@ func startEnvoy(t *testing.T) { "NodeID": nodeID, "BaseDir": env.IstioSrc + "/tests/testdata/local", // Same value used in the real template - "meta_json_str": fmt.Sprintf(`"BASE": "%s", ISTIO_PROXY_VERSION: 1.1.3`, env.IstioSrc+"/tests/testdata/local"), + "meta_json_str": fmt.Sprintf(`"BASE": "%s", ISTIO_VERSION: 1.3.0`, env.IstioSrc+"/tests/testdata/local"), } // Mixer will push stats every 1 sec diff --git a/pilot/pkg/serviceregistry/memory/discovery_mock.go b/pilot/pkg/serviceregistry/memory/discovery_mock.go index d62c052f605a..b7fa36e10150 100644 --- a/pilot/pkg/serviceregistry/memory/discovery_mock.go +++ b/pilot/pkg/serviceregistry/memory/discovery_mock.go @@ -41,10 +41,11 @@ var ( // HelloProxyV0 is a mock proxy v0 of HelloService HelloProxyV0 = model.Proxy{ - Type: model.SidecarProxy, - IPAddresses: []string{HelloInstanceV0}, - ID: "v0.default", - DNSDomain: "default.svc.cluster.local", + Type: model.SidecarProxy, + IPAddresses: []string{HelloInstanceV0}, + ID: "v0.default", + DNSDomain: "default.svc.cluster.local", + IstioVersion: model.MaxIstioVersion, } // MockDiscovery is an in-memory ServiceDiscover with mock services diff --git a/pkg/adsc/adsc.go b/pkg/adsc/adsc.go index 53e4fb9cbca6..1436ebeca6ee 100644 --- a/pkg/adsc/adsc.go +++ b/pkg/adsc/adsc.go @@ -502,7 +502,7 @@ func (a *ADSC) node() *core.Node { if a.Metadata == nil { n.Metadata = &types.Struct{ Fields: map[string]*types.Value{ - "ISTIO_PROXY_VERSION": {Kind: &types.Value_StringValue{StringValue: "1.0"}}, + "ISTIO_VERSION": {Kind: &types.Value_StringValue{StringValue: "65536.65536.65536"}}, }} } else { f := map[string]*types.Value{} diff --git a/pkg/bootstrap/bootstrap_config_test.go b/pkg/bootstrap/bootstrap_config_test.go index fc78a635a13b..342caff43a55 100644 --- a/pkg/bootstrap/bootstrap_config_test.go +++ b/pkg/bootstrap/bootstrap_config_test.go @@ -100,15 +100,14 @@ func TestGolden(t *testing.T) { { base: "running", envVars: map[string]string{ - "ISTIO_META_ISTIO_PROXY_SHA": "istio-proxy:sha", - "ISTIO_META_INTERCEPTION_MODE": "REDIRECT", - "ISTIO_META_ISTIO_PROXY_VERSION": "istio-proxy:version", - "ISTIO_META_ISTIO_VERSION": "release-3.1", - "ISTIO_META_POD_NAME": "svc-0-0-0-6944fb884d-4pgx8", - "POD_NAME": "svc-0-0-0-6944fb884d-4pgx8", - "POD_NAMESPACE": "test", - "INSTANCE_IP": "10.10.10.1", - "ISTIO_METAJSON_LABELS": `{"version": "v1alpha1", "app": "test", "istio-locality":"regionA.zoneB.sub_zoneC"}`, + "ISTIO_META_ISTIO_PROXY_SHA": "istio-proxy:sha", + "ISTIO_META_INTERCEPTION_MODE": "REDIRECT", + "ISTIO_META_ISTIO_VERSION": "release-3.1", + "ISTIO_META_POD_NAME": "svc-0-0-0-6944fb884d-4pgx8", + "POD_NAME": "svc-0-0-0-6944fb884d-4pgx8", + "POD_NAMESPACE": "test", + "INSTANCE_IP": "10.10.10.1", + "ISTIO_METAJSON_LABELS": `{"version": "v1alpha1", "app": "test", "istio-locality":"regionA.zoneB.sub_zoneC"}`, }, annotations: map[string]string{ "istio.io/insecurepath": "{\"paths\":[\"/metrics\",\"/live\"]}", diff --git a/pkg/bootstrap/testdata/running_golden.json b/pkg/bootstrap/testdata/running_golden.json index d71f8d44a407..3f875ad6d8fe 100644 --- a/pkg/bootstrap/testdata/running_golden.json +++ b/pkg/bootstrap/testdata/running_golden.json @@ -13,7 +13,6 @@ "INSTANCE_IPS":"10.3.3.3,10.4.4.4,10.5.5.5,10.6.6.6", "INTERCEPTION_MODE":"REDIRECT", "ISTIO_PROXY_SHA":"istio-proxy:sha", - "ISTIO_PROXY_VERSION":"istio-proxy:version", "ISTIO_VERSION":"release-3.1", "POD_NAME":"svc-0-0-0-6944fb884d-4pgx8", "ISTIO_META_SDS": "1", diff --git a/pkg/test/framework/components/echo/common/testdata/config_dump.json b/pkg/test/framework/components/echo/common/testdata/config_dump.json index 148ab8937ffd..d03b19093b54 100644 --- a/pkg/test/framework/components/echo/common/testdata/config_dump.json +++ b/pkg/test/framework/components/echo/common/testdata/config_dump.json @@ -17,7 +17,6 @@ "INSTANCE_IPS": "10.40.3.59,10.40.3.59,fe80::7cf5:f9ff:fe8f:48bb", "POD_NAME": "a-6bb6dbdcc5-z58cx", "istio": "sidecar", - "ISTIO_PROXY_VERSION": "1.1.0", "ISTIO_PROXY_SHA": "istio-proxy:ecbd1731cedc5d373766ea6e2f1c2e58623b0e28" }, "locality": { diff --git a/tests/integration/pilot/sidecar_api_test.go b/tests/integration/pilot/sidecar_api_test.go index 6a2b92c8d970..3c218ac43f55 100644 --- a/tests/integration/pilot/sidecar_api_test.go +++ b/tests/integration/pilot/sidecar_api_test.go @@ -37,11 +37,12 @@ func TestSidecarListeners(t *testing.T) { // Simulate proxy identity of a sidecar ... nodeID := &model.Proxy{ - ClusterID: "integration-test", - Type: model.SidecarProxy, - IPAddresses: []string{"10.2.0.1"}, - ID: "app3.testns", - DNSDomain: "testns.cluster.local", + ClusterID: "integration-test", + Type: model.SidecarProxy, + IPAddresses: []string{"10.2.0.1"}, + ID: "app3.testns", + DNSDomain: "testns.cluster.local", + IstioVersion: model.MaxIstioVersion, } // Start the xDS stream containing the listeners for this node @@ -92,7 +93,7 @@ func validateListenersNoConfig(t *testing.T, response *structpath.Instance) { Equals("virtualOutbound", "{.name}"). Equals("0.0.0.0", "{.address.socketAddress.address}"). Equals("envoy.tcp_proxy", "{.filterChains[0].filters[0].name}"). - Equals("BlackHoleCluster", "{.filterChains[0].filters[0].config.cluster}"). + Equals("BlackHoleCluster", "{.filterChains[0].filters[0].typedConfig.cluster}"). Equals("10.2.0.1", "{.filterChains[0].filterChainMatch.prefixRanges[0].addressPrefix}"). Equals("32", "{.filterChains[0].filterChainMatch.prefixRanges[0].prefixLen}"). Equals(true, "{.useOriginalDst}"). @@ -106,8 +107,8 @@ func validateListenersNoConfig(t *testing.T, response *structpath.Instance) { Equals("0.0.0.0", "{.address.socketAddress.address}"). Equals("mixer", "{.filterChains[1].filters[0].name}"). Equals("envoy.tcp_proxy", "{.filterChains[1].filters[1].name}"). - Equals("PassthroughCluster", "{.filterChains[1].filters[1].config.cluster}"). - Equals("PassthroughCluster", "{.filterChains[1].filters[1].config.stat_prefix}"). + Equals("PassthroughCluster", "{.filterChains[1].filters[1].typedConfig.cluster}"). + Equals("PassthroughCluster", "{.filterChains[1].filters[1].typedConfig.statPrefix}"). Equals(true, "{.useOriginalDst}"). CheckOrFail(t) }) diff --git a/tools/packaging/common/istio-start.sh b/tools/packaging/common/istio-start.sh index bf8acd60a113..ddefd464fc0f 100755 --- a/tools/packaging/common/istio-start.sh +++ b/tools/packaging/common/istio-start.sh @@ -21,7 +21,7 @@ set -e # Match pilot/docker/Dockerfile.proxyv2 -export ISTIO_META_ISTIO_PROXY_VERSION="1.1.3" +export ISTIO_META_ISTIO_VERSION="1.3.0" # Set defaults ISTIO_BIN_BASE=${ISTIO_BIN_BASE:-/usr/local/bin}