You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by qi...@apache.org on 2020/08/25 01:19:06 UTC

[mesos] 02/02: Refactored state recovery in `volume/csi` isolator.

This is an automated email from the ASF dual-hosted git repository.

qianzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit d8647b018fbcfc38ccf0e39bfeae9118e275068f
Author: Qian Zhang <zh...@gmail.com>
AuthorDate: Thu Aug 20 17:09:36 2020 +0800

    Refactored state recovery in `volume/csi` isolator.
    
    Read the checkpointed CSI volume state directly in protobuf message way.
    
    Review: https://reviews.apache.org/r/72789
---
 .../mesos/isolators/volume/csi/isolator.cpp            | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/src/slave/containerizer/mesos/isolators/volume/csi/isolator.cpp b/src/slave/containerizer/mesos/isolators/volume/csi/isolator.cpp
index 535974b..02ef1f2 100644
--- a/src/slave/containerizer/mesos/isolators/volume/csi/isolator.cpp
+++ b/src/slave/containerizer/mesos/isolators/volume/csi/isolator.cpp
@@ -198,14 +198,12 @@ Try<Nothing> VolumeCSIIsolatorProcess::recoverContainer(
     return Nothing();
   }
 
-  Result<string> read = state::read<string>(volumesPath);
+  Result<CSIVolumes> read = state::read<CSIVolumes>(volumesPath);
   if (read.isError()) {
     return Error(
         "Failed to read the CSI volumes checkpoint file '" +
         volumesPath + "': " + read.error());
-  }
-
-  if (read->empty()) {
+  } else if (read.isNone()) {
     // This could happen if agent is hard rebooted after the checkpoint file is
     // created but before the data is synced on disk.
     LOG(WARNING) << "The CSI volumes checkpointed at '" << volumesPath
@@ -220,18 +218,8 @@ Try<Nothing> VolumeCSIIsolatorProcess::recoverContainer(
     return Nothing();
   }
 
-  Try<JSON::Object> json = JSON::parse<JSON::Object>(read.get());
-  if (json.isError()) {
-    return Error("JSON parse failed: " + json.error());
-  }
-
-  Try<CSIVolumes> parse = ::protobuf::parse<CSIVolumes>(json.get());
-  if (parse.isError()) {
-    return Error("Protobuf parse failed: " + parse.error());
-  }
-
   hashset<CSIVolume> volumes;
-  foreach (const CSIVolume& volume, parse->volumes()) {
+  foreach (const CSIVolume& volume, read->volumes()) {
     VLOG(1) << "Recovering CSI volume with plugin '" << volume.plugin_name()
             << "' and ID '" << volume.id() << "' for container " << containerId;