Unable to build and run MAAS from source

Hello,

I started today with the plan of contributing Moonshot Chassis Manager 2.0 improvements to MAAS, but I seem to have become stuck at the first step; getting things running.

Using a pristine Ubuntu 20.04 server (with git, golang, and build-essential installed), I’ve tried to build from source using different branches/tags, but no luck. Taking 2.9.2 as an example:

  • make install-dependencies - OK
  • make - OK
  • make syncdb - OK
  • make run - Not working…

The main symptom is that when I visit http://server:5240/ I get redirected to http://server:5240/MAAS/r/ and I get a 404 No Such Resource error. “File not found.”

In the logs I see:

2021-03-11 14:22:50 regiond: [info] 192.168.50.193 GET /MAAS/r/ HTTP/1.1 --> 404 NOT_FOUND (referrer: -; agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0) Gecko/20100101 Firefox/86.0)

There’s a lot of activity continuously output by the logs; a lot of it looks healthy, some of it looks problematic, but I don’t know if any of it might be a cause.

2021-03-11 14:23:53 provisioningserver.utils.service_monitor: [debug] [try:1] Service monitor executing cmd: sudo --non-interactive systemctl restart chrony
2021-03-11 14:23:53 provisioningserver.utils.service_monitor: [debug] [try:1] Service monitor got exit code '5' from cmd: sudo --non-interactive systemctl restart chrony
2021-03-11 14:23:53 maas.service_monitor: [error] Service 'ntp_region' failed to restart: Failed to restart chrony.service: Unit chrony.service not found.

2021-03-11 14:23:53 maasserver.regiondservices.ntp: [critical] Failed to update NTP configuration.
        Traceback (most recent call last):
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 501, in errback
            self._startRunCallbacks(fail)
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 568, in _startRunCallbacks
            self._runCallbacks()
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 654, in _runCallbacks
            current.result = callback(current.result, *args, **kw)
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1475, in gotResult
            _inlineCallbacks(r, g, status)
        --- <exception caught here> ---
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
            result = result.throwExceptionIntoGenerator(g)
          File "/usr/lib/python3/dist-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
            return g.throw(self.type, self.value, self.tb)
          File "/home/bob/projects/maas-2.9.2/src/provisioningserver/utils/service_monitor.py", line 354, in restartService
            yield self._performServiceAction(service, "restart")
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
            result = g.send(result)
          File "/home/bob/projects/maas-2.9.2/src/provisioningserver/utils/service_monitor.py", line 561, in _performServiceAction
            raise ServiceActionError(error_msg)
        provisioningserver.utils.service_monitor.ServiceActionError: Service 'ntp_region' failed to restart: Failed to restart chrony.service: Unit chrony.service not found.


2021-03-11 14:23:58 stderr: [error] request to http://127.0.0.1:5240/MAAS/metadata/2012-03-01/ failed. sleeping 16.: HTTP Error 503: Service Unavailable
2021-03-11 14:24:21 maasserver.regiondservices.syslog: [critical] Failed to update syslog configuration.
        Traceback (most recent call last):
          File "/usr/lib/python3.8/threading.py", line 870, in run
            self._target(*self._args, **self._kwargs)
          File "/home/bob/projects/maas-2.9.2/src/provisioningserver/utils/twisted.py", line 825, 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 "/home/bob/projects/maas-2.9.2/src/provisioningserver/utils/twisted.py", line 860, in callInContext
            return func(*args, **kwargs)
          File "/home/bob/projects/maas-2.9.2/src/provisioningserver/utils/twisted.py", line 192, in wrapper
            result = func(*args, **kwargs)
          File "/home/bob/projects/maas-2.9.2/src/provisioningserver/syslog/config.py", line 93, in write_config
            atomic_write(content, target_path, overwrite=True, mode=0o644)
          File "/home/bob/projects/maas-2.9.2/src/provisioningserver/utils/fs.py", line 123, in atomic_write
            temp_file = _write_temp_file(content, filename)
          File "/home/bob/projects/maas-2.9.2/src/provisioningserver/utils/fs.py", line 83, in _write_temp_file
            temp_fd, temp_file = tempfile.mkstemp(
          File "/usr/lib/python3.8/tempfile.py", line 471, in mkstemp
            return _mkstemp_inner(dir, prefix, suffix, flags, output_type)
          File "/usr/lib/python3.8/tempfile.py", line 389, in _mkstemp_inner
            fd = _os.open(file, flags, 0o600)
        builtins.FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/maas/.rsyslog.conf.gf_pp9fl.tmp'
2021-03-11 14:24:22 provisioningserver.utils.service_monitor: [debug] [try:2] Service monitor got exit code '4' from cmd: sudo --non-interactive systemctl status maas-http
2021-03-11 14:24:22 provisioningserver.rackdservices.http: [critical] Failed to update HTTP configuration.
        Traceback (most recent call last):
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 501, in errback
            self._startRunCallbacks(fail)
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 568, in _startRunCallbacks
            self._runCallbacks()
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 654, in _runCallbacks
            current.result = callback(current.result, *args, **kw)
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1475, in gotResult
            _inlineCallbacks(r, g, status)
        --- <exception caught here> ---
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
            result = result.throwExceptionIntoGenerator(g)
          File "/usr/lib/python3/dist-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
            return g.throw(self.type, self.value, self.tb)
          File "/home/bob/projects/maas-2.9.2/src/provisioningserver/utils/service_monitor.py", line 400, in reloadService
            state = yield self.ensureService(name)
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
            result = result.throwExceptionIntoGenerator(g)
          File "/usr/lib/python3/dist-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
            return g.throw(self.type, self.value, self.tb)
          File "/home/bob/projects/maas-2.9.2/src/provisioningserver/utils/service_monitor.py", line 687, in _ensureService
            state = yield self.getServiceState(service.name, now=True)
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
            result = result.throwExceptionIntoGenerator(g)
          File "/usr/lib/python3/dist-packages/twisted/python/failure.py", line 491, in throwExceptionIntoGenerator
            return g.throw(self.type, self.value, self.tb)
          File "/home/bob/projects/maas-2.9.2/src/provisioningserver/utils/service_monitor.py", line 283, in getServiceState
            active_state, process_state = yield self._loadServiceState(service)
          File "/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
            result = g.send(result)
          File "/home/bob/projects/maas-2.9.2/src/provisioningserver/utils/service_monitor.py", line 628, in _loadSystemDServiceState
            raise ServiceParsingError(
        provisioningserver.utils.service_monitor.ServiceParsingError: Unable to parse the output from systemd for service 'maas-http'.

Can anyone please help? A bit dejected I’ve not been able to get it running locally so that I can do some debugging yet.

Cheers.

Before running make run make sure your run make sampledata This configures the database and adds a bunch of fake machines in various states to help test the UI.

It’s not that I’m afraid. I tried as suggested, and re-ran make run but it’s still the same issue.

I think I’ve fixed one of the log errors which I was having, which was about chrony. I’ve installed that via apt and I’m no longer seeing that in the logs. This leads me to suspect that perhaps the packages chosen by make install-dependencies might not be completely comprehensive?

The maas-http error looks quite bad:

2021-03-11 14:24:22 provisioningserver.utils.service_monitor: [debug] [try:2] Service monitor got exit code '4' from cmd: sudo --non-interactive systemctl status maas-http

Is there perhaps something that I need to do to rectify that?

Its been awhile since I ran MAAS with make run and actually deployed anything. Its primarily used by our design team to quickly iterate on the UI. If maas-http isn’t running deployments most likely won’t work.

What I normally do is build the Debian packages with make package-dev and install them into an LXD container which is on a MAAS test network. This allows me to run MAAS normally and because I’m using the Debian package over the Snap I can quickly edit files on the filesystem to test things out.

Ok thanks. I’ll give that a try. Please could you explain the “install” process? And does it allow me to easily debug from Visual Studio Code? I’ll happily take any method of getting things running if it allows me to get on with the real challenge of modifying and debugging it. So far I’ve not been able to get a UI to appear. :frowning:

I’ve only got a very tight window for getting this to work unfortunately. We got Moonshot to solve some critical resource issues at work, and I’ve only got it for a short period in which I can play around with it and hopefully make changes to add Moonshot Chassis 2.0 support. Once it’s in production using it a development environment for MAAS won’t be an option so I’ll need to abandon the plan.

@ltrager, I managed to get it built and installed with make package-dev! I just chose to do a local install on my development machine, which I did with:

sudo dpkg -i python3-maas-client_2.9.2-9164-g.ac176b5c4-0ubuntu1_all.deb
sudo dpkg -i maas-cli_2.9.2-9164-g.ac176b5c4-0ubuntu1_all.deb
sudo dpkg -i python3-django-maas_2.9.2-9164-g.ac176b5c4-0ubuntu1_all.deb
sudo dpkg -i python3-maas-provisioningserver_2.9.2-9164-g.ac176b5c4-0ubuntu1_all.deb
sudo dpkg -i maas-common_2.9.2-9164-g.ac176b5c4-0ubuntu1_all.deb
sudo apt install squid
sudo dpkg -i maas-proxy_2.9.2-9164-g.ac176b5c4-0ubuntu1_all.deb
sudo dpkg -i maas-region-api_2.9.2-9164-g.ac176b5c4-0ubuntu1_all.deb
sudo dpkg -i maas-region-controller_2.9.2-9164-g.ac176b5c4-0ubuntu1_all.deb # This does schema updates. To what?
sudo dpkg -i maas-dhcp_2.9.2-9164-g.ac176b5c4-0ubuntu1_all.deb
sudo apt install libvirt-clients
sudo dpkg -i maas-rack-controller_2.9.2-9164-g.ac176b5c4-0ubuntu1_all.deb
sudo dpkg -i maas_2.9.2-9164-g.ac176b5c4-0ubuntu1_all.deb

So now I’ve got a working MAAS from the source on my system (albeit running as services and immutable due to it not running from my codebase). My process for changing and testing seems to be to rerun make package-dev and reinstall the relevant changed package(s) from above and test, and unfortunately I’ve got no ability to debug the processes since they’re running under ‘maas’ user.

Are you able to illuminate me on a more sensible way of development please? :slight_smile: I’m hoping for something as instant as just running locally (which I was hoping to achieve with make run or make start/stop.

Cheers. Slowly getting somewhere.

I’ve run into this lovely bug with the make package-dev build: https://bugs.launchpad.net/maas/+bug/1702567

It means that when I go to do a Commission operation, I get the error:

Error:name 'maas_api_helper_py' is not defined at line 17 column 3 in file /usr/lib/python3/dist-packages/metadataserver/user_data/templates/script_runner.template

Is there definitely no one that can advise on creating a development environment that works? :slight_smile: