Skip to content

Commit

Permalink
Merge pull request #611 from weaveworks/appmesh-timeout
Browse files Browse the repository at this point in the history
Implement App Mesh v1beta2 timeout
  • Loading branch information
stefanprodan authored Jun 8, 2020
2 parents 45d4d1f + 0715e1c commit bebfac8
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 101 deletions.
24 changes: 24 additions & 0 deletions pkg/apis/appmesh/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,27 @@ type VirtualGatewayReference struct {
// UID is the UID of VirtualGateway CR
UID types.UID `json:"uid"`
}

type HTTPTimeout struct {
// An object that represents per request timeout duration.
// +optional
PerRequest *Duration `json:"perRequest,omitempty"`
// An object that represents idle timeout duration.
// +optional
Idle *Duration `json:"idle,omitempty"`
}

type GRPCTimeout struct {
// An object that represents per request timeout duration.
// +optional
PerRequest *Duration `json:"perRequest,omitempty"`
// An object that represents idle timeout duration.
// +optional
Idle *Duration `json:"idle,omitempty"`
}

type TCPTimeout struct {
// An object that represents idle timeout duration.
// +optional
Idle *Duration `json:"idle,omitempty"`
}
59 changes: 30 additions & 29 deletions pkg/apis/appmesh/v1beta2/virtualnode_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,41 +82,30 @@ type BackendDefaults struct {
// HealthCheckPolicy refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_HealthCheckPolicy.html
type HealthCheckPolicy struct {
// The number of consecutive successful health checks that must occur before declaring listener healthy.
// If unspecified, defaults to be 10
// +kubebuilder:validation:Minimum=2
// +kubebuilder:validation:Maximum=10
// +optional
HealthyThreshold *int64 `json:"healthyThreshold,omitempty"`
HealthyThreshold int64 `json:"healthyThreshold"`
// The time period in milliseconds between each health check execution.
// If unspecified, defaults to be 30000
// +kubebuilder:validation:Minimum=5000
// +kubebuilder:validation:Maximum=300000
// +optional
IntervalMillis *int64 `json:"intervalMillis,omitempty"`
IntervalMillis int64 `json:"intervalMillis"`
// The destination path for the health check request.
// This value is only used if the specified protocol is http or http2. For any other protocol, this value is ignored.
// +optional
Path *string `json:"path,omitempty"`
// The destination port for the health check request.
// If unspecified, defaults to be same as port defined in the PortMapping for the listener.
// +optional
Port *PortNumber `json:"port,omitempty"`
// The protocol for the health check request
// If unspecified, defaults to be same as protocol defined in the PortMapping for the listener.
// +optional
Protocol *PortProtocol `json:"protocol,omitempty"`
Protocol PortProtocol `json:"protocol"`
// The amount of time to wait when receiving a response from the health check, in milliseconds.
// If unspecified, defaults to be 5000
// +kubebuilder:validation:Minimum=2000
// +kubebuilder:validation:Maximum=60000
// +optional
TimeoutMillis *int64 `json:"timeoutMillis,omitempty"`
TimeoutMillis int64 `json:"timeoutMillis"`
// The number of consecutive failed health checks that must occur before declaring a virtual node unhealthy.
// If unspecified, defaults to be 2
// +kubebuilder:validation:Minimum=2
// +kubebuilder:validation:Maximum=10
// +optional
UnhealthyThreshold *int64 `json:"unhealthyThreshold,omitempty"`
UnhealthyThreshold int64 `json:"unhealthyThreshold"`
}

// ListenerTLSACMCertificate refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_ListenerTlsAcmCertificate.html
Expand Down Expand Up @@ -164,6 +153,22 @@ type ListenerTLS struct {
Mode ListenerTLSMode `json:"mode"`
}

// ListenerTimeout refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_ListenerTimeout.html
type ListenerTimeout struct {
// Specifies tcp timeout information for the virtual node.
// +optional
TCP *TCPTimeout `json:"tcp,omitempty"`
// Specifies http timeout information for the virtual node.
// +optional
HTTP *HTTPTimeout `json:"http,omitempty"`
// Specifies http2 information for the virtual node.
// +optional
HTTP2 *HTTPTimeout `json:"http2,omitempty"`
// Specifies grpc timeout information for the virtual node.
// +optional
GRPC *GRPCTimeout `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.
Expand All @@ -174,6 +179,9 @@ type Listener struct {
// A reference to an object that represents the Transport Layer Security (TLS) properties for a listener.
// +optional
TLS *ListenerTLS `json:"tls,omitempty"`
// A reference to an object that represents
// +optional
Timeout *ListenerTimeout `json:"timeout,omitempty"`
}

// AWSCloudMapInstanceAttribute refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_AwsCloudMapInstanceAttribute.html
Expand Down Expand Up @@ -264,16 +272,6 @@ type VirtualNodeCondition struct {
Message *string `json:"message,omitempty"`
}

// AWSCloudMapServiceStatus is AWS CloudMap Service object's info
type AWSCloudMapServiceStatus struct {
// NamespaceID is AWS CloudMap Service object's namespace Id
// +optional
NamespaceID *string `json:"namespaceID,omitempty"`
// ServiceID is AWS CloudMap Service object's Id
// +optional
ServiceID *string `json:"serviceID,omitempty"`
}

// VirtualNodeSpec defines the desired state of VirtualNode
// refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_VirtualServiceSpec.html
type VirtualNodeSpec struct {
Expand All @@ -282,7 +280,9 @@ type VirtualNodeSpec struct {
// +optional
AWSName *string `json:"awsName,omitempty"`
// PodSelector selects Pods using labels to designate VirtualNode membership.
// if unspecified or empty, it selects no pods.
// This field follows standard label selector semantics:
// if present but empty, it selects all pods within namespace.
// if absent, it selects no pod.
// +optional
PodSelector *metav1.LabelSelector `json:"podSelector,omitempty"`
// The listener that the virtual node is expected to receive inbound traffic from
Expand Down Expand Up @@ -320,9 +320,10 @@ type VirtualNodeStatus struct {
// The current VirtualNode status.
// +optional
Conditions []VirtualNodeCondition `json:"conditions,omitempty"`
// AWSCloudMapServiceStatus is AWS CloudMap Service object's info

// The generation observed by the VirtualNode controller.
// +optional
AWSCloudMapServiceStatus *AWSCloudMapServiceStatus `json:"awsCloudMapServiceStatus,omitempty"`
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`
}

// +genclient
Expand Down
29 changes: 13 additions & 16 deletions pkg/apis/appmesh/v1beta2/virtualrouter_types.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/*
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 (
Expand Down Expand Up @@ -149,6 +133,9 @@ type HTTPRoute struct {
// An object that represents a retry policy.
// +optional
RetryPolicy *HTTPRetryPolicy `json:"retryPolicy,omitempty"`
// An object that represents a http timeout.
// +optional
Timeout *HTTPTimeout `json:"timeout,omitempty"`
}

// TCPRouteAction refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_TcpRouteAction.html
Expand All @@ -163,6 +150,9 @@ type TCPRouteAction struct {
type TCPRoute struct {
// The action to take if a match is determined.
Action TCPRouteAction `json:"action"`
// An object that represents a tcp timeout.
// +optional
Timeout *TCPTimeout `json:"timeout,omitempty"`
}

// GRPCRouteMetadataMatchMethod refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_GrpcRouteMetadataMatchMethod.html
Expand Down Expand Up @@ -261,6 +251,9 @@ type GRPCRoute struct {
// An object that represents a retry policy.
// +optional
RetryPolicy *GRPCRetryPolicy `json:"retryPolicy,omitempty"`
// An object that represents a grpc timeout.
// +optional
Timeout *GRPCTimeout `json:"timeout,omitempty"`
}

// Route refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_RouteSpec.html
Expand Down Expand Up @@ -345,6 +338,10 @@ type VirtualRouterStatus struct {
// The current VirtualRouter status.
// +optional
Conditions []VirtualRouterCondition `json:"conditions,omitempty"`

// The generation observed by the VirtualRouter controller.
// +optional
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`
}

// +genclient
Expand Down
Loading

0 comments on commit bebfac8

Please sign in to comment.