Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(appmesh): add listener timeout to Virtual Nodes #10793

Merged
merged 27 commits into from Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c0073e6
feat(aws-appmesh): adds listener timeout to Virtual Nodes
sshver Oct 5, 2020
97e1275
Update README.md to include listener timeout for Virtual Nodes
sshver Oct 8, 2020
03e012f
Added check to set timeout only for those protocol the listener uses
sshver Oct 13, 2020
3d3e09f
WIP - Adding VirtualNodeListener Class
sshver Oct 19, 2020
0046aa1
Added descriptive comments
sshver Oct 25, 2020
d4f136c
minor edits: added/updated comments and added/removed spaces where ev…
sshver Oct 26, 2020
c520b01
Fixed test after cherry-pick
sshver Oct 26, 2020
b348e42
Fixed code to make sure the build does not fail.
sshver Oct 26, 2020
2fe07eb
Fixed code to make sure the build does not fail.
sshver Oct 26, 2020
9d4f03b
Revert "Fixed code to make sure the build does not fail."
sshver Oct 27, 2020
b012bbb
addressed comments and removed dupilcations
sshver Oct 30, 2020
8c8c2ad
addressed comment
sshver Nov 2, 2020
8373e3c
Updated appmesh.ts to add listener based on protocol
sshver Nov 2, 2020
f220deb
Removing unused file from directory
sshver Nov 2, 2020
ae6ad41
Merge remote-tracking branch 'upstream/master' into feature/listenert…
sshver Nov 3, 2020
03b4c1f
- Updated test to remove unnecessary changes.
sshver Nov 5, 2020
6ff4b82
- Moved bind implementation to VirtualNodeListener.
sshver Nov 6, 2020
a167ae8
Removed addListeners and moved addListener and addBackends from IVirt…
sshver Nov 6, 2020
588b56b
Create addListener() and addBackend() method to accept a single liste…
sshver Nov 9, 2020
0d70cd7
Merge remote-tracking branch 'upstream/master' into feature/listenert…
sshver Nov 10, 2020
b67d48e
Removed unnecessary whitespaces
sshver Nov 10, 2020
a2138cd
Make the fields in VirtualNode private instead of protected
skinny85 Nov 10, 2020
caf3e7c
Merge branch 'master' into feature/listenertimeout
sshver Nov 10, 2020
be69829
Merge branch 'master' into feature/listenertimeout
skinny85 Nov 10, 2020
d35705f
Revert unnecessarily removed empty line in virtual-node.ts
skinny85 Nov 10, 2020
d8b049c
Merge branch 'master' into feature/listenertimeout
skinny85 Nov 11, 2020
cf15f6e
Merge branch 'master' into feature/listenertimeout
mergify[bot] Nov 11, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -259,17 +259,28 @@ export class AppMeshExtension extends ServiceExtension {
throw new Error('You must add a CloudMap namespace to the ECS cluster in order to use the AppMesh extension');
}

function addListener(protocol: appmesh.Protocol, port: number): appmesh.VirtualNodeListener {
switch (protocol) {
case appmesh.Protocol.HTTP :
return appmesh.VirtualNodeListener.http({ port });

case appmesh.Protocol.HTTP2 :
return appmesh.VirtualNodeListener.http2({ port });

case appmesh.Protocol.GRPC :
return appmesh.VirtualNodeListener.grpc({ port });

case appmesh.Protocol.TCP :
return appmesh.VirtualNodeListener.tcp({ port });
}
}

// Create a virtual node for the name service
this.virtualNode = new appmesh.VirtualNode(this.scope, `${this.parentService.id}-virtual-node`, {
mesh: this.mesh,
virtualNodeName: this.parentService.id,
cloudMapService: service.cloudMapService,
listener: {
portMapping: {
port: containerextension.trafficPort,
protocol: this.protocol,
},
},
listeners: [addListener(this.protocol, containerextension.trafficPort)],
});

// Create a virtual router for this service. This allows for retries
Expand Down
25 changes: 11 additions & 14 deletions packages/@aws-cdk/aws-appmesh/README.md
Expand Up @@ -143,11 +143,8 @@ const service = namespace.createService('Svc');

const node = mesh.addVirtualNode('virtual-node', {
cloudMapService: service,
listener: {
portMapping: {
port: 8081,
protocol: Protocol.HTTP,
},
listeners: [appmesh.VirtualNodeListener.httpNodeListener({
port: 8081,
healthCheck: {
healthyThreshold: 3,
interval: Duration.seconds(5), // minimum
Expand All @@ -157,9 +154,9 @@ const node = mesh.addVirtualNode('virtual-node', {
timeout: Duration.seconds(2), // minimum
unhealthyThreshold: 2,
},
},
})],
accessLog: appmesh.AccessLog.fromFilePath('/dev/stdout'),
})
});
```

Create a `VirtualNode` with the the constructor and add tags.
Expand All @@ -168,11 +165,8 @@ Create a `VirtualNode` with the the constructor and add tags.
const node = new VirtualNode(this, 'node', {
mesh,
cloudMapService: service,
listener: {
portMapping: {
port: 8080,
protocol: Protocol.HTTP,
},
listeners: [appmesh.VirtualNodeListener.httpNodeListener({
port: 8080,
healthCheck: {
healthyThreshold: 3,
interval: Duration.seconds(5), // min
Expand All @@ -181,15 +175,18 @@ const node = new VirtualNode(this, 'node', {
protocol: Protocol.HTTP,
timeout: Duration.seconds(2), // min
unhealthyThreshold: 2,
},
timeout: {
skinny85 marked this conversation as resolved.
Show resolved Hide resolved
idle: cdk.Duration.seconds(5),
},
},
})],
accessLog: appmesh.AccessLog.fromFilePath('/dev/stdout'),
});

cdk.Tag.add(node, 'Environment', 'Dev');
```

The listeners property can be left blank and added later with the `node.addListeners()` method. The `healthcheck` property is optional but if specifying a listener, the `portMappings` must contain at least one property.
The listeners property can be left blank and added later with the `node.addListeners()` method. The `healthcheck` and `timeout` properties are optional but if specifying a listener, the `port` must be added.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The listeners property can be left blank and added later with the `node.addListeners()` method. The `healthcheck` and `timeout` properties are optional but if specifying a listener, the `port` must be added.
The `listeners` property can be left blank and added later with the `node.addListener()` method. The `healthcheck` and `timeout` properties are optional but if specifying a listener, the `port` must be added.


## Adding a Route

Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-appmesh/lib/index.ts
Expand Up @@ -6,6 +6,7 @@ export * from './shared-interfaces';
export * from './virtual-node';
export * from './virtual-router';
export * from './virtual-service';
export * from './virtual-node-listener';
export * from './virtual-gateway';
export * from './virtual-gateway-listener';
export * from './gateway-route';
Expand Down
19 changes: 0 additions & 19 deletions packages/@aws-cdk/aws-appmesh/lib/shared-interfaces.ts
Expand Up @@ -87,25 +87,6 @@ export interface PortMapping {
readonly protocol: Protocol;
}

/**
* Represents the properties needed to define healthy and active listeners for nodes
*/
export interface VirtualNodeListener {
/**
* Array of PortMappingProps for the listener
*
* @default - HTTP port 8080
*/
readonly portMapping?: PortMapping;

/**
* Health checking strategy upstream nodes should use when communicating with the listener
*
* @default - no healthcheck
*/
readonly healthCheck?: HealthCheck;
}

skinny85 marked this conversation as resolved.
Show resolved Hide resolved
/**
* All Properties for Envoy Access logs for mesh endpoints
*/
Expand Down