teamhephy / controller

Hephy Workflow Controller (API)
https://teamhephy.com
MIT License
14 stars 26 forks source link

Unclear error message when setting memory limits #165

Closed dvalfre closed 2 years ago

dvalfre commented 2 years ago

When trying to set memory limits, if the new settings are not expressed exactly as requested, then an undetailed error is presented:

$ deis limits:set myproc=1GB/2GB -a myapp
Applying limits... Error: Internal Server Error

Can this error be made more clear?

This is the error at Controller which corresponds to the above:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/views.py", line 492, in dispatch
    response = handler(request, *args, **kwargs)
  File "/app/api/views.py", line 186, in create
    return super(AppResourceViewSet, self).create(request, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/mixins.py", line 21, in create
    self.perform_create(serializer)
  File "/app/api/viewsets.py", line 20, in perform_create
    obj = serializer.save(owner=self.request.user)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/serializers.py", line 214, in save
    self.instance = self.create(validated_data)
  File "/usr/local/lib/python3.6/dist-packages/rest_framework/serializers.py", line 943, in create
    instance = ModelClass._default_manager.create(**validated_data)
  File "/usr/local/lib/python3.6/dist-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/django/db/models/query.py", line 394, in create
    obj.save(force_insert=True, using=self.db)
  File "/app/api/models/config.py", line 170, in save
    self._memory_guard()
  File "/app/api/models/config.py", line 202, in _memory_guard
    memory_settings,discrepancy_found = self.app.check_request_lower_than_default(value)
  File "/app/api/models/app.py", line 1178, in check_request_lower_than_default
    if requests_value < lowest_values[requests_unit]:
KeyError: 'gb'
eudalov commented 2 years ago

The fix suggested - PR https://github.com/teamhephy/controller/pull/166.

Cryptophobia commented 2 years ago

Does the suggested fix actually fix anything or change the required format to only a single letter? @dvalfre , are you expecting better error message or something else?

dvalfre commented 2 years ago

thanks @Cryptophobia for pointing this out. Turns out the issue & fix are related to internal customizations made to Controller. The code will eventually be submitted upstream, but we're not there yet.