Failed to retrieve curtin config: 'NoneType' object has no attribute 'url'

Bug #1847337 reported by Jim Conner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Triaged
Medium
Unassigned

Bug Description

Log output:

```
2019-10-07 19:40:01 maasserver.websockets.protocol: [critical] Error on request (165) machine.action: Failed to retrieve curtin config: 'NoneType' object has no attribute 'url'
        Traceback (most recent call last):
          File "/usr/lib/python3.6/threading.py", line 864, in run
            self._target(*self._args, **self._kwargs)
          File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 852, in worker
            return target()
          File "/usr/lib/python3/dist-packages/twisted/_threads/_threadworker.py", line 46, in work
            task()
          File "/usr/lib/python3/dist-packages/twisted/_threads/_team.py", line 190, in doWork
            task()
        --- <exception caught here> ---
          File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 250, in inContext
            result = inContext.theWork()
          File "/usr/lib/python3/dist-packages/twisted/python/threadpool.py", line 266, in <lambda>
            inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
          File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 122, in callWithContext
            return self.currentContext().callWithContext(ctx, func, *args, **kw)
          File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 85, in callWithContext
            return func(*args,**kw)
          File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 885, in callInContext
            return func(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 234, in wrapper
            result = func(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 756, in call_within_transaction
            return func_outside_txn(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/maasserver/utils/orm.py", line 563, in retrier
            return func(*args, **kwargs)
          File "/usr/lib/python3.6/contextlib.py", line 52, in inner
            return func(*args, **kwds)
          File "/usr/lib/python3/dist-packages/maasserver/websockets/base.py", line 402, in prep_user_execute
            method_name, method, params)
          File "/usr/lib/python3/dist-packages/maasserver/websockets/base.py", line 421, in _call_method_track_queries
            result = method(params)
          File "/usr/lib/python3/dist-packages/maasserver/websockets/handlers/machine.py", line 891, in action
            return action.execute(**extra_params)
          File "/usr/lib/python3/dist-packages/maasserver/node_action.py", line 172, in execute
            self._execute(*args, **kwargs)
          File "/usr/lib/python3/dist-packages/maasserver/node_action.py", line 510, in _execute
            "Failed to retrieve curtin config: %s" % e)
        maasserver.exceptions.NodeActionError: Failed to retrieve curtin config: 'NoneType' object has no attribute 'url'
```

`request` is an `HttpRequest` object going into the `try`, but `url` is missing for some reason. The `if` condition is getting skipped (on check for `None`) because `request` is not `None`; only `request.url` is seemingly missing.

The `self` object and `self.request` object contain:
```
=> /var/log/maas/regiond.log <==
2019-10-08 18:32:21 stdout: [info] { 'endpoint': 1,
2019-10-08 18:32:21 stdout: [info] 'node': <Machine: qhytrx (njdcsbcpu01)>,
2019-10-08 18:32:21 stdout: [info] 'request': <HttpRequest>,
2019-10-08 18:32:21 stdout: [info] 'user': <User: user>}
2019-10-08 18:32:21 stdout: [info] { 'COOKIES': {},
2019-10-08 18:32:21 stdout: [info] 'FILES': <MultiValueDict: {}>,
2019-10-08 18:32:21 stdout: [info] 'GET': <QueryDict: {}>,
2019-10-08 18:32:21 stdout: [info] 'META': { 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; Intel Mac OS X '
2019-10-08 18:32:21 stdout: [info] '10_14_6) AppleWebKit/537.36 (KHTML, like '
2019-10-08 18:32:21 stdout: [info] 'Gecko) Chrome/77.0.3865.90 Safari/537.36',
2019-10-08 18:32:21 stdout: [info] 'REMOTE_ADDR': '::ffff:105.210.153.254',
2019-10-08 18:32:21 stdout: [info] 'SERVER_NAME': 'URL.io',
2019-10-08 18:32:21 stdout: [info] 'SERVER_PORT': 5240},
2019-10-08 18:32:21 stdout: [info] 'POST': <QueryDict: {}>,
2019-10-08 18:32:21 stdout: [info] '_post_parse_error': False,
2019-10-08 18:32:21 stdout: [info] 'content_params': None,
2019-10-08 18:32:21 stdout: [info] 'content_type': None,
2019-10-08 18:32:21 stdout: [info] 'method': None,
2019-10-08 18:32:21 stdout: [info] 'path': '',
2019-10-08 18:32:21 stdout: [info] 'path_info': '',
2019-10-08 18:32:21 stdout: [info] 'resolver_match': None,
2019-10-08 18:32:21 stdout: [info] 'user': <User: cms>}
```

Obviously, `HttpRequest.url` is None, but the check only exists on checking `request` for None. It is still not clear yet why `request.url` is `None`.

I took a look at the bug reported that gives a similar error message, but looking at my boot sources shows we have a single boot source still:

```
Machine-readable output follows:
[
    {
        "created": "2019-04-01T16:30:31.519",
        "updated": "2019-04-01T16:30:31.519",
        "url": "http://images.maas.io/ephemeral-v3/daily/",
        "keyring_filename": "/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg",
        "keyring_data": "",
        "id": 1,
        "resource_uri": "/MAAS/api/2.0/boot-sources/1/"
    }
]
```

One thing about this environment that could have a strong indicator to the cause of this issue is that this environment is behind a firewall completely secluded from the Internet. An internal private apt repo exists, though.

=================================== Requested Info ===========================================

root@njdcsbdr:/var/www/ubuntu# dpkg -l '*maas*'|cat
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===============================-======================================-============-=================================================
ii maas 2.6.1-7832-g17912cdc9-0ubuntu1~18.04.1 all "Metal as a Service" is a physical cloud and IPAM
ii maas-cli 2.6.1-7832-g17912cdc9-0ubuntu1~18.04.1 all MAAS client and command-line interface
un maas-cluster-controller <none> <none> (no description available)
ii maas-common 2.6.1-7832-g17912cdc9-0ubuntu1~18.04.1 all MAAS server common files
ii maas-dhcp 2.6.1-7832-g17912cdc9-0ubuntu1~18.04.1 all MAAS DHCP server
ii maas-dns 2.6.1-7832-g17912cdc9-0ubuntu1~18.04.1 all dummy transitional package for MAAS DNS server
ii maas-proxy 2.6.1-7832-g17912cdc9-0ubuntu1~18.04.1 all MAAS Caching Proxy
ii maas-rack-controller 2.6.1-7832-g17912cdc9-0ubuntu1~18.04.1 all Rack Controller for MAAS
ii maas-region-api 2.6.1-7832-g17912cdc9-0ubuntu1~18.04.1 all Region controller API service for MAAS
ii maas-region-controller 2.6.1-7832-g17912cdc9-0ubuntu1~18.04.1 all Region Controller for MAAS
un maas-region-controller-min <none> <none> (no description available)
un python-django-maas <none> <none> (no description available)
un python-maas-client <none> <none> (no description available)
un python-maas-provisioningserver <none> <none> (no description available)
ii python3-django-maas 2.6.1-7832-g17912cdc9-0ubuntu1~18.04.1 all MAAS server Django web framework (Python 3)
ii python3-maas-client 2.6.1-7832-g17912cdc9-0ubuntu1~18.04.1 all MAAS python API client (Python 3)
ii python3-maas-provisioningserver 2.6.1-7832-g17912cdc9-0ubuntu1~18.04.1 all MAAS server provisioning libraries (Python 3)

Revision history for this message
Jim Conner (snafuxnj) wrote :
Revision history for this message
Jim Conner (snafuxnj) wrote :

This is probably related and just noticed. When attempting to go to the settings page for MaaS the following occurs:

logs:
```
=> /var/log/maas/regiond.log <==
2019-10-08 22:41:51 regiond: [info] ::1 GET /MAAS/rpc/ HTTP/1.1 --> 200 OK (referrer: -; agent: provisioningserver.rpc.clusterservice.ClusterClientService)
2019-10-08 22:42:02 maasserver: [error] ################################ Exception: 'NoneType' object has no attribute 'url' ################################
2019-10-08 22:42:02 maasserver: [error] Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python3/dist-packages/maasserver/utils/views.py", line 277, in view_atomic_with_post_commit_savepoint
    return view_atomic(*args, **kwargs)
  File "/usr/lib/python3.6/contextlib.py", line 52, in inner
    return func(*args, **kwds)
  File "/usr/lib/python3/dist-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/maasserver/views/settings.py", line 277, in general
    "Configuration updated.")
  File "/usr/lib/python3/dist-packages/maasserver/views/__init__.py", line 215, in process_form
    form = form_class(prefix=prefix, **form_kwargs)
  File "/usr/lib/python3/dist-packages/maasserver/forms/__init__.py", line 1689, in __init__
    self._load_initials()
  File "/usr/lib/python3/dist-packages/maasserver/forms/__init__.py", line 1696, in _load_initials
    PackageRepository.get_ports_archive().url)
AttributeError: 'NoneType' object has no attribute 'url'

2019-10-08 22:42:02 regiond: [info] 105.210.153.254 GET /MAAS/settings/general/ HTTP/1.1 --> 500 INTERNAL_SERVER_ERROR (referrer: -; agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36)
2019-10-08 22:42:21 regiond: [info] ::1 GET /MAAS/rpc/ HTTP/1.1 --> 200 OK (referrer: -; agent: provisioningserver.rpc.clusterservice.ClusterClientService)
```

from URL: http://URL:5240/MAAS/settings/general/ and the page shows:
'NoneType' object has no attribute 'url'

Revision history for this message
Lee Trager (ltrager) wrote :

I think I see where the bug is. When setting custom repositories you must of deselected armhf, arm64, ppc64el, and s390x from the Ubuntu extra architectures repository. Try reselecting those, MAAS won't use them unless you're booting one of those architectures.

The bug is in PackageRepository.get_ports_archive(). If armhf, arm64, ppc64el, s390x isn't selected anywhere the query failures and the error above is seen. MAAS should ensure there is always a repository configured for all architectures.

Changed in maas:
status: New → Confirmed
Revision history for this message
Jim Conner (snafuxnj) wrote :

Yup! Confirmed. I re-selected those ports archives and everything works again. Thank you!

The seemingly tight-coupledness of repositories and maas is awkward. Is my assessment shared among others?

Revision history for this message
Jim Conner (snafuxnj) wrote :

One last thing mildly related. It looks as though if one deselects all pockets and all components (IE no updates, security, or backports) in (restricted, universe, and multiverse) the same error occurs.

If I'm hosting my own internal APT repo and I have limited bandwidth to mirror said repo causing me to only be able to replicate a subset of everything from the world (IE main) that I should be able to just allow main. OTH one could also argue that it would be nice to be able to disable apt altogether. *shrug*

Changed in maas:
importance: Undecided → Medium
Changed in maas:
status: Confirmed → Triaged
Revision history for this message
Jerzy Husakowski (jhusakowski) wrote :

Let's re-check this on recent MAAS and fix PackageRepository.get_ports_archive() if the issue still reproduces.

summary: - MaaS 2.6.1 - Failed to retrieve curtin config: 'NoneType' object has no
- attribute 'url'
+ Failed to retrieve curtin config: 'NoneType' object has no attribute
+ 'url'
Changed in maas:
milestone: none → 3.5.0
Changed in maas:
milestone: 3.5.0 → 3.5.x
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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