Adds wait loop to entrypoint when --multus-conf-file=auto (#234)

* [entrypoint] Adds wait loop when using --multus-conf-file=auto waits for presence of any conf file

* [entrypoint] fixes incorrect logical comparison

* [entrypoint] add log every 5 tries, fix tries increment, fix logical comparison

* [entrypoint] fix attempt output
This commit is contained in:
Doug Smith
2019-02-28 13:56:08 -05:00
committed by GitHub
parent 560d07f007
commit f0a43ca0a5

View File

@@ -157,30 +157,39 @@ fi
if [ "$MULTUS_CONF_FILE" == "auto" ]; then if [ "$MULTUS_CONF_FILE" == "auto" ]; then
echo "Generating Multus configuration file ..." echo "Generating Multus configuration file ..."
found_master=false
tries=0
while [ $found_master == false ]; do
MASTER_PLUGIN="$(ls $CNI_CONF_DIR | grep -E '\.conf(list)?$' | grep -Ev '00-multus\.conf' | head -1)" MASTER_PLUGIN="$(ls $CNI_CONF_DIR | grep -E '\.conf(list)?$' | grep -Ev '00-multus\.conf' | head -1)"
if [ "$MASTER_PLUGIN" == "" ]; then if [ "$MASTER_PLUGIN" == "" ]; then
if [ $tries -lt 600 ]; then
if ! (($tries % 5)); then
echo "Attemping to find master plugin configuration, attempt $tries"
fi
let "tries+=1"
sleep 1;
else
echo "Error: Multus could not be configured: no master plugin was found." echo "Error: Multus could not be configured: no master plugin was found."
exit 1; exit 1;
else
ISOLATION_STRING=""
if [ "$MULTUS_NAMESPACE_ISOLATION" == true ]; then
ISOLATION_STRING="\"namespaceIsolation\": true,"
fi fi
else
found_master=true
MASTER_PLUGIN_JSON="$(cat $CNI_CONF_DIR/$MASTER_PLUGIN)" MASTER_PLUGIN_JSON="$(cat $CNI_CONF_DIR/$MASTER_PLUGIN)"
CONF=$(cat <<-EOF CONF=$(cat <<-EOF
{ {
"name": "multus-cni-network", "name": "multus-cni-network",
"type": "multus", "type": "multus",
$ISOLATION_STRING
"kubeconfig": "$MULTUS_KUBECONFIG_FILE_HOST", "kubeconfig": "$MULTUS_KUBECONFIG_FILE_HOST",
"delegates": [ "delegates": [
$MASTER_PLUGIN_JSON $MASTER_PLUGIN_JSON
] ]
} }
EOF EOF
) )
echo $CONF > $CNI_CONF_DIR/00-multus.conf echo $CONF > $CNI_CONF_DIR/00-multus.conf
echo "Config file created @ $CNI_CONF_DIR/00-multus.conf"
fi fi
done
fi fi
# ---------------------- end Generate "00-multus.conf". # ---------------------- end Generate "00-multus.conf".