-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
AppMesh VirtualNode creation fails due to broken servicediscovery.Service.from_service_attributes call #4286
Comments
I'm much less experienced w/ CDK, but looking at the input
EDIT: also, the values that you would have for service_arn/service_id don't sound correct. I would expect service_arn/id to be the ones for the service, not the namespace. vs. the implementation of from_service_attributes
it looks like the namespace isn't actually getting retrieved? This appears to be a bug in servicediscovery and not the appmesh package. |
@dastbe I too thought the service_arn and service_id are related to service, but documentation says otherwise: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-servicediscovery.Service.html (see Properties) Regarding the namespace that isn't retrieved - you might be right, it could be also service discovery problem, not only AppMesh. However, there is also a discrepancy in documentation and implementation of AppMesh. In the example docs that I posted originally you can see that namespace name is provided as a parameter to Appmesh.addVirtualNode, but it disappeared from the implementation. Maybe it was there originally but was removed later on for some reason? |
@tsykora-verimatrix looking at the docs you referenced for addVirtualNode, what you replaced with It's always been the case that the cloudMapService should be a cloudmap service, and that object should encapsulate information about both the service and the namespace. The from_service_attributes call isn't resolving the namespace information, which is required. |
- Fix the missing initialization of `namespace` on CloudMap's `Service.fromServiceAttributes()`. - Expose the created CloudMap Service on ECS services so that `fromServiceAttributes()` doesn't need to be called at all. - Fix a number of property initialization errors across the library. Fixes #4286. BREAKING CHANGE: `cloudmap.Service.fromServiceAttributes` takes a newly required argument `namespace`.
Thank you for reporting the issue with I have rectified this in the linked PR. |
…ce (#4313) - Fix the missing initialization of `namespace` on CloudMap's `Service.fromServiceAttributes()`. - Expose the created CloudMap Service on ECS services so that `fromServiceAttributes()` doesn't need to be called at all. - Fix a number of property initialization errors across the library. Fixes #4286. BREAKING CHANGE: `cloudmap.Service.fromServiceAttributes` takes a newly required argument `namespace`.
Tldr version: It is not possible to create AppMesh VirtualNode in Fargate environment because CloudMap service is already created by
ecs.FargateService
andservicediscovery.Service.from_service_attributes
call to look up that CloudMap service is brokenDetailed description: When trying to create AppMesh VirtualNode using
servicediscovery.Service.from_service_attributes
ascloud_map_service
parameter forappmesh.VirtualNode
call we get the following error:jsii.errors.JSIIError: Cannot read property 'namespaceName' of undefined
Using method
servicediscovery.Service.from_service_attributes
to import existing CloudMap service rather than letting AppMesh to create a new service is common when working with Fargate. The reason is that theecs.FargateService
call is using parametercloud_map_options
to create a new CloudMap ServiceDiscovery Service. This is mandatory in order to register the FargateTasks with CloudMap. Since the CloudMap Service is created during creation of FargateService, the only option is to import existing CloudMap service when creating AppMesh VirtualNode. It is not possible to let AppMeshVirtualNode
to create that CloudMap service as it has been already created byecs.FargateService
. Moreover the object type inservicediscovery.Service
(required byappmesh.VirtualNode
) isIService
which is different toecs.FargateService
that is usingCloudMapOptions
type of object. So althought we need to reference the same CloudMap service, it has to be looked up instead of just referenced from previous step, however the lookup method is broken.By checking source code in aws_cdk/aws_appmesh/init.py we can see that namespaceName is not included in
class VirtualNode
norclass CfnVirtualNode
as parameter. Instead it is included in AwsCloudMapServiceDiscoveryProperty.In the TypeScript version of the documentation the same call to create a new VirtualNode namespace_name is listed as required parameter:
https://docs.aws.amazon.com/cdk/api/latest/docs/aws-appmesh-readme.html
Reproduction Steps
Step1: create Fargate service first along with CloudMap service (see cloud_map_options)
Step 2: try to create AppMesh virtual node (behaviour is the same for both methods to create virtual node - that means by using add virtual node method or creating separated virtual node and referencing the appmesh)
Error Log
File "/usr/local/lib/python3.7/site-packages/aws_cdk/aws_appmesh/__init__.py", line 3131, in add_virtual_node return jsii.invoke(self, "addVirtualNode", [id, props]) File "/usr/local/lib/python3.7/site-packages/jsii/_kernel/__init__.py", line 104, in wrapped return _recursize_dereference(kernel, fn(kernel, *args, **kwargs)) File "/usr/local/lib/python3.7/site-packages/jsii/_kernel/__init__.py", line 267, in invoke args=_make_reference_for_native(self, args), File "/usr/local/lib/python3.7/site-packages/jsii/_kernel/providers/process.py", line 346, in invoke return self._process.send(request, InvokeResponse) File "/usr/local/lib/python3.7/site-packages/jsii/_kernel/providers/process.py", line 316, in send raise JSIIError(resp.error) from JavaScriptError(resp.stack) jsii.errors.JSIIError: Cannot read property 'namespaceName' of undefined
Environment
Other
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: