]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
[EDF29150] : Put additionnal fault tolerant mecanism
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 5 Jun 2024 11:27:15 +0000 (13:27 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 5 Jun 2024 11:27:15 +0000 (13:27 +0200)
idl/SALOME_Component.idl
src/Container/Container_i.cxx
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_Container_i.hxx
src/Container/SALOME_PyNode.py
src/Launcher/Test/testCrashProofContainer.py

index 2d7d3ea5bd4971e20891685b1c5c2bee4c96b39a..8911badd941d26a40adb3a86bc9b4972b20d68c7 100644 (file)
@@ -92,6 +92,10 @@ module Engines
     
     void set_number_of_retry(in long nbRetry);
 
+    void set_startup_code(in string codeAtStartUp);
+
+    string get_startup_code();
+
     void addLogFileNameGroup(in vectorOfString groupOfLogFileNames);
     
     vectorOfVectorOfString getAllLogFileNameGroups();
index 4e0d5fe93fd0bd565887c1934bec78595da94a12..4841ee2a0581cc24aaf27c635000bbf7b4f478c0 100644 (file)
@@ -1185,6 +1185,16 @@ void Abstract_Engines_Container_i::set_number_of_retry(CORBA::Long nbRetry)
   SALOME::SetNumberOfRetry( nbRetry );
 }
 
+void Abstract_Engines_Container_i::set_startup_code(const char *codeAtStartUp)
+{
+  _code_at_startup = codeAtStartUp;
+}
+
+char *Abstract_Engines_Container_i::get_startup_code()
+{
+  return CORBA::string_dup( this->_code_at_startup.c_str() );
+}
+
 Engines::vectorOfString_var FromVecStringCppToCORBA( const std::vector<std::string>& group)
 {
   Engines::vectorOfString_var ret( new Engines::vectorOfString );
index 2ee5639bce06ee691dc02b32a942cfa40fb8ed75..4ac6468c81a52ee96312a3aadb64538a1cdcdeae 100644 (file)
@@ -566,6 +566,7 @@ Engines::Container_ptr SALOME_ContainerManager::GiveContainer(const Engines::Con
         if( !_code_to_exe_on_startup.empty() )
         {
           INFOS("[GiveContainer] container " << containerNameInNS << " python code executed " << _code_to_exe_on_startup);
+          cont->set_startup_code( _code_to_exe_on_startup.c_str() );
           cont->execute_python_code( _code_to_exe_on_startup.c_str() );
         }
         INFOS("[GiveContainer] container " << containerNameInNS << " verbosity positionning Activation = " << SALOME::VerbosityActivated() << " Verbosity Level = " << SALOME::VerbosityLevelStr());
index 08c174254c09cff57123be2289ca9f97d7fc380f..b6ace750dc0efcb2243f46f1f82b107c6c37c35a 100644 (file)
@@ -87,6 +87,10 @@ public:
   void set_big_obj_on_disk_directory(const char *directory) override;
 
   void set_number_of_retry(CORBA::Long nbRetry) override;
+  
+  void set_startup_code(const char *codeAtStartUp) override;
+
+  char *get_startup_code() override;
 
   void addLogFileNameGroup(const Engines::vectorOfString& groupOfLogFileNames) override;
     
@@ -202,6 +206,7 @@ protected:
   std::string _localfilename;
   std::string _load_script;
   std::string _py_container_name;
+  std::string _code_at_startup;
   CORBA::ORB_var _orb;
   PortableServer::POA_var _poa;
   PortableServer::ObjectId *_id;
index 0b0c9b3cd66c07b02c19efa156cc3e8c481a715f..cb8d1abd2306982cbc0175e69a80879406905771 100644 (file)
@@ -840,7 +840,10 @@ def ExecCrashProofGeneric( code, context, outargsname, containerRef, instanceOfL
       return True,StdErrTreatment(closeEyesOnErrorAtExit , stderr)
     if not closeEyesOnErrorAtExit:
       return False, stderr
-    return stderr[-len(MY_KEY_TO_DETECT_FINISH):] == MY_KEY_TO_DETECT_FINISH,stderr[:-len(MY_KEY_TO_DETECT_FINISH)]
+    if stderr[-len(MY_KEY_TO_DETECT_FINISH):] == MY_KEY_TO_DETECT_FINISH:
+      return True,stderr[:-len(MY_KEY_TO_DETECT_FINISH)]
+    else:
+      return False,stderr
 
   #
   def InternalExecResistant( code, context, outargsname):
@@ -852,6 +855,7 @@ def ExecCrashProofGeneric( code, context, outargsname, containerRef, instanceOfL
     def RetrieveUniquePartFromPfx( fname ):
       return os.path.splitext( os.path.basename(fname)[len(EXEC_CODE_FNAME_PXF):] )[0]
     with tempfile.NamedTemporaryFile(dir=os.getcwd(),prefix=EXEC_CODE_FNAME_PXF,suffix=".py", mode="w", delete = False) as codeFd:
+      codeFd.write( "{}\n".format( containerRef.get_startup_code() ) )
       codeFd.write( code )
       if closeEyesOnErrorAtExit:
         codeFd.write( """
index 0d2a168fe91a1e232aa2d770b4991ed398602ad6..e494959d4ece0840fe52c53dc3303eb0065f2b06 100644 (file)
@@ -63,7 +63,7 @@ def ErrorAtexit():
 atexit.register(ErrorAtexit)
 
 print("OKKKKKK")
-j = 9 * i
+j = 9 * i * a
 print("OKKKKKK3333")
 """
 
@@ -179,6 +179,7 @@ class testPerfLogManager1(unittest.TestCase):
         hostname = "localhost"
         cp = pylauncher.GetRequestForGiveContainer(hostname,"container_crash_test")
         salome.cm.SetNumberOfRetry( 3 )
+        salome.cm.SetCodeOnContainerStartUp("""a = 2""")
         salome.cm.SetBigObjOnDiskThreshold(1000)
         salome.cm.SetOverrideEnvForContainersSimple(env = [])
         cont = salome.cm.GiveContainer(cp)
@@ -188,7 +189,7 @@ class testPerfLogManager1(unittest.TestCase):
         pyscript.executeFirst(refPtr)
         ret = pyscript.executeSecond(["j"])
         ret = pickle.loads( SALOME_PyNode.SeqByteReceiver(ret[0]).data() )
-        self.assertEqual(ret,27)
+        self.assertEqual(ret,54)
         with open(cont.locallogfilename) as f:
             logCont = f.read( )
             self.assertTrue( "WARNING : Retry #" in logCont)