Boavizta / boaviztapi

🛠 Giving access to BOAVIZTA reference data and methodologies trough a RESTful API
GNU Affero General Public License v3.0
75 stars 25 forks source link

Missing AWS platforms / servers for several instance references #284

Open bpetit opened 7 months ago

bpetit commented 7 months ago

Bug description

Querying the cloud/instance route with the following instances returns a 500 error, because of missing server/platform in servers.csv:

Instance Platform
g3.4xlarge platform_aws_g3
g3.8xlarge platform_aws_g3
g3.16xlarge platform_aws_g3
g3s.xlarge platform_aws_g3
m7gd.medium platform_aws_g3
m7gd.large m7gd.metal
m7gd.xlarge m7gd.metal
m7gd.2xlarge m7gd.metal
m7gd.4xlarge m7gd.metal
m7gd.8xlarge m7gd.metal
m7gd.12xlarge m7gd.metal
m7gd.16xlarge m7gd.metal
db.m1.medium platform_aws_m1
m1.medium platform_aws_m1
db.m1.small platform_aws_m1
m1.small platform_aws_m1
db.m1.large platform_aws_m1
m1.large platform_aws_m1
db.m1.xlarge platform_aws_m1

Trace in the API is :

'NoneType' object is not subscriptable Traceback (most recent call last): File "/app/boaviztapi/main.py", line 45, in catch_exceptions_middleware return await call_next(request) File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 84, in call_next raise app_exc File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 70, in coro await self.app(scope, receive_or_disconnect, send_no_error) File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 79, in call raise exc File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 68, in call await self.app(scope, receive, sender) File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in call raise e File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call await self.app(scope, receive, send) File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 718, in call await route.handle(scope, receive, send) File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 276, in handle await self.app(scope, receive, send) File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 66, in app response = await func(request) File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 237, in app raw_response = await run_endpoint_function( File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 163, in run_endpoint_function return await dependant.call(**values) File "/app/boaviztapi/routers/cloud_router.py", line 48, in instance_cloud_impact instance_model = mapper_cloud_instance(cloud_instance, archetype=instance_archetype) File "/app/boaviztapi/dto/device/device.py", line 82, in mapper_cloud_instance complete_components_usage(model_cloud_instance.platform, model_cloud_instance.usage) File "/app/boaviztapi/dto/device/device.py", line 59, in complete_components_usage for disk_unit in model.disk: File "/app/boaviztapi/model/device/server.py", line 53, in disk if get_arch_component(self.archetype, "SSD")["units"] not in [{}, {'default':0}]: TypeError: 'NoneType' object is not subscriptable

To Reproduce

query cloud/instance route with provider aws and instance_type equals one of the above instances

Expected behavior

200 OK with a result

da-ekchajzer commented 1 month ago

I've added an error (404 + message) if a platform specified for a given instance doesn't exist.

https://github.com/Boavizta/boaviztapi/commit/c1df46a6e52a4d4610e416dea598072053a6cd97

da-ekchajzer commented 1 month ago

https://github.com/Boavizta/boaviztapi/commit/27fee4ad2573d9183a5b34b956e64897a33eb6f0 adds the missing cloud platform