Unable to add a 16384-bit ssh key to my account from web UI

Bug #1604702 reported by Po-Hsu Lin
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
High
Björn Tillenius

Bug Description

When trying to add a 16384-bits public key to my account on MaaS, it will throw me to an "Internal Server Error" page.

It works with a regular 2048-bits key.

MaaS version:
    MAAS Version 1.9.2+bzr4568-0ubuntu1 (trusty1)

Tags: internal

Related branches

Revision history for this message
Brendan Donegan (brendan-donegan) wrote :

I can confirm this happens, even in trunk, setting to triaged

Changed in maas:
status: New → Triaged
importance: Undecided → High
Revision history for this message
Brendan Donegan (brendan-donegan) wrote :
Download full text (4.7 KiB)

From regiond.log:

2016-07-20 04:56:20 [HTTPChannel,4,127.0.0.1] 500 Error - /MAAS/account/prefs/sshkey/add/
        Traceback (most recent call last):
          File "/usr/lib/python3/dist-packages/django/core/handlers/wsgi.py", line 189, in __call__
            response = self.get_response(request)
          File "/usr/lib/python3/dist-packages/maasserver/utils/views.py", line 227, in get_response
            response = get_response(request)
          File "/usr/lib/python3/dist-packages/maasserver/utils/views.py", line 201, in get_response
            return django_get_response(request)
          File "/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 218, in get_response
            response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
        --- <exception caught here> ---
          File "/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 132, in get_response
            response = wrapped_callback(request, *callback_args, **callback_kwargs)
          File "/usr/lib/python3/dist-packages/maasserver/utils/views.py", line 180, in view_atomic_with_post_commit_savepoint
            return view_atomic(*args, **kwargs)
          File "/usr/lib/python3.5/contextlib.py", line 30, in inner
            return func(*args, **kwds)
          File "/usr/lib/python3/dist-packages/django/views/generic/base.py", line 71, in view
            return self.dispatch(request, *args, **kwargs)
          File "/usr/lib/python3/dist-packages/django/views/generic/base.py", line 89, in dispatch
            return handler(request, *args, **kwargs)
          File "/usr/lib/python3/dist-packages/django/views/generic/edit.py", line 249, in post
            return super(BaseCreateView, self).post(request, *args, **kwargs)
          File "/usr/lib/python3/dist-packages/django/views/generic/edit.py", line 215, in post
            return self.form_valid(form)
          File "/usr/lib/python3/dist-packages/maasserver/views/prefs.py", line 49, in form_valid
            return super(SSHKeyCreateView, self).form_valid(form)
          File "/usr/lib/python3/dist-packages/django/views/generic/edit.py", line 193, in form_valid
            self.object = form.save()
          File "/usr/lib/python3/dist-packages/django/forms/models.py", line 459, in save
            construct=False)
          File "/usr/lib/python3/dist-packages/django/forms/models.py", line 105, in save_instance
            instance.save()
          File "/usr/lib/python3/dist-packages/maasserver/models/cleansave.py", line 29, in save
            return super(CleanSave, self).save(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/maasserver/models/timestampedmodel.py", line 64, in save
            return super(TimestampedModel, self).save(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/django/db/models/base.py", line 734, in save
            force_update=force_update, update_fields=update_fields)
          File "/usr/lib/python3/dist-packages/django/db/models/base.py", line 762, in save_base
            updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
          File "/usr/lib/python3/dist-pa...

Read more...

Revision history for this message
Gavin Panella (allenap) wrote :

One solution would be to create a functional unique index on the key
fingerprint. Or, as the error suggests, on the MD5 hash. However...

Simplest would be to remove the unique index. Uniqueness is currently
checked on user+key, so we're only guarding against a user adding the
same key multiple times, which is basically harmless, and unlikely to
happen in any case. Plus it can be trivially subverted by changing the
key comment each time.

Changed in maas:
milestone: 2.1.0 → 2.1.1
Changed in maas:
milestone: 2.1.1 → 2.1.2
Changed in maas:
milestone: 2.1.2 → 2.1.3
Revision history for this message
Andres Rodriguez (andreserl) wrote :

Hi there!

Is this still an issue?

no longer affects: maas/1.9
no longer affects: maas/2.0
no longer affects: maas/trunk
Changed in maas:
milestone: 2.1.3 → next
status: Triaged → Incomplete
tags: added: internal
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Hello,
Yes, this issue still exist on MaaS 2.2.2 and 2.3.1
But I guess I'm the only one that challenges its limit, heh
Thanks.

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

BTW the error message will be:

index row size 2816 exceeds maximum 2712 for index "maasserver_sshkey_user_id_31f4dfe9dbd6f8ba_uniq" HINT: Values larger than 1/3 of a buffer page cannot be indexed. Consider a function index of an MD5 hash of the value, or use full text indexing.

Changed in maas:
status: Incomplete → Confirmed
Changed in maas:
milestone: next → 2.4.0rc2
Changed in maas:
assignee: nobody → Björn Tillenius (bjornt)
Changed in maas:
status: Confirmed → In Progress
Revision history for this message
Björn Tillenius (bjornt) wrote :

I'm going to remove the index, since having duplicate keys is harmless. Using a function to calculate the value to index would be fine as well, but Django doesn't support it.

Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.