Implement an Arguments Key Handling for Entry Points Defined in snap-openstack.yaml

Bug #1655989 reported by Dmitrii Shcherbakov
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snap.openstack
Triaged
High
Unassigned

Bug Description

Right now it is only possible to pass additional arguments to an app via a top-level snapcraft.yaml file, for example, ceilometer's agent-central service uses ceilometer-polling script and passes --polling-namespaces argument to it so we need to do the same in the app definition. The following can be used to do it:

https://paste.ubuntu.com/23786868/

  agent-central:
    command: snap-openstack ceilometer-polling --polling-namespaces central

It seems to be cleaner to do it in the snap/snap-openstack.yaml though:

1) like this https://paste.ubuntu.com/23786827/
2) or via key-value pairs:

    arguments:
      polling-namespaces: central

The code in question is here https://git.launchpad.net/snap.openstack/tree/snap_openstack/base.py#n128

we just need to add a handler for the arguments key.

Revision history for this message
Corey Bryant (corey.bryant) wrote :

While we could get away with specifying the arguments in snapcraft.yaml, I agree that it would be cleaner to specify additional arguments in snap-openstack.yaml, alongside other args that are currently passed to the daemon (ie. log files, config files).

Changed in snap.openstack:
status: New → Triaged
importance: Undecided → High
Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote :

Found another reason for this to be implemented:

1) ceilometer API requires --port option to be present
ubuntu@juju-180ad0-oct-2x-next-0:~/src/ceilometer-6.1.3$ systemctl cat ceilometer-api.service

# /lib/systemd/system/ceilometer-api.service
[Unit]
Description=Ceilometer API
After=mongodb.service rabbitmq-server.service

[Service]
...
Environment=PORT=8777
...
ExecStart=/usr/bin/ceilometer-api --port ${PORT} -- --config-file=/etc/ceilometer/ceilometer.conf --log-file=/var/log/ceilometer/ceilometer-api.log
...

# /etc/systemd/system/ceilometer-api.service.d/override.conf
[Service]
Environment=PORT=8767

2) Looking at how it is launched I can see that the common options such as --log-file, --config-file or --config-dir are passed after the port is specified with two dashes in between:

/usr/bin/ceilometer-api -h
usage: ceilometer-api [-h] [--port PORT] -- [passed options]

positional arguments:
  -- [passed options] '--' is the separator of the arguments used to start
                        the WSGI server and the arguments passed to the WSGI
                        application.

optional arguments:
  -h, --help show this help message and exit
  --port PORT, -p PORT TCP port to listen on (default: 8000)

As here:

ubuntu@juju-180ad0-oct-2x-next-0:~/src/ceilometer-6.1.3$ systemctl status ceilometer-api.service | grep -ioP '\d+.*?/usr/bin/ceilometer-api.*?$'
26777 /usr/bin/python /usr/bin/ceilometer-api --port 8767 -- --config-file=/etc/ceilometer/ceilometer.conf --log-file=/var/log/ceilometer/ceilometer-api.log

Using snapcraft.yaml for passing the port parameter results in the argument reordering:

snapcraft.yaml:
...
apps:
  api:
    command: snap-openstack ceilometer-api --port 8767 --
...

янв 13 12:09:21 maas-xenial1 snap[15278]: WARNING:snap_openstack.base:Configuration file /var/snap/ceilometer/common/etc/ceilometer/ceilometer.conf not found, skipping
янв 13 12:09:25 maas-xenial1 snap[15278]: usage: ceilometer-api [-h] [--port PORT] -- [passed options]
янв 13 12:09:25 maas-xenial1 snap[15278]: ceilometer-api: error: unrecognized arguments: --config-file=/snap/ceilometer/x1/etc/ceilometer/ceilometer.conf --config-dir=/var/snap/ceilometer/common/etc/ceilometer.conf.d --log-file=/var/snap/ceilometer/common/log/ceilometer-api.log

So special handling is required here to correctly launch a service using snap.openstack helper code.

In case of ceilometer this is the only service that requires special handling btw.

Revision history for this message
James Page (james-page) wrote :

ceilometer-api needs to be snapped as a wsgi process, using uwsgi as we did in the keystone snap - the ceilometer-api standalone binary is deprecated for removal and does not scale in any way.

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote :

James,

Thanks, I did it and uploaded the result to my repo until we are ready to create an official one:
https://github.com/dshcherb/snap-ceilometer

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.