You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2018/09/27 22:44:51 UTC
[mesos] 01/03: Skipped CNI config load if named network is not
enabled.
This is an automated email from the ASF dual-hosted git repository.
jieyu pushed a commit to branch 1.7.x
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 8ca9dd23be7765eae638dc6a8783f4c09a517df6
Author: Jie Yu <yu...@gmail.com>
AuthorDate: Wed Sep 26 21:38:05 2018 -0700
Skipped CNI config load if named network is not enabled.
If the operator didn't turn on named CNI network support (i.e., both
agent flags `network_cni_config_dir` and `network_cni_plugins_dir` are
not specified), the CNI should not attempt to load the network configs.
This patch fixed a potential CHECK failure.
Review: https://reviews.apache.org/r/68861
(cherry picked from commit 832ebc2beddbe8d38427c2ce0e5578bcaee69b35)
---
.../mesos/isolators/network/cni/cni.cpp | 41 ++++++++++++----------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
index ed47046..8af853c 100644
--- a/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
+++ b/src/slave/containerizer/mesos/isolators/network/cni/cni.cpp
@@ -1929,27 +1929,32 @@ Try<JSON::Object> NetworkCniIsolatorProcess::getNetworkConfigJSON(
}
// Cache-miss.
- Try<hashmap<string, string>> _networkConfigs = loadNetworkConfigs(
- flags.network_cni_config_dir.get(),
- flags.network_cni_plugins_dir.get());
+ if (rootDir.isSome()) {
+ CHECK_SOME(flags.network_cni_config_dir);
+ CHECK_SOME(flags.network_cni_plugins_dir);
- if (_networkConfigs.isError()) {
- return Error(
- "Encountered error while loading CNI config during "
- "a cache-miss for CNI network '" + network + "': " +
- _networkConfigs.error());
- }
+ Try<hashmap<string, string>> _networkConfigs = loadNetworkConfigs(
+ flags.network_cni_config_dir.get(),
+ flags.network_cni_plugins_dir.get());
- networkConfigs = _networkConfigs.get();
+ if (_networkConfigs.isError()) {
+ return Error(
+ "Encountered error while loading CNI config during "
+ "a cache-miss for CNI network '" + network + "': " +
+ _networkConfigs.error());
+ }
- // Do another search.
- if (networkConfigs.contains(network)) {
- // This is a best-effort retrieval of the CNI network config. So
- // if it fails in this attempt just return the `Error` instead of
- // trying to erase the network from cache. Deletion of the
- // network, in case of an error, will happen on its own in the
- // next attempt.
- return getNetworkConfigJSON(network, networkConfigs[network]);
+ networkConfigs = _networkConfigs.get();
+
+ // Do another search.
+ if (networkConfigs.contains(network)) {
+ // This is a best-effort retrieval of the CNI network config. So
+ // if it fails in this attempt just return the `Error` instead of
+ // trying to erase the network from cache. Deletion of the
+ // network, in case of an error, will happen on its own in the
+ // next attempt.
+ return getNetworkConfigJSON(network, networkConfigs[network]);
+ }
}
return Error("Unknown CNI network '" + network + "'");