Broken systemd unit for gnocchi-api

Bug #1707642 reported by Daniele Venzano
34
This bug affects 5 people
Affects Status Importance Assigned to Milestone
gnocchi (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

gnocchi-api is a developer wrapper arount a test server.
The Gnocchi documentation (http://gnocchi.xyz/operating.html) suggests using Apache WSGI to run it. The Ubuntu packages should contain the Apache configuration like is done for Keystone and Cinder.

Anyway the systemd unit is broken because gnocchi-api is called with the wrong options:

Jul 31 14:34:00 bfeb systemd[1]: Started OpenStack Gnocchi Api.
Jul 31 14:34:02 bfeb gnocchi-api[10203]: usage: gnocchi-api [-h] [--port PORT] -- [passed options]
Jul 31 14:34:02 bfeb gnocchi-api[10203]: gnocchi-api: error: unrecognized arguments: --config-file=/etc/gnocchi/gnocchi.conf --log-file=/var/log/gnocchi/gnocchi-api.log
Jul 31 14:34:02 bfeb systemd[1]: gnocchi-api.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Jul 31 14:34:02 bfeb systemd[1]: gnocchi-api.service: Unit entered failed state.
Jul 31 14:34:02 bfeb systemd[1]: gnocchi-api.service: Failed with result 'exit-code'.
Jul 31 14:34:02 bfeb systemd[1]: gnocchi-api.service: Service hold-off time over, scheduling restart.
Jul 31 14:34:02 bfeb systemd[1]: Stopped OpenStack Gnocchi Api.
Jul 31 14:34:02 bfeb systemd[1]: gnocchi-api.service: Start request repeated too quickly.
Jul 31 14:34:02 bfeb systemd[1]: Failed to start OpenStack Gnocchi Api.

This is Ubuntu Xenial with the Ocata cloud archive for openstack.

Revision history for this message
Sumit KUmar (sumit.kumar) wrote :

I am having the same problem:

* gnocchi-api.service - OpenStack Gnocchi Api
   Loaded: loaded (/lib/systemd/system/gnocchi-api.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

Sep 02 04:53:57 neutron1 gnocchi-api[19591]: usage: gnocchi-api [-h] [--port PORT] -- [passed options]
Sep 02 04:53:57 neutron1 gnocchi-api[19591]: gnocchi-api: error: unrecognized arguments: --config-file=/etc/gnocchi/gnocchi.conf --log-file=/var/log/gnocchi/gnocchi-api.log
Sep 02 04:53:57 neutron1 systemd[1]: gnocchi-api.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Sep 02 04:53:57 neutron1 systemd[1]: gnocchi-api.service: Unit entered failed state.
Sep 02 04:53:57 neutron1 systemd[1]: gnocchi-api.service: Failed with result 'exit-code'.
Sep 02 04:53:57 neutron1 systemd[1]: gnocchi-api.service: Service hold-off time over, scheduling restart.
Sep 02 04:53:57 neutron1 systemd[1]: Stopped OpenStack Gnocchi Api.
Sep 02 04:53:57 neutron1 systemd[1]: gnocchi-api.service: Start request repeated too quickly.
Sep 02 04:53:57 neutron1 systemd[1]: Failed to start OpenStack Gnocchi Api.
Sep 04 16:24:03 neutron1 systemd[1]: Stopped OpenStack Gnocchi Api.

Is there any workaround for this?

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gnocchi (Ubuntu):
status: New → Confirmed
Revision history for this message
KI4RBC (mikemcdonough) wrote :

To add a little more of the back story:

/etc/os_release:

NAME="Ubuntu"
VERSION="16.04.4 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.4 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

Package:

gnocchi-api/xenial-updates,now 3.1.2-0ubuntu1~cloud0 all [installed]

Errors in syslog:
Mar 6 03:01:25 pod2controller-admin gnocchi-api[100950]: usage: gnocchi-api [-h] [--port PORT] -- [passed options]
Mar 6 03:01:25 pod2controller-admin gnocchi-api[100950]: gnocchi-api: error: unrecognized arguments: --config-file=/etc/gnocchi/gnocchi.conf --log-file=/var/log/gnocchi/gnocchi-api.log

The comment in `/etc/init.d/gnocchi-api` seems to suggest that this init script is auto-generated.

# The content after this line comes from openstack-pkg-tools
# and has been automatically added to a .init.in script, which
# contains only the descriptive part for the daemon. Everything
# else is standardized as a single unique script.

So this standardized script is setting $DAEMON_ARGS with the above arguments while `/usr/bin/gnocchi-api` is expecting only a port number to listen on.

I am able to execute `/etc/bin/gnocchi-api` and sucessfully test the api

[root@controller gnocchi(admin)]$ /usr/bin/gnocchi-api --port 8041
********************************************************************************
STARTING test server gnocchi.rest.app.build_wsgi_app
Available at http://10.3.35.40:8041/
DANGER! For testing only, do not use in production
********************************************************************************
192.168.100.40 - - [06/Mar/2018 22:26:53] "GET / HTTP/1.1" 200 150

[root@controller gnocchi(admin)]$ api-test.sh -a gnocchi -c controller-int -d
...
Mar 06 22:26:53 pod2controller /usr/local/bin/api-test.sh: INFO: gnocchi test passed on http://pod2controller-int:8041/
{
    "versions": [
        {
            "id": "v1.0",
            "links": [
                {
                    "href": "http://controller-int:8041/v1/",
                    "rel": "self"
                }
            ],
            "status": "CURRENT",
            "updated": "2015-03-19"
        }
    ]
}
[root@controller gnocchi(admin)]$

I also am able to use uwsgi with this ini file
[uwsgi]
http = 0.0.0.0:8041
wsgi-file = /usr/bin/gnocchi-api
master = true
die-on-term = true
threads = 32
processes = 32
enabled-threads = true
thunder-lock = true
plugins = python
buffer-size = 65535
lazy-apps = true
add-header = Connection: close

Perhaps @zigo can chime in here?

Revision history for this message
KI4RBC (mikemcdonough) wrote :

as a work-around I did the following:

mv /usr/bin/gnocchi-api /usr/bin/gnocchi-wsgi-api
cat << 'EOF' >> /usr/bin/gnocchi-api
#!/bin/sh
GID=$(/usr/bin/id -g gnocchi)
/usr/local/bin/uwsgi /etc/gnocchi/uwsgi.ini --gid $GID
EOF
cat << 'EOF' >> /etc/gnocchi/uwsgi.ini
[uwsgi]
http = 0.0.0.0:8041
wsgi-file = /usr/bin/gnocchi-wsgi-api
master = true
die-on-term = true
threads = 32
processes = 32
enabled-threads = true
thunder-lock = true
plugins = python
buffer-size = 65535
lazy-apps = true
add-header = Connection: close
EOF
service gnocchi-api restart

Revision history for this message
KI4RBC (mikemcdonough) wrote :

My team has a suspicion adding uwsgi package is causing a problem with openstack-dashboard. I am looking to patch the init script that calls the original gnocchi-api to call the correct arguments this week and will post it here.

Revision history for this message
KI4RBC (mikemcdonough) wrote :

So scratch my earlier workaround or patching. After reading what /etc/init/gnocchi-api.conf is doing around lines 31 to 36 I found I can modify startup behavior by creating `/etc/defaults/gnocchi-api` and adding the following contents

```bash
DAEMON_ARGS="--port 8041 -- --log-file=/var/log/gnocchi/gnocchi-api.log"
CONFIG_FILE="/etc/gnocchi/gnocchi.conf"
USE_SYSLOG="no"
USE_LOGFILE="yes"
```

It seems the extra "--" is not being passed to the start-stop-daemon function

Now my only problem is that API requests are still showing up in `/var/log/syslog` even though this is not what I see in the arguments reported by systemctl status

```bash
   CGroup: /system.slice/gnocchi-api.service
           └─110578 /usr/bin/python2.7 /usr/bin/gnocchi-api --port 8041 -- --log-file=/var/log/gnocchi/gnocchi-api.log
```

Revision history for this message
Andreas (fattony666) wrote :

It seems that the latest version (4.2.0) does not have the gnocchi-api service unit installed.

Failed to restart gnocchi-api.service: Unit gnocchi-api.service not found.

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.