Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #29 from dougbtv/updates-09-29-19-additional-bin-dir
Bug 1752453: Adds additional bin dir functionality
  • Loading branch information
openshift-merge-robot committed Sep 19, 2019
2 parents 30f0ae9 + c758877 commit d3a1815
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/configuration.md
Expand Up @@ -38,7 +38,7 @@ Following is the example of multus config file, in `/etc/cni/net.d/`.
* `type` (string, required): "multus"
* `confDir` (string, optional): directory for CNI config file that multus reads. default `/etc/cni/multus/net.d`
* `cniDir` (string, optional): Multus CNI data directory, default `/var/lib/cni/multus`
* `binDir` (string, optional): directory for CNI plugins which multus calls. default `/opt/cni/bin`
* `binDir` (string, optional): additional directory for CNI plugins which multus calls, in addition to the default (the default is typically set to `/opt/cni/bin`)
* `kubeconfig` (string, optional): kubeconfig file for the out of cluster communication with kube-apiserver. See the example [kubeconfig](https://github.com/intel/multus-cni/blob/master/doc/node-kubeconfig.yaml). If you would like to use CRD (i.e. network attachment definition), this is required
* `logFile` (string, optional): file path for log file. multus puts log in given file
* `logLevel` (string, optional): logging level ("debug", "error" or "panic")
Expand Down
4 changes: 4 additions & 0 deletions doc/how-to-use.md
Expand Up @@ -545,3 +545,7 @@ When using CRIO, you may need to restart CRIO to get the Multus configuration fi
Additionally when using CRIO, you may wish to have the CNI config file that's used as the source for `--multus-conf-file=auto` renamed. This boolean option when set to true automatically renames the file with a `.old` suffix to the original filename.

--rename-conf-file=true

When using `--multus-conf-file=auto` you may also care to specify a `binDir` in the configuration, this can be accomplished using the `--additional-bin-dir` option.

--additional-bin-dir=/opt/multus/bin
11 changes: 11 additions & 0 deletions images/entrypoint.sh
Expand Up @@ -20,6 +20,7 @@ EOF
# Set our known directories.
CNI_CONF_DIR="/host/etc/cni/net.d"
CNI_BIN_DIR="/host/opt/cni/bin"
ADDITIONAL_BIN_DIR=""
MULTUS_CONF_FILE="/usr/src/multus-cni/images/70-multus.conf"
MULTUS_AUTOCONF_DIR="/host/etc/cni/net.d"
MULTUS_BIN_FILE="/usr/src/multus-cni/bin/multus"
Expand Down Expand Up @@ -57,6 +58,7 @@ function usage()
echo -e "\t--override-network-name=false (used only with --multus-conf-file=auto)"
echo -e "\t--cleanup-config-on-exit=false (used only with --multus-conf-file=auto)"
echo -e "\t--rename-conf-file=false (used only with --multus-conf-file=auto)"
echo -e "\t--additional-bin-dir=$ADDITIONAL_BIN_DIR (adds binDir option to configuration, used only with --multus-conf-file=auto)"
echo -e "\t--restart-crio=false (restarts CRIO after config file is generated)"
}

Expand Down Expand Up @@ -126,6 +128,9 @@ while [ "$1" != "" ]; do
--rename-conf-file)
RENAME_SOURCE_CONFIG_FILE=$VALUE
;;
--additional-bin-dir)
ADDITIONAL_BIN_DIR=$VALUE
;;
*)
warn "unknown parameter \"$PARAM\""
;;
Expand Down Expand Up @@ -284,6 +289,11 @@ if [ "$MULTUS_CONF_FILE" == "auto" ]; then
CNI_VERSION_STRING="\"cniVersion\": \"$CNI_VERSION\","
fi

ADDITIONAL_BIN_DIR_STRING=""
if [ ! -z "${ADDITIONAL_BIN_DIR// }" ]; then
ADDITIONAL_BIN_DIR_STRING="\"binDir\": \"$ADDITIONAL_BIN_DIR\","
fi

if [ "$OVERRIDE_NETWORK_NAME" == "true" ]; then
MASTER_PLUGIN_NET_NAME="$(cat $MULTUS_AUTOCONF_DIR/$MASTER_PLUGIN | \
python -c 'import json,sys;print json.load(sys.stdin)["name"]')"
Expand All @@ -302,6 +312,7 @@ if [ "$MULTUS_CONF_FILE" == "auto" ]; then
$ISOLATION_STRING
$LOG_LEVEL_STRING
$LOG_FILE_STRING
$ADDITIONAL_BIN_DIR_STRING
"kubeconfig": "$MULTUS_KUBECONFIG_FILE_HOST",
"delegates": [
$MASTER_PLUGIN_JSON
Expand Down
7 changes: 7 additions & 0 deletions multus/multus.go
Expand Up @@ -238,7 +238,10 @@ func delegateAdd(exec invoke.Exec, ifName string, delegate *types.DelegateNetCon
return nil, logging.Errorf("Multus: error in invoke Conflist add - %q: %v", delegate.ConfList.Name, err)
}
} else {
origpath := os.Getenv("CNI_PATH")
os.Setenv("CNI_PATH", origpath+":"+binDir)
result, err = invoke.DelegateAdd(context.Background(), delegate.Conf.Type, delegate.Bytes, exec)
os.Setenv("CNI_PATH", origpath)
if err != nil {
return nil, logging.Errorf("Multus: error in invoke Delegate add - %q: %v", delegate.Conf.Type, err)
}
Expand Down Expand Up @@ -282,9 +285,13 @@ func delegateDel(exec invoke.Exec, ifName string, delegateConf *types.DelegateNe
return logging.Errorf("Multus: error in invoke Conflist Del - %q: %v", delegateConf.ConfList.Name, err)
}
} else {
origpath := os.Getenv("CNI_PATH")
os.Setenv("CNI_PATH", origpath+":"+binDir)
if err = invoke.DelegateDel(context.Background(), delegateConf.Conf.Type, delegateConf.Bytes, exec); err != nil {
os.Setenv("CNI_PATH", origpath)
return logging.Errorf("Multus: error in invoke Delegate del - %q: %v", delegateConf.Conf.Type, err)
}
os.Setenv("CNI_PATH", origpath)
}

return err
Expand Down

0 comments on commit d3a1815

Please sign in to comment.