From e149125eaa94abd0893105c079f3a37fcf6552c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Carreira?= Date: Thu, 19 Nov 2020 15:31:18 +0000 Subject: [PATCH 1/5] validate if its an ARN --- pkg/apis/appmesh/v1beta2/types.go | 4 +++- pkg/router/appmesh_v1beta2.go | 21 ++++++++++++++++----- pkg/router/appmesh_v1beta2_test.go | 4 ++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/pkg/apis/appmesh/v1beta2/types.go b/pkg/apis/appmesh/v1beta2/types.go index a94cfa83..570f612f 100644 --- a/pkg/apis/appmesh/v1beta2/types.go +++ b/pkg/apis/appmesh/v1beta2/types.go @@ -57,7 +57,9 @@ type VirtualServiceReference struct { // +optional Namespace *string `json:"namespace,omitempty"` // Name is the name of VirtualService CR - Name string `json:"name"` + Name string `json:"name,omitempty"` + // ARN of the AWS VirtualService CR + ARN string `json:"virtualServiceARN,omitempty"` } // VirtualRouterReference holds a reference to VirtualRouter.appmesh.k8s.aws diff --git a/pkg/router/appmesh_v1beta2.go b/pkg/router/appmesh_v1beta2.go index cf106eb4..4dd24ee5 100644 --- a/pkg/router/appmesh_v1beta2.go +++ b/pkg/router/appmesh_v1beta2.go @@ -104,12 +104,23 @@ func (ar *AppMeshv1beta2Router) reconcileVirtualNode(canary *flaggerv1.Canary, n backends := make([]appmeshv1.Backend, 0) for _, b := range canary.Spec.Service.Backends { - bk := appmeshv1.Backend{ - VirtualService: appmeshv1.VirtualServiceBackend{ - VirtualServiceRef: appmeshv1.VirtualServiceReference{ - Name: b, + var bk appmeshv1.Backend + if b[:6] == "arn:aws" { + bk = appmeshv1.Backend{ + VirtualService: appmeshv1.VirtualServiceBackend{ + VirtualServiceRef: appmeshv1.VirtualServiceReference{ + ARN: b, + }, }, - }, + } + } else { + bk = appmeshv1.Backend{ + VirtualService: appmeshv1.VirtualServiceBackend{ + VirtualServiceRef: appmeshv1.VirtualServiceReference{ + Name: b, + }, + }, + } } backends = append(backends, bk) } diff --git a/pkg/router/appmesh_v1beta2_test.go b/pkg/router/appmesh_v1beta2_test.go index d01b216c..473a368d 100644 --- a/pkg/router/appmesh_v1beta2_test.go +++ b/pkg/router/appmesh_v1beta2_test.go @@ -66,7 +66,7 @@ func TestAppmeshv1beta2Router_Reconcile(t *testing.T) { cdClone := cd.DeepCopy() backends := cdClone.Spec.Service.Backends - backends = append(backends, "test.example.com") + backends = append(backends, "test.example.com", "arn:aws:appmesh:eu-west-1:12345678910:mesh/my-mesh/virtualService/mytestservice") cdClone.Spec.Service.Backends = backends canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cdClone, metav1.UpdateOptions{}) require.NoError(t, err) @@ -78,7 +78,7 @@ func TestAppmeshv1beta2Router_Reconcile(t *testing.T) { // verify vnPrimary, err = router.appmeshClient.AppmeshV1beta2().VirtualNodes("default").Get(context.TODO(), primaryName, metav1.GetOptions{}) require.NoError(t, err) - require.Len(t, vnPrimary.Spec.Backends, 2) + require.Len(t, vnPrimary.Spec.Backends, 3) // update URI vrClone := vrApex.DeepCopy() From 7ab906189965d84cf0e8f6e97f86c35568fd8567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Carreira?= Date: Fri, 20 Nov 2020 10:33:25 +0000 Subject: [PATCH 2/5] Update AWS App Mesh types --- pkg/apis/appmesh/v1beta2/types.go | 37 +++- pkg/apis/appmesh/v1beta2/virtualnode_types.go | 73 ++++++- .../appmesh/v1beta2/virtualrouter_types.go | 24 ++- .../appmesh/v1beta2/virtualservice_types.go | 21 +- .../appmesh/v1beta2/zz_generated.deepcopy.go | 182 +++++++++++++++++- 5 files changed, 320 insertions(+), 17 deletions(-) diff --git a/pkg/apis/appmesh/v1beta2/types.go b/pkg/apis/appmesh/v1beta2/types.go index 570f612f..9cf3a22b 100644 --- a/pkg/apis/appmesh/v1beta2/types.go +++ b/pkg/apis/appmesh/v1beta2/types.go @@ -57,9 +57,7 @@ type VirtualServiceReference struct { // +optional Namespace *string `json:"namespace,omitempty"` // Name is the name of VirtualService CR - Name string `json:"name,omitempty"` - // ARN of the AWS VirtualService CR - ARN string `json:"virtualServiceARN,omitempty"` + Name string `json:"name"` } // VirtualRouterReference holds a reference to VirtualRouter.appmesh.k8s.aws @@ -115,3 +113,36 @@ type TCPTimeout struct { // +optional Idle *Duration `json:"idle,omitempty"` } + +type TCPConnectionPool struct { + // Represents the maximum number of outbound TCP connections + // the envoy can establish concurrently with all the hosts in the upstream cluster. + // +kubebuilder:validation:Minimum=1 + MaxConnections int64 `json:"maxConnections"` +} + +type HTTPConnectionPool struct { + // Represents the maximum number of outbound TCP connections + // the envoy can establish concurrently with all the hosts in the upstream cluster. + // +kubebuilder:validation:Minimum=1 + MaxConnections int64 `json:"maxConnections"` + // Represents the number of overflowing requests after max_connections + // that an envoy will queue to an upstream cluster. + // +kubebuilder:validation:Minimum=1 + // +optional + MaxPendingRequests *int64 `json:"maxPendingRequests,omitempty"` +} + +type HTTP2ConnectionPool struct { + // Represents the maximum number of inflight requests that an envoy + // can concurrently support across all the hosts in the upstream cluster + // +kubebuilder:validation:Minimum=1 + MaxRequests int64 `json:"maxRequests"` +} + +type GRPCConnectionPool struct { + // Represents the maximum number of inflight requests that an envoy + // can concurrently support across all the hosts in the upstream cluster + // +kubebuilder:validation:Minimum=1 + MaxRequests int64 `json:"maxRequests"` +} diff --git a/pkg/apis/appmesh/v1beta2/virtualnode_types.go b/pkg/apis/appmesh/v1beta2/virtualnode_types.go index 813806de..b01560e6 100644 --- a/pkg/apis/appmesh/v1beta2/virtualnode_types.go +++ b/pkg/apis/appmesh/v1beta2/virtualnode_types.go @@ -1,3 +1,19 @@ +/* + + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package v1beta2 import ( @@ -59,8 +75,12 @@ type ClientPolicy struct { // VirtualServiceBackend refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_VirtualServiceBackend.html type VirtualServiceBackend struct { - // The VirtualService that is acting as a virtual node backend. - VirtualServiceRef VirtualServiceReference `json:"virtualServiceRef"` + // Reference to Kubernetes VirtualService CR in cluster that is acting as a virtual node backend. Exactly one of 'virtualServiceRef' or 'virtualServiceARN' must be specified. + // +optional + VirtualServiceRef *VirtualServiceReference `json:"virtualServiceRef,omitempty"` + // Amazon Resource Name to AppMesh VirtualService object that is acting as a virtual node backend. Exactly one of 'virtualServiceRef' or 'virtualServiceARN' must be specified. + // +optional + VirtualServiceARN *string `json:"virtualServiceARN,omitempty"` // A reference to an object that represents the client policy for a backend. // +optional ClientPolicy *ClientPolicy `json:"clientPolicy,omitempty"` @@ -108,6 +128,25 @@ type HealthCheckPolicy struct { UnhealthyThreshold int64 `json:"unhealthyThreshold"` } +// OutlierDetection defines the health check policy that temporarily ejects an endpoint/host of a VirtualNode +// from the load balancing set when it meets failure threshold +type OutlierDetection struct { + // The threshold for the number of server errors returned by a given host during an outlier detection interval. + // If the server error count meets/exceeds this threshold the host is ejected. + // A server error is defined as any HTTP 5xx response (or the equivalent for gRPC and TCP connections) + // +kubebuilder:validation:Minimum=1 + MaxServerErrors int64 `json:"maxServerErrors"` + // The time interval between ejection analysis sweeps. This can result in both new ejections as well as hosts being returned to service + Interval Duration `json:"interval"` + // The base time that a host is ejected for. The real time is equal to the base time multiplied by the number of times the host has been ejected + BaseEjectionDuration Duration `json:"baseEjectionDuration"` + // The threshold for the max percentage of outlier hosts that can be ejected from the load balancing set. + // maxEjectionPercent=100 means outlier detection can potentially eject all of the hosts from the upstream service if they are all considered outliers, leaving the load balancing set with zero hosts + // +kubebuilder:validation:Minimum=0 + // +kubebuilder:validation:Maximum=100 + MaxEjectionPercent int64 `json:"maxEjectionPercent"` +} + // ListenerTLSACMCertificate refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_ListenerTlsAcmCertificate.html type ListenerTLSACMCertificate struct { // The Amazon Resource Name (ARN) for the certificate. @@ -169,6 +208,25 @@ type ListenerTimeout struct { GRPC *GRPCTimeout `json:"grpc,omitempty"` } +// VirtualNodeConnectionPool refers to the connection pools settings for Virtual Node. +// Connection pool limits the number of connections that an Envoy can concurrently establish with +// all the hosts in the upstream cluster. Currently connection pool is supported only at the listener +// level and it is intended protect your local application from being overwhelmed with connections. +type VirtualNodeConnectionPool struct { + // Specifies tcp connection pool settings for the virtual node listener + // +optional + TCP *TCPConnectionPool `json:"tcp,omitempty"` + // Specifies http connection pool settings for the virtual node listener + // +optional + HTTP *HTTPConnectionPool `json:"http,omitempty"` + // Specifies http2 connection pool settings for the virtual node listener + // +optional + HTTP2 *HTTP2ConnectionPool `json:"http2,omitempty"` + // Specifies grpc connection pool settings for the virtual node listener + // +optional + GRPC *GRPCConnectionPool `json:"grpc,omitempty"` +} + // Listener refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_Listener.html type Listener struct { // The port mapping information for the listener. @@ -176,6 +234,12 @@ type Listener struct { // The health check information for the listener. // +optional HealthCheck *HealthCheckPolicy `json:"healthCheck,omitempty"` + // The outlier detection for the listener + // +optional + OutlierDetection *OutlierDetection `json:"outlierDetection,omitempty"` + // The connection pool settings for the listener + // +optional + ConnectionPool *VirtualNodeConnectionPool `json:"connectionPool,omitempty"` // A reference to an object that represents the Transport Layer Security (TLS) properties for a listener. // +optional TLS *ListenerTLS `json:"tls,omitempty"` @@ -273,7 +337,7 @@ type VirtualNodeCondition struct { } // VirtualNodeSpec defines the desired state of VirtualNode -// refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_VirtualServiceSpec.html +// refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_VirtualNodeSpec.html type VirtualNodeSpec struct { // AWSName is the AppMesh VirtualNode object's name. // If unspecified or empty, it defaults to be "${name}_${namespace}" of k8s VirtualNode @@ -290,7 +354,8 @@ type VirtualNodeSpec struct { // +kubebuilder:validation:MaxItems=1 // +optional Listeners []Listener `json:"listeners,omitempty"` - // The service discovery information for the virtual node. + // The service discovery information for the virtual node. Optional if there is no + // inbound traffic(no listeners). Mandatory if a listener is specified. // +optional ServiceDiscovery *ServiceDiscovery `json:"serviceDiscovery,omitempty"` // The backends that the virtual node is expected to send outbound traffic to. diff --git a/pkg/apis/appmesh/v1beta2/virtualrouter_types.go b/pkg/apis/appmesh/v1beta2/virtualrouter_types.go index 3fe43d53..36a4df80 100644 --- a/pkg/apis/appmesh/v1beta2/virtualrouter_types.go +++ b/pkg/apis/appmesh/v1beta2/virtualrouter_types.go @@ -1,3 +1,19 @@ +/* + + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package v1beta2 import ( @@ -13,8 +29,12 @@ type VirtualRouterListener struct { // WeightedTarget refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_WeightedTarget.html type WeightedTarget struct { - // The virtual node to associate with the weighted target. - VirtualNodeRef VirtualNodeReference `json:"virtualNodeRef"` + // Reference to Kubernetes VirtualNode CR in cluster to associate with the weighted target. Exactly one of 'virtualNodeRef' or 'virtualNodeARN' must be specified. + // +optional + VirtualNodeRef *VirtualNodeReference `json:"virtualNodeRef,omitempty"` + // Amazon Resource Name to AppMesh VirtualNode object to associate with the weighted target. Exactly one of 'virtualNodeRef' or 'virtualNodeARN' must be specified. + // +optional + VirtualNodeARN *string `json:"virtualNodeARN,omitempty"` // The relative weight of the weighted target. // +kubebuilder:validation:Minimum=0 // +kubebuilder:validation:Maximum=100 diff --git a/pkg/apis/appmesh/v1beta2/virtualservice_types.go b/pkg/apis/appmesh/v1beta2/virtualservice_types.go index 2c7d9d51..b1467adf 100644 --- a/pkg/apis/appmesh/v1beta2/virtualservice_types.go +++ b/pkg/apis/appmesh/v1beta2/virtualservice_types.go @@ -23,14 +23,22 @@ import ( // VirtualNodeServiceProvider refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_VirtualNodeServiceProvider.html type VirtualNodeServiceProvider struct { - // The virtual node that is acting as a service provider. - VirtualNodeRef VirtualNodeReference `json:"virtualNodeRef"` + // Reference to Kubernetes VirtualNode CR in cluster that is acting as a service provider. Exactly one of 'virtualNodeRef' or 'virtualNodeARN' must be specified. + // +optional + VirtualNodeRef *VirtualNodeReference `json:"virtualNodeRef,omitempty"` + // Amazon Resource Name to AppMesh VirtualNode object that is acting as a service provider. Exactly one of 'virtualNodeRef' or 'virtualNodeARN' must be specified. + // +optional + VirtualNodeARN *string `json:"virtualNodeARN,omitempty"` } // VirtualRouterServiceProvider refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_VirtualRouterServiceProvider.html type VirtualRouterServiceProvider struct { - // The virtual router that is acting as a service provider. - VirtualRouterRef VirtualRouterReference `json:"virtualRouterRef"` + // Reference to Kubernetes VirtualRouter CR in cluster that is acting as a service provider. Exactly one of 'virtualRouterRef' or 'virtualRouterARN' must be specified. + // +optional + VirtualRouterRef *VirtualRouterReference `json:"virtualRouterRef,omitempty"` + // Amazon Resource Name to AppMesh VirtualRouter object that is acting as a service provider. Exactly one of 'virtualRouterRef' or 'virtualRouterARN' must be specified. + // +optional + VirtualRouterARN *string `json:"virtualRouterARN,omitempty"` } // VirtualServiceProvider refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_VirtualServiceProvider.html @@ -67,6 +75,7 @@ type VirtualServiceCondition struct { } // VirtualServiceSpec defines the desired state of VirtualService +// refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_VirtualServiceSpec.html type VirtualServiceSpec struct { // AWSName is the AppMesh VirtualService object's name. // If unspecified or empty, it defaults to be "${name}.${namespace}" of k8s VirtualService @@ -94,6 +103,10 @@ type VirtualServiceStatus struct { // The current VirtualService status. // +optional Conditions []VirtualServiceCondition `json:"conditions,omitempty"` + + // The generation observed by the VirtualService controller. + // +optional + ObservedGeneration *int64 `json:"observedGeneration,omitempty"` } // +genclient diff --git a/pkg/apis/appmesh/v1beta2/zz_generated.deepcopy.go b/pkg/apis/appmesh/v1beta2/zz_generated.deepcopy.go index 0faa568f..62cb3db2 100644 --- a/pkg/apis/appmesh/v1beta2/zz_generated.deepcopy.go +++ b/pkg/apis/appmesh/v1beta2/zz_generated.deepcopy.go @@ -217,6 +217,22 @@ func (in *FileAccessLog) DeepCopy() *FileAccessLog { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GRPCConnectionPool) DeepCopyInto(out *GRPCConnectionPool) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GRPCConnectionPool. +func (in *GRPCConnectionPool) DeepCopy() *GRPCConnectionPool { + if in == nil { + return nil + } + out := new(GRPCConnectionPool) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GRPCRetryPolicy) DeepCopyInto(out *GRPCRetryPolicy) { *out = *in @@ -426,6 +442,43 @@ func (in *GRPCTimeout) DeepCopy() *GRPCTimeout { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTP2ConnectionPool) DeepCopyInto(out *HTTP2ConnectionPool) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTP2ConnectionPool. +func (in *HTTP2ConnectionPool) DeepCopy() *HTTP2ConnectionPool { + if in == nil { + return nil + } + out := new(HTTP2ConnectionPool) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HTTPConnectionPool) DeepCopyInto(out *HTTPConnectionPool) { + *out = *in + if in.MaxPendingRequests != nil { + in, out := &in.MaxPendingRequests, &out.MaxPendingRequests + *out = new(int64) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPConnectionPool. +func (in *HTTPConnectionPool) DeepCopy() *HTTPConnectionPool { + if in == nil { + return nil + } + out := new(HTTPConnectionPool) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HTTPRetryPolicy) DeepCopyInto(out *HTTPRetryPolicy) { *out = *in @@ -665,6 +718,16 @@ func (in *Listener) DeepCopyInto(out *Listener) { *out = new(HealthCheckPolicy) (*in).DeepCopyInto(*out) } + if in.OutlierDetection != nil { + in, out := &in.OutlierDetection, &out.OutlierDetection + *out = new(OutlierDetection) + **out = **in + } + if in.ConnectionPool != nil { + in, out := &in.ConnectionPool, &out.ConnectionPool + *out = new(VirtualNodeConnectionPool) + (*in).DeepCopyInto(*out) + } if in.TLS != nil { in, out := &in.TLS, &out.TLS *out = new(ListenerTLS) @@ -852,6 +915,24 @@ func (in *MeshReference) DeepCopy() *MeshReference { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OutlierDetection) DeepCopyInto(out *OutlierDetection) { + *out = *in + out.Interval = in.Interval + out.BaseEjectionDuration = in.BaseEjectionDuration + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OutlierDetection. +func (in *OutlierDetection) DeepCopy() *OutlierDetection { + if in == nil { + return nil + } + out := new(OutlierDetection) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PortMapping) DeepCopyInto(out *PortMapping) { *out = *in @@ -935,6 +1016,22 @@ func (in *ServiceDiscovery) DeepCopy() *ServiceDiscovery { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TCPConnectionPool) DeepCopyInto(out *TCPConnectionPool) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TCPConnectionPool. +func (in *TCPConnectionPool) DeepCopy() *TCPConnectionPool { + if in == nil { + return nil + } + out := new(TCPConnectionPool) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TCPRoute) DeepCopyInto(out *TCPRoute) { *out = *in @@ -1160,6 +1257,42 @@ func (in *VirtualNodeCondition) DeepCopy() *VirtualNodeCondition { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualNodeConnectionPool) DeepCopyInto(out *VirtualNodeConnectionPool) { + *out = *in + if in.TCP != nil { + in, out := &in.TCP, &out.TCP + *out = new(TCPConnectionPool) + **out = **in + } + if in.HTTP != nil { + in, out := &in.HTTP, &out.HTTP + *out = new(HTTPConnectionPool) + (*in).DeepCopyInto(*out) + } + if in.HTTP2 != nil { + in, out := &in.HTTP2, &out.HTTP2 + *out = new(HTTP2ConnectionPool) + **out = **in + } + if in.GRPC != nil { + in, out := &in.GRPC, &out.GRPC + *out = new(GRPCConnectionPool) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualNodeConnectionPool. +func (in *VirtualNodeConnectionPool) DeepCopy() *VirtualNodeConnectionPool { + if in == nil { + return nil + } + out := new(VirtualNodeConnectionPool) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VirtualNodeList) DeepCopyInto(out *VirtualNodeList) { *out = *in @@ -1217,7 +1350,16 @@ func (in *VirtualNodeReference) DeepCopy() *VirtualNodeReference { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VirtualNodeServiceProvider) DeepCopyInto(out *VirtualNodeServiceProvider) { *out = *in - in.VirtualNodeRef.DeepCopyInto(&out.VirtualNodeRef) + if in.VirtualNodeRef != nil { + in, out := &in.VirtualNodeRef, &out.VirtualNodeRef + *out = new(VirtualNodeReference) + (*in).DeepCopyInto(*out) + } + if in.VirtualNodeARN != nil { + in, out := &in.VirtualNodeARN, &out.VirtualNodeARN + *out = new(string) + **out = **in + } return } @@ -1456,7 +1598,16 @@ func (in *VirtualRouterReference) DeepCopy() *VirtualRouterReference { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VirtualRouterServiceProvider) DeepCopyInto(out *VirtualRouterServiceProvider) { *out = *in - in.VirtualRouterRef.DeepCopyInto(&out.VirtualRouterRef) + if in.VirtualRouterRef != nil { + in, out := &in.VirtualRouterRef, &out.VirtualRouterRef + *out = new(VirtualRouterReference) + (*in).DeepCopyInto(*out) + } + if in.VirtualRouterARN != nil { + in, out := &in.VirtualRouterARN, &out.VirtualRouterARN + *out = new(string) + **out = **in + } return } @@ -1579,7 +1730,16 @@ func (in *VirtualService) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VirtualServiceBackend) DeepCopyInto(out *VirtualServiceBackend) { *out = *in - in.VirtualServiceRef.DeepCopyInto(&out.VirtualServiceRef) + if in.VirtualServiceRef != nil { + in, out := &in.VirtualServiceRef, &out.VirtualServiceRef + *out = new(VirtualServiceReference) + (*in).DeepCopyInto(*out) + } + if in.VirtualServiceARN != nil { + in, out := &in.VirtualServiceARN, &out.VirtualServiceARN + *out = new(string) + **out = **in + } if in.ClientPolicy != nil { in, out := &in.ClientPolicy, &out.ClientPolicy *out = new(ClientPolicy) @@ -1754,6 +1914,11 @@ func (in *VirtualServiceStatus) DeepCopyInto(out *VirtualServiceStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.ObservedGeneration != nil { + in, out := &in.ObservedGeneration, &out.ObservedGeneration + *out = new(int64) + **out = **in + } return } @@ -1770,7 +1935,16 @@ func (in *VirtualServiceStatus) DeepCopy() *VirtualServiceStatus { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WeightedTarget) DeepCopyInto(out *WeightedTarget) { *out = *in - in.VirtualNodeRef.DeepCopyInto(&out.VirtualNodeRef) + if in.VirtualNodeRef != nil { + in, out := &in.VirtualNodeRef, &out.VirtualNodeRef + *out = new(VirtualNodeReference) + (*in).DeepCopyInto(*out) + } + if in.VirtualNodeARN != nil { + in, out := &in.VirtualNodeARN, &out.VirtualNodeARN + *out = new(string) + **out = **in + } return } From a9c96fa8884f313e3e46623a34bbf9834c2a9a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Carreira?= Date: Fri, 20 Nov 2020 10:34:10 +0000 Subject: [PATCH 3/5] update th usage of App Mesh types --- pkg/router/appmesh_v1beta2.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/pkg/router/appmesh_v1beta2.go b/pkg/router/appmesh_v1beta2.go index 4dd24ee5..e5248577 100644 --- a/pkg/router/appmesh_v1beta2.go +++ b/pkg/router/appmesh_v1beta2.go @@ -108,15 +108,13 @@ func (ar *AppMeshv1beta2Router) reconcileVirtualNode(canary *flaggerv1.Canary, n if b[:6] == "arn:aws" { bk = appmeshv1.Backend{ VirtualService: appmeshv1.VirtualServiceBackend{ - VirtualServiceRef: appmeshv1.VirtualServiceReference{ - ARN: b, - }, + VirtualServiceARN: &b, }, } } else { bk = appmeshv1.Backend{ VirtualService: appmeshv1.VirtualServiceBackend{ - VirtualServiceRef: appmeshv1.VirtualServiceReference{ + VirtualServiceRef: &appmeshv1.VirtualServiceReference{ Name: b, }, }, @@ -211,13 +209,13 @@ func (ar *AppMeshv1beta2Router) reconcileVirtualRouter(canary *flaggerv1.Canary, Action: appmeshv1.HTTPRouteAction{ WeightedTargets: []appmeshv1.WeightedTarget{ { - VirtualNodeRef: appmeshv1.VirtualNodeReference{ + VirtualNodeRef: &appmeshv1.VirtualNodeReference{ Name: canaryVirtualNode, }, Weight: canaryWeight, }, { - VirtualNodeRef: appmeshv1.VirtualNodeReference{ + VirtualNodeRef: &appmeshv1.VirtualNodeReference{ Name: primaryVirtualNode, }, Weight: 100 - canaryWeight, @@ -244,13 +242,13 @@ func (ar *AppMeshv1beta2Router) reconcileVirtualRouter(canary *flaggerv1.Canary, Action: appmeshv1.HTTPRouteAction{ WeightedTargets: []appmeshv1.WeightedTarget{ { - VirtualNodeRef: appmeshv1.VirtualNodeReference{ + VirtualNodeRef: &appmeshv1.VirtualNodeReference{ Name: canaryVirtualNode, }, Weight: canaryWeight, }, { - VirtualNodeRef: appmeshv1.VirtualNodeReference{ + VirtualNodeRef: &appmeshv1.VirtualNodeReference{ Name: primaryVirtualNode, }, Weight: 100 - canaryWeight, @@ -271,7 +269,7 @@ func (ar *AppMeshv1beta2Router) reconcileVirtualRouter(canary *flaggerv1.Canary, Action: appmeshv1.HTTPRouteAction{ WeightedTargets: []appmeshv1.WeightedTarget{ { - VirtualNodeRef: appmeshv1.VirtualNodeReference{ + VirtualNodeRef: &appmeshv1.VirtualNodeReference{ Name: primaryVirtualNode, }, Weight: 100, @@ -336,7 +334,7 @@ func (ar *AppMeshv1beta2Router) reconcileVirtualRouter(canary *flaggerv1.Canary, Spec: appmeshv1.VirtualServiceSpec{ Provider: &appmeshv1.VirtualServiceProvider{ VirtualRouter: &appmeshv1.VirtualRouterServiceProvider{ - VirtualRouterRef: appmeshv1.VirtualRouterReference{ + VirtualRouterRef: &appmeshv1.VirtualRouterReference{ Name: name, }, }, @@ -442,13 +440,13 @@ func (ar *AppMeshv1beta2Router) SetRoutes( vrClone.Spec.Routes[0].HTTPRoute.Action = appmeshv1.HTTPRouteAction{ WeightedTargets: []appmeshv1.WeightedTarget{ { - VirtualNodeRef: appmeshv1.VirtualNodeReference{ + VirtualNodeRef: &appmeshv1.VirtualNodeReference{ Name: canaryName, }, Weight: int64(canaryWeight), }, { - VirtualNodeRef: appmeshv1.VirtualNodeReference{ + VirtualNodeRef: &appmeshv1.VirtualNodeReference{ Name: primaryName, }, Weight: int64(primaryWeight), From 5a856c98aa89cc004969e4680a83eaabfff227e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Carreira?= Date: Fri, 20 Nov 2020 10:43:28 +0000 Subject: [PATCH 4/5] Use strings.HasPrefix instead of manual count of prefix --- pkg/router/appmesh_v1beta2.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/router/appmesh_v1beta2.go b/pkg/router/appmesh_v1beta2.go index e5248577..248da14b 100644 --- a/pkg/router/appmesh_v1beta2.go +++ b/pkg/router/appmesh_v1beta2.go @@ -105,7 +105,7 @@ func (ar *AppMeshv1beta2Router) reconcileVirtualNode(canary *flaggerv1.Canary, n backends := make([]appmeshv1.Backend, 0) for _, b := range canary.Spec.Service.Backends { var bk appmeshv1.Backend - if b[:6] == "arn:aws" { + if strings.HasPrefix(b, "arn:aws") { bk = appmeshv1.Backend{ VirtualService: appmeshv1.VirtualServiceBackend{ VirtualServiceARN: &b, From 74efb784a25d2355d1f7ba3c414145089dcaa28b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Carreira?= Date: Fri, 20 Nov 2020 11:37:13 +0000 Subject: [PATCH 5/5] Update App Mesh guide with ARN usage in backends --- docs/gitbook/tutorials/appmesh-progressive-delivery.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/gitbook/tutorials/appmesh-progressive-delivery.md b/docs/gitbook/tutorials/appmesh-progressive-delivery.md index 8b822028..15f5ca95 100644 --- a/docs/gitbook/tutorials/appmesh-progressive-delivery.md +++ b/docs/gitbook/tutorials/appmesh-progressive-delivery.md @@ -180,7 +180,7 @@ create an App Mesh virtual service for it and add the virtual service name to th port: 9898 backends: - backend1 - - backend2 + - arn:aws:appmesh:eu-west-1:12345678910:mesh/my-mesh/virtualService/backend2 ``` ## Setup App Mesh Gateway (optional)