Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

.include line missing from a unit file after submitting it to fleet #1396

Open
maticmeznar opened this issue Dec 17, 2015 · 1 comment
Open

Comments

@maticmeznar
Copy link

I wanted to create a nice common unit file that I will include with all docker units, so I don't have to repeat myself when writing units for fleet. However, the .include line seems to be missing from the resulting unit file. This is unacceptable.

core@core-01 ~ $ cat skydns\@.service 
.include /etc/systemd/include.unit

[Unit]
Description=skydns

[Service]
Environment="IMAGE=skynetservices/skydns:latest"
EnvironmentFile=/etc/etcd-client.env
ExecStartPre=-/usr/bin/docker stop $NAME
ExecStartPre=-/usr/bin/docker rm -f $NAME
ExecStartPre=-/usr/bin/docker pull $IMAGE
ExecStartPre=/usr/bin/etcdctl set /skydns/config \
        '{"dns_addr":"0.0.0.0:53", "rcache":0, "no_rec":true, "ttl":3600, "nameservers": ["10.1.11.1:53"], "hostmaster":"[email protected]", "read_timeout":10}'

ExecStart=/usr/bin/docker run \
        --name $NAME --read-only --rm \
        -e ETCD_MACHINES="https://${COREOS_PRIVATE_IPV4}:2379" \
        -e ETCD_CACERT=${ETCDCTL_CA_FILE} \
        -e ETCD_TLSPEM=${ETCDCTL_CERT_FILE} \
        -e ETCD_TLSKEY=${ETCDCTL_KEY_FILE} \
        -v ${ETCD_SSL_DIR}:${ETCD_SSL_DIR}:ro \
        -p 53:53 -p 53:53/udp \
        $IMAGE

ExecStop=/usr/bin/docker stop $NAME

[X-Fleet]
Conflicts=%p@*.service

File /etc/systemd/include.unit is present on all CoreOS nodes (created with cloud-config).

core@core-01 ~ $ cat /etc/systemd/include.unit
[Unit]
After=docker.service
Requires=docker.service
[Service]
Type=simple
TimeoutStartSec=10min
TimeoutStopSec=5min
KillMode=none
Restart=on-failure
RestartSec=3s
StartLimitInterval=10s
StartLimitBurst=1
EnvironmentFile=/etc/environment
Environment=NAME=%p-%i

Resulting unit file after submitting and starting the unit with fleetctl:

core@core-01 ~ $ systemctl cat [email protected] 
# /run/fleet/units/[email protected]
[Unit]
Description=skydns

[Service]
Environment="IMAGE=skynetservices/skydns:latest"
EnvironmentFile=/etc/etcd-client.env
ExecStartPre=-/usr/bin/docker stop $NAME
ExecStartPre=-/usr/bin/docker rm -f $NAME
ExecStartPre=-/usr/bin/docker pull $IMAGE
ExecStartPre=/usr/bin/etcdctl set /skydns/config          '{"dns_addr":"0.0.0.0:53", "rcache":0, "no_rec":true, "ttl":3600, "nameservers": ["10.1.11.1:53"], "hostmaster":"[email protected]", "read_timeout":10}'
ExecStart=/usr/bin/docker run          --name $NAME --read-only --rm          -e ETCD_MACHINES="https://${COREOS_PRIVATE_IPV4}:2379"          -e ETCD_CACERT=${ETCDCTL_CA_FILE}    
ExecStop=/usr/bin/docker stop $NAME

[X-Fleet]
Conflicts=%p@*.service
@jonboulle
Copy link
Contributor

This is an interesting use case, but unfortunately it's infeasible with the current way that unit files are handled in fleet. When communicating over the API unit files are deserialized (via go-systemd) into a sequence of unit options, which means we lose any comments and other things like includes. (I also seem to recall that .include directives are strongly discouraged by upstream systemd, but can't find a reference for that now.)

Not sure how to go about approaching this one.

@jonboulle jonboulle added this to the vfuture milestone Jan 26, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants