Comment 0 for bug 1679301

Revision history for this message
Andrew Bruce (andybrucenet) wrote :

While deploying new bay to OpenStack Mitaka, found that some generated files were incorrect:

./magnum/drivers/common/templates/kubernetes/fragments/network-config-service.sh
./magnum/drivers/common/templates/kubernetes/fragments/write-network-config.sh
./magnum/drivers/common/templates/swarm/fragments/network-config-service.sh

The problem is the usage of FLANNEL_ETCD / FLANNEL_ETCD_KEY after sourcing in /etc/sysconfig/flanneld. For Fedora Atomic 25, these variables are completely different.

Upon reviewing the latest code in the OpenStack Magnum repo, I see that both the Kubernetes fragments appear updated. However, the Swarm fragment still uses:

<cut>
if ! [ "$FLANNEL_ETCD" ] && [ "$FLANNEL_ETCD_KEY" ]; then
    echo "ERROR: missing required configuration" >&2
    exit 1
fi

echo "creating flanneld config in etcd"
while ! curl -sf -L $ETCD_CURL_OPTIONS \
    $FLANNEL_ETCD/v2/keys${FLANNEL_ETCD_KEY}/config \
    -X PUT --data-urlencode value@${FLANNEL_JSON}; do
    echo "waiting for etcd"
    sleep 1
done
</cut>

These need to be changed to FLANNEL_ETCD_ENDPOINTS / FLANNEL_ETCD_PREFIX as was done with Kubernetes.

While in there, I request two additional changes that still affect the Swarm / Kubernetes network-config-service.sh fragments:

1. Please source in current settings from /etc/sysconfig/flanneld

2. In the fragments, escape variable references. For example, how about:

<cut>
if ! [ "\$FLANNEL_ETCD_ENDPOINTS" ] && [ "\$FLANNEL_ETCD_PREFIX" ]; then
    echo "ERROR: missing required configuration" >&2
    exit 1
fi

echo "creating flanneld config in etcd"
while ! curl -sf -L \$FLANNEL_ETCD_ENDPOINTS/v2/keys\${FLANNEL_ETCD_PREFIX}/config \
  -X PUT --data-urlencode value@${FLANNEL_JSON}; do
    echo "waiting for etcd"
    sleep 1
done
</cut>

3. For both the Kubernetes and the Swarm network-config-service.sh, can you put in a dependency when setting up /etc/systemd/system/flannel-config.service? Something like:

<cut>
cat > $FLANNEL_CONFIG_SERVICE <<EOF
[Unit]
After=etcd.service
Requires=etcd.service
# ABr: maintain state
Before=flanneld.service

[Service]
Type=oneshot
EnvironmentFile=/etc/sysconfig/flanneld
ExecStart=$FLANNEL_CONFIG_BIN

[Install]
WantedBy=multi-user.target
EOF
</cut>

That last setting will prevent flanneld from starting too early - settings will be properly populated to etcd!

Thanks very much.