Re: [devel] [PATCH 1/2] base: Add support to direct OpenSAF logging to local node file [#2306]

2018-04-19 Thread Minh Hon Chau

Hi all,


V3 has been sent for review, it's basically not many different to V2, it 
mainly moves the TraceLog to a separate file as Hans' suggestion.



Regards,

Minh


On 19/04/18 15:28, Minh Hon Chau wrote:


Hi Hans,


That's why it needs explicitly "extern C++", I have changed it as your 
suggestion


I have sent out V2, still keep TraceLog in logtrace.h as of now, so it 
can be included once for either c or c++.


Let's see from Anders and Ravi if we have any ideas, I'm happy to move 
it out of logtrace.h too, maybe the existing class Trace as well



Regards,

Minh



On 19/04/18 06:47, Hans Nordebäck wrote:


Hi Minh,


One part of this problem is in mbcsv_papi.h, the

#ifdef __cplusplus

extern "C" {

should at least be after the  #include stmts. Fixing this should 
remove the need for the extern "C++". But moving this part to


a separate header file would also be good.


As a general comment, (all OpenSAF), is that only extern "C" should 
be needed, and it should


be carefully placed only where it is required, c++ access to a c 
function/variable with external linkage, not placing


it in a too wide scope. It can be placed around a group of 
c-functions but not the complete header file.


/Thanks HansN


*Från:* Hans Nordebäck 
*Skickat:* den 18 april 2018 20:43:22
*Till:* Minh Hon Chau; Anders Widell; ravisekhar.ko...@oracle.com
*Kopia:* opensaf-devel@lists.sourceforge.net
*Ämne:* Re: [devel] [PATCH 1/2] base: Add support to direct OpenSAF 
logging to local node file [#2306]

Hi Minh,


yes, before this patch logtrace.h was a c header file callable from c 
and c++. Now it is a c/c++ header file


so including it from a c program without the extern "c++" will fail. 
In the first review comment I suggested


to move this part to a separate header file and keep logtrace.h as 
before.


/Regards HansN


Från: Minh Hon Chau 
Skickat: den 18 april 2018 16:09:35
Till: Hans Nordebäck; Anders Widell; ravisekhar.ko...@oracle.com
Kopia: opensaf-devel@lists.sourceforge.net
Ämne: Re: [PATCH 1/2] base: Add support to direct OpenSAF logging to 
local node file [#2306]


Hi Hans,

One comment regarding extern C++ as below

Thanks,

Minh


On 18/04/18 23:37, Hans Nordebäck wrote:
> Hi Minh,
>
>   See my comments below.
>
> /Thanks HansN
>
> -Original Message-
> From: Minh Hon Chau [mailto:minh.c...@dektech.com.au]
> Sent: den 18 april 2018 15:20
> To: Hans Nordebäck ; Anders Widell 
; ravisekhar.ko...@oracle.com

> Cc: opensaf-devel@lists.sourceforge.net
> Subject: Re: [PATCH 1/2] base: Add support to direct OpenSAF 
logging to local node file [#2306]

>
> Hi Hans,
>
> Please check my response with [Minh]
>
> Thanks
>
> Minh
>
>
> On 18/04/18 22:40, Hans Nordeback wrote:
>> Hi Minh,
>>
>> ack, code review only. Some comments below.
>>
>> /Thanks HansN
>>
>>
>> On 04/12/2018 01:12 AM, Minh Chau wrote:
>>> Unify TraceLog and MdsLog class to one class (TraceLog) so it can be
>>> used as a common log client.
>>> Add new instance TraceLog for OpenSAF logging to local file, which
>>> can be enabled/disabled via environment variable OSAF_LOCAL_NODE_LOG
>>> ---
>>>    src/base/logtrace.cc | 167
>>> ++-
>>>    src/base/logtrace.h  |  50 +--
>>>    src/mds/mds_log.cc   | 114 +++
>>>    3 files changed, 140 insertions(+), 191 deletions(-)
>>>
>>> diff --git a/src/base/logtrace.cc b/src/base/logtrace.cc index
>>> b046fab..857e31c 100644
>>> --- a/src/base/logtrace.cc
>>> +++ b/src/base/logtrace.cc
>>> @@ -36,15 +36,10 @@
>>>    #include 
>>>    #include 
>>>    #include 
>>> -#include "base/buffer.h"
>>> -#include "base/conf.h"
>>> -#include "base/log_message.h"
>>> -#include "base/macros.h"
>>> -#include "base/mutex.h"
>>> +#include "base/getenv.h"
>>>    #include "base/ncsgl_defs.h"
>>>    #include "base/osaf_utility.h"
>>>    #include "base/time.h"
>>> -#include "base/unix_client_socket.h"
>>>    #include "dtm/common/osaflog_protocol.h"
>>>  namespace global {
>>> @@ -55,65 +50,38 @@ const char *const prefix_name[] = {"EM", "AL",
>>> "CR", "ER", "WA", "NO", "IN",
>>>   "T6", "T7", "T8", ">>", "<<"};
>>>    char *msg_id;
>>>    int logmask;
>>> +const char* osaf_log_file = "osaf.log"; bool enable_osaf_log =
>>> +false;
>>>  }  // namespace global
>>>    -class TraceLog {
>>> - public:
>>> -  static bool Init();
>>> -  static void Log(base::LogMessage::Severity severity, const char
>>> *fmt,
>>> -  va_list ap);
>>> -
>>> - private:
>>> -  TraceLog(const std::string &fqdn, const std::string &app_name,
>>> -   uint32_t proc_id, const std::string &msg_id,
>>> -   const std::string &socket_name);
>>> -  void LogInternal(base::LogMessage::Severity severity, const char
>>> *fmt,
>>> -   va_list ap);
>>> -  static constexpr const uint32

[devel] [PATCH 1/2] base: Add support to direct OpenSAF logging to local node file V3 [#2306]

2018-04-19 Thread Minh Chau
Unify TraceLog and MdsLog class to one class (TraceLog) so it can be
used as a common log client.
Add new instance TraceLog for OpenSAF logging to local file, which can
be enabled/disabled via environment variable OSAF_LOCAL_NODE_LOG.
---
 src/base/Makefile.am|   2 +
 src/base/logtrace.cc| 195 
 src/base/logtrace.h |  12 ++-
 src/base/logtrace_client.cc | 105 
 src/base/logtrace_client.h  |  55 +
 src/mds/mds_log.cc  | 132 +++---
 6 files changed, 234 insertions(+), 267 deletions(-)
 create mode 100644 src/base/logtrace_client.cc
 create mode 100644 src/base/logtrace_client.h

diff --git a/src/base/Makefile.am b/src/base/Makefile.am
index eacc009..aa94423 100644
--- a/src/base/Makefile.am
+++ b/src/base/Makefile.am
@@ -48,6 +48,7 @@ lib_libopensaf_core_la_SOURCES += \
src/base/hj_ubaid.c \
src/base/log_message.cc \
src/base/logtrace.cc \
+   src/base/logtrace_client.cc \
src/base/mutex.cc \
src/base/ncs_main_pub.c \
src/base/ncs_sprr.c \
@@ -94,6 +95,7 @@ noinst_HEADERS += \
src/base/hash.h \
src/base/log_message.h \
src/base/logtrace.h \
+   src/base/logtrace_client.h \
src/base/macros.h \
src/base/mutex.h \
src/base/ncs_edu.h \
diff --git a/src/base/logtrace.cc b/src/base/logtrace.cc
index b046fab..fd3d829 100644
--- a/src/base/logtrace.cc
+++ b/src/base/logtrace.cc
@@ -18,10 +18,6 @@
  */
 
 #include "base/logtrace.h"
-#include 
-#include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -30,22 +26,9 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include "base/buffer.h"
-#include "base/conf.h"
-#include "base/log_message.h"
-#include "base/macros.h"
-#include "base/mutex.h"
+#include "base/getenv.h"
+#include "base/logtrace_client.h"
 #include "base/ncsgl_defs.h"
-#include "base/osaf_utility.h"
-#include "base/time.h"
-#include "base/unix_client_socket.h"
-#include "dtm/common/osaflog_protocol.h"
 
 namespace global {
 
@@ -55,107 +38,13 @@ const char *const prefix_name[] = {"EM", "AL", "CR", "ER", 
"WA", "NO", "IN",
"T6", "T7", "T8", ">>", "<<"};
 char *msg_id;
 int logmask;
+const char* osaf_log_file = "osaf.log";
+bool enable_osaf_log = false;
 
 }  // namespace global
 
-class TraceLog {
- public:
-  static bool Init();
-  static void Log(base::LogMessage::Severity severity, const char *fmt,
-  va_list ap);
-
- private:
-  TraceLog(const std::string &fqdn, const std::string &app_name,
-   uint32_t proc_id, const std::string &msg_id,
-   const std::string &socket_name);
-  void LogInternal(base::LogMessage::Severity severity, const char *fmt,
-   va_list ap);
-  static constexpr const uint32_t kMaxSequenceId = uint32_t{0x7fff};
-  static TraceLog *instance_;
-  const base::LogMessage::HostName fqdn_;
-  const base::LogMessage::AppName app_name_;
-  const base::LogMessage::ProcId proc_id_;
-  const base::LogMessage::MsgId msg_id_;
-  uint32_t sequence_id_;
-  base::UnixClientSocket log_socket_;
-  base::Buffer<512> buffer_;
-  base::Mutex mutex_;
-
-  DELETE_COPY_AND_MOVE_OPERATORS(TraceLog);
-};
-
-TraceLog *TraceLog::instance_ = nullptr;
-
-TraceLog::TraceLog(const std::string &fqdn, const std::string &app_name,
-   uint32_t proc_id, const std::string &msg_id,
-   const std::string &socket_name)
-: fqdn_{base::LogMessage::HostName{fqdn}},
-  app_name_{base::LogMessage::AppName{app_name}},
-  proc_id_{base::LogMessage::ProcId{std::to_string(proc_id)}},
-  msg_id_{base::LogMessage::MsgId{msg_id}},
-  sequence_id_{1},
-  log_socket_{socket_name, base::UnixSocket::kBlocking},
-  buffer_{},
-  mutex_{} {}
-
-bool TraceLog::Init() {
-  if (instance_ != nullptr) return false;
-  char app_name[49];
-  char pid_path[1024];
-  uint32_t process_id = getpid();
-  char *token, *saveptr;
-  char *pid_name = nullptr;
-
-  memset(app_name, 0, 49);
-  memset(pid_path, 0, 1024);
-
-  snprintf(pid_path, sizeof(pid_path), "/proc/%" PRIu32 "/cmdline", 
process_id);
-  FILE *f = fopen(pid_path, "r");
-  if (f != nullptr) {
-size_t size;
-size = fread(pid_path, sizeof(char), 1024, f);
-if (size > 0) {
-  if ('\n' == pid_path[size - 1]) pid_path[size - 1] = '\0';
-}
-fclose(f);
-  } else {
-pid_path[0] = '\0';
-  }
-  token = strtok_r(pid_path, "/", &saveptr);
-  while (token != nullptr) {
-pid_name = token;
-token = strtok_r(nullptr, "/", &saveptr);
-  }
-  if (snprintf(app_name, sizeof(app_name), "%s", pid_name) < 0) {
-app_name[0] = '\0';
-  }
-  base::Conf::InitFullyQualifiedDomainName();
-  const std::string &fqdn = base::Conf::FullyQualifiedDomainName();
-  instance_ = new TraceLog{fqdn, app_name, process_id, global::msg_id,
-  

[devel] [PATCH 0/2] Review Request for base: Add support for OpenSAF local log file V3 [#2306]

2018-04-19 Thread Minh Chau
Summary: base: Add support to direct OpenSAF logging to local node file V3 
[#2306]
Review request for Ticket(s): 2306
Peer Reviewer(s): Anders, Hans, Ravi
Pull request to: *** LIST THE PERSON WITH PUSH ACCESS HERE ***
Affected branch(es): develop
Development branch: ticket-2306
Base revision: 72b6ed1fdd6851d8af6bb3dcd2fea25d8095ad1e
Personal repository: git://git.code.sf.net/u/minh-chau/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  y
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
*** EXPLAIN/COMMENT THE PATCH SERIES HERE ***

This V3 moves the TraceLog into new file
logtrace_client.h/cc

revision 30417b4eced76c5cc924cc2ec96a10c241da0011
Author: Minh Chau 
Date:   Fri, 20 Apr 2018 09:29:41 +1000

base: Add OSAF_LOCAL_NODE_LOG environment variable to osaf service conf file 
[#2306]



revision 26be4c6c2fe33b8b92d4c2d46c02ad50c39896c7
Author: Minh Chau 
Date:   Fri, 20 Apr 2018 09:28:35 +1000

base: Add support to direct OpenSAF logging to local node file V3 [#2306]

Unify TraceLog and MdsLog class to one class (TraceLog) so it can be
used as a common log client.
Add new instance TraceLog for OpenSAF logging to local file, which can
be enabled/disabled via environment variable OSAF_LOCAL_NODE_LOG.



Added Files:

 src/base/logtrace_client.cc
 src/base/logtrace_client.h


Complete diffstat:
--
 src/amf/amfd/amfd.conf  |   5 ++
 src/amf/amfnd/amfnd.conf|   5 ++
 src/amf/amfwd/amfwdog.conf  |   5 ++
 src/base/Makefile.am|   2 +
 src/base/logtrace.cc| 195 
 src/base/logtrace.h |  12 ++-
 src/base/logtrace_client.cc | 105 
 src/base/logtrace_client.h  |  55 +
 src/ckpt/ckptd/ckptd.conf   |   5 ++
 src/ckpt/ckptnd/ckptnd.conf |   5 ++
 src/clm/clmd/clmd.conf  |   5 ++
 src/clm/clmnd/clmna.conf|   5 ++
 src/dtm/dtmnd/dtmd.conf |   5 ++
 src/evt/evtd/evtd.conf  |   5 ++
 src/fm/fmd/fmd.conf |   5 ++
 src/imm/immd/immd.conf  |   4 +
 src/imm/immnd/immnd.conf|   5 ++
 src/lck/lckd/lckd.conf  |   5 ++
 src/lck/lcknd/lcknd.conf|   5 ++
 src/log/logd/logd.conf  |   5 ++
 src/mds/mds_log.cc  | 132 +++---
 src/msg/msgd/msgd.conf  |   5 ++
 src/msg/msgnd/msgnd.conf|   5 ++
 src/ntf/ntfd/ntfd.conf  |   5 ++
 src/plm/plmd/plmd.conf  |   5 ++
 src/rde/rded/rde.conf   |   5 ++
 src/smf/smfd/smfd.conf  |   5 ++
 src/smf/smfnd/smfnd.conf|   5 ++
 28 files changed, 343 insertions(+), 267 deletions(-)


Testing Commands:
-
*** LIST THE COMMAND LINE TOOLS/STEPS TO TEST YOUR CHANGES ***


Testing, Expected Results:
--
*** PASTE COMMAND OUTPUTS / TEST RESULTS ***


Conditions of Submission:
-
ack from reviewers


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should pl

[devel] [PATCH 2/2] base: Add OSAF_LOCAL_NODE_LOG environment variable to osaf service conf file [#2306]

2018-04-19 Thread Minh Chau
---
 src/amf/amfd/amfd.conf  | 5 +
 src/amf/amfnd/amfnd.conf| 5 +
 src/amf/amfwd/amfwdog.conf  | 5 +
 src/ckpt/ckptd/ckptd.conf   | 5 +
 src/ckpt/ckptnd/ckptnd.conf | 5 +
 src/clm/clmd/clmd.conf  | 5 +
 src/clm/clmnd/clmna.conf| 5 +
 src/dtm/dtmnd/dtmd.conf | 5 +
 src/evt/evtd/evtd.conf  | 5 +
 src/fm/fmd/fmd.conf | 5 +
 src/imm/immd/immd.conf  | 4 
 src/imm/immnd/immnd.conf| 5 +
 src/lck/lckd/lckd.conf  | 5 +
 src/lck/lcknd/lcknd.conf| 5 +
 src/log/logd/logd.conf  | 5 +
 src/msg/msgd/msgd.conf  | 5 +
 src/msg/msgnd/msgnd.conf| 5 +
 src/ntf/ntfd/ntfd.conf  | 5 +
 src/plm/plmd/plmd.conf  | 5 +
 src/rde/rded/rde.conf   | 5 +
 src/smf/smfd/smfd.conf  | 5 +
 src/smf/smfnd/smfnd.conf| 5 +
 22 files changed, 109 insertions(+)

diff --git a/src/amf/amfd/amfd.conf b/src/amf/amfd/amfd.conf
index 6ee111b..9da3bec 100644
--- a/src/amf/amfd/amfd.conf
+++ b/src/amf/amfd/amfd.conf
@@ -19,3 +19,8 @@ export AVSV_HB_PERIOD=100
 
 # Uncomment the next line to enable info level logging
 #args="--loglevel=info"
+
+# Only log priority LOG_WARNING and higher to the system log file.
+# All logging will be recorded in a new node local log file 
$PKGLOGDIR/osaf.log.
+# Uncomment the next line to enable this service to log to OpenSAF node local 
log file.
+# export OSAF_LOCAL_NODE_LOG=1
diff --git a/src/amf/amfnd/amfnd.conf b/src/amf/amfnd/amfnd.conf
index 2c13eda..8e8bfdb 100644
--- a/src/amf/amfnd/amfnd.conf
+++ b/src/amf/amfnd/amfnd.conf
@@ -20,3 +20,8 @@ export AVND_PM_MONITORING_RATE=1000
 
 # Uncomment the next line to enable info level logging
 #args="--loglevel=info"
+
+# Only log priority LOG_WARNING and higher to the system log file.
+# All logging will be recorded in a new node local log file 
$PKGLOGDIR/osaf.log.
+# Uncomment the next line to enable this service to log to OpenSAF node local 
log file.
+# export OSAF_LOCAL_NODE_LOG=1
diff --git a/src/amf/amfwd/amfwdog.conf b/src/amf/amfwd/amfwdog.conf
index a3c326e..44a1423 100644
--- a/src/amf/amfwd/amfwdog.conf
+++ b/src/amf/amfwd/amfwdog.conf
@@ -12,3 +12,8 @@ export AMFWDOG_ENV_HEALTHCHECK_KEY="Default"
 
 # Uncomment the next line to enable info level logging
 #args="--loglevel=info"
+
+# Only log priority LOG_WARNING and higher to the system log file.
+# All logging will be recorded in a new node local log file 
$PKGLOGDIR/osaf.log.
+# Uncomment the next line to enable this service to log to OpenSAF node local 
log file.
+# export OSAF_LOCAL_NODE_LOG=1
diff --git a/src/ckpt/ckptd/ckptd.conf b/src/ckpt/ckptd/ckptd.conf
index a682e25..145f232 100644
--- a/src/ckpt/ckptd/ckptd.conf
+++ b/src/ckpt/ckptd/ckptd.conf
@@ -9,3 +9,8 @@ export CPSV_ENV_HEALTHCHECK_KEY="Default"
 
 # Uncomment the next line to enable info level logging
 #args="--loglevel=info"
+
+# Only log priority LOG_WARNING and higher to the system log file.
+# All logging will be recorded in a new node local log file 
$PKGLOGDIR/osaf.log.
+# Uncomment the next line to enable this service to log to OpenSAF node local 
log file.
+# export OSAF_LOCAL_NODE_LOG=1
diff --git a/src/ckpt/ckptnd/ckptnd.conf b/src/ckpt/ckptnd/ckptnd.conf
index ec95c37..717b618 100644
--- a/src/ckpt/ckptnd/ckptnd.conf
+++ b/src/ckpt/ckptnd/ckptnd.conf
@@ -20,3 +20,8 @@ export CPSV_ENV_HEALTHCHECK_KEY="Default"
 
 # Uncomment the next line to enable info level logging
 #args="--loglevel=info"
+
+# Only log priority LOG_WARNING and higher to the system log file.
+# All logging will be recorded in a new node local log file 
$PKGLOGDIR/osaf.log.
+# Uncomment the next line to enable this service to log to OpenSAF node local 
log file.
+# export OSAF_LOCAL_NODE_LOG=1
diff --git a/src/clm/clmd/clmd.conf b/src/clm/clmd/clmd.conf
index 57f3c62..041c888 100644
--- a/src/clm/clmd/clmd.conf
+++ b/src/clm/clmd/clmd.conf
@@ -12,3 +12,8 @@ export CLMSV_ENV_HEALTHCHECK_KEY="Default"
 
 # Uncomment the next line to enable info level logging
 #args="--loglevel=info"
+
+# Only log priority LOG_WARNING and higher to the system log file.
+# All logging will be recorded in a new node local log file 
$PKGLOGDIR/osaf.log.
+# Uncomment the next line to enable this service to log to OpenSAF node local 
log file.
+# export OSAF_LOCAL_NODE_LOG=1
diff --git a/src/clm/clmnd/clmna.conf b/src/clm/clmnd/clmna.conf
index ed4b1a7..5328724 100644
--- a/src/clm/clmnd/clmna.conf
+++ b/src/clm/clmnd/clmna.conf
@@ -37,3 +37,8 @@ export CLMNA_ENV_HEALTHCHECK_KEY="Default"
 
 # Uncomment the next line to enable info level logging
 #args="--loglevel=info"
+
+# Only log priority LOG_WARNING and higher to the system log file.
+# All logging will be recorded in a new node local log file 
$PKGLOGDIR/osaf.log.
+# Uncomment the next line to enable this service to log to OpenSAF node local 
log file.
+# export OSAF_LOCAL_NODE_LOG=1
diff --git a/src/dtm/dtmnd/dtmd.conf b/src/dtm/dtmnd/dtmd.conf
index b9299f7..

Re: [devel] [PATCH 1/1] nid: restart opensafd on failure when systemd enabled [#2839]

2018-04-19 Thread Hans Nordebäck
Hi Alex,


a question, if opensafd fails, (assert or exit code ne 0) a reboot of the node 
will be performed if REBOOT_ON_FAIL_TIMEOUT

is configured, I have not checked, but how do systemd handle the reboot request 
if Restart=on-failure is set?


/BR HansN


Från: Alex Jones 
Skickat: den 19 april 2018 17:27:27
Till: Hans Nordebäck; Anders Widell
Kopia: opensaf-devel@lists.sourceforge.net; Alex Jones
Ämne: [PATCH 1/1] nid: restart opensafd on failure when systemd enabled [#2839]

Under certain circumstances opensafd fails to start (immnd or dtmd crashes,
etc).

Apr 19 15:07:31 ams-idsp-46-novnfm osafdtmd[3315]: 
src/dtm/dtmnd/dtm_intra_svc.cc:1778: dtm_process_internode_service_up_msg: 
Assertion '0' failed.

We can tell systemd to restart opensafd if it fails to start.
---
 src/nid/opensafd.service.in | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/nid/opensafd.service.in b/src/nid/opensafd.service.in
index 7f4d75ee3..6050f5e88 100644
--- a/src/nid/opensafd.service.in
+++ b/src/nid/opensafd.service.in
@@ -12,5 +12,7 @@ ControlGroup=cpu:/
 TimeoutStartSec=3hours
 KillMode=none
 @systemdtasksmax@
+Restart=on-failure
+
 [Install]
 WantedBy=multi-user.target
--
2.13.6

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 0/1] Review Request for nid: restart opensafd on failure when systemd enabled [#2839]

2018-04-19 Thread Alex Jones
Summary: nid: restart opensafd on failure when systemd enabled [#2839]
Review request for Ticket(s): 2839
Peer Reviewer(s): Hans, Anders
Pull request to: 
Affected branch(es): develop
Development branch: ticket-2839
Base revision: 72b6ed1fdd6851d8af6bb3dcd2fea25d8095ad1e
Personal repository: git://git.code.sf.net/u/trguitar/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-

revision c67596599b7728ea45e2d449d5ba3c3103bf8452
Author: Alex Jones 
Date:   Thu, 19 Apr 2018 11:17:06 -0400

nid: restart opensafd on failure when systemd enabled [#2839]

Under certain circumstances opensafd fails to start (immnd or dtmd crashes,
etc).

Apr 19 15:07:31 ams-idsp-46-novnfm osafdtmd[3315]: 
src/dtm/dtmnd/dtm_intra_svc.cc:1778: dtm_process_internode_service_up_msg: 
Assertion '0' failed.

We can tell systemd to restart opensafd if it fails to start.



Complete diffstat:
--
 src/nid/opensafd.service.in | 2 ++
 1 file changed, 2 insertions(+)


Testing Commands:
-
systemctl start opensafd


Testing, Expected Results:
--
opensafd should restart if it fails to come up


Conditions of Submission:
-
Apr 25, or ack from developer


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 1/1] nid: restart opensafd on failure when systemd enabled [#2839]

2018-04-19 Thread Alex Jones
Under certain circumstances opensafd fails to start (immnd or dtmd crashes,
etc).

Apr 19 15:07:31 ams-idsp-46-novnfm osafdtmd[3315]: 
src/dtm/dtmnd/dtm_intra_svc.cc:1778: dtm_process_internode_service_up_msg: 
Assertion '0' failed.

We can tell systemd to restart opensafd if it fails to start.
---
 src/nid/opensafd.service.in | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/nid/opensafd.service.in b/src/nid/opensafd.service.in
index 7f4d75ee3..6050f5e88 100644
--- a/src/nid/opensafd.service.in
+++ b/src/nid/opensafd.service.in
@@ -12,5 +12,7 @@ ControlGroup=cpu:/
 TimeoutStartSec=3hours
 KillMode=none
 @systemdtasksmax@
+Restart=on-failure
+
 [Install]
 WantedBy=multi-user.target
-- 
2.13.6


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


Re: [devel] [PATCH 1/1] mds: Update test suite 14 to avoid perpetually hanging [#2831]

2018-04-19 Thread Lennart Lund
Ack

Thanks
Lennart

> -Original Message-
> From: Hoa Le [mailto:hoa...@dektech.com.au]
> Sent: den 10 april 2018 05:19
> To: Anders Widell ; Hans Nordebäck
> 
> Cc: opensaf-devel@lists.sourceforge.net
> Subject: [devel] [PATCH 1/1] mds: Update test suite 14 to avoid perpetually
> hanging [#2831]
> 
> Currently in suite 14, mdstest sends messages with
> MDS_SENDTYPE_SNDACK
> and MDS_SENDTYPE_SNDRSP types to the same destination, this sometimes
> makes the Response thread to catch the wrong event and does not respond
> to MDS_SENDTYPE_SNDRSP call. This causes the test case to hang forever.
> 
> This patch changes the destination of MDS_SENDTYPE_SNDRSP call to
> NCSMDS_SVC_ID_INTERNAL_MIN to avoid the above issue.
> ---
>  src/mds/apitest/mdstipc_api.c | 56 +
> --
>  1 file changed, 28 insertions(+), 28 deletions(-)
> 
> diff --git a/src/mds/apitest/mdstipc_api.c b/src/mds/apitest/mdstipc_api.c
> index 5bfa7ef..de166d1 100644
> --- a/src/mds/apitest/mdstipc_api.c
> +++ b/src/mds/apitest/mdstipc_api.c
> @@ -8541,7 +8541,7 @@ void tet_direct_send_all_tp_1()
>   /*SNDRSP*/
>   printf("\nDirect send with rsp\n");
>   if
> (tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_all_thread,
> - gl_tet_vdest[1].svc[1].task.t_handle) ==
> + gl_tet_vdest[1].svc[0].task.t_handle) ==
>   NCSCC_RC_SUCCESS) {
>   printf("\nTask has been Created\n");
>   fflush(stdout);
> @@ -8549,7 +8549,7 @@ void tet_direct_send_all_tp_1()
>   /*Sender*/
>   if (mds_direct_send_message(
>   gl_tet_adest.mds_pwe1_hdl,
> NCSMDS_SVC_ID_EXTERNAL_MIN,
> - NCSMDS_SVC_ID_EXTERNAL_MIN,
> gl_set_msg_fmt_ver,
> + NCSMDS_SVC_ID_INTERNAL_MIN,
> gl_set_msg_fmt_ver,
>   MDS_SENDTYPE_SNDRSP, gl_tet_vdest[1].vdest, 0,
>   MDS_SEND_PRIORITY_LOW, message) !=
> NCSCC_RC_SUCCESS) {
>   printf("\nFail\n");
> @@ -8557,7 +8557,7 @@ void tet_direct_send_all_tp_1()
>   } else
>   printf("\nSuccess\n");
>   /*Now Stop and Release the Receiver Thread*/
> - if (tet_release_task(gl_tet_vdest[1].svc[1].task.t_handle) ==
> + if (tet_release_task(gl_tet_vdest[1].svc[0].task.t_handle) ==
>   NCSCC_RC_SUCCESS)
>   printf("\nTASK is released\n");
> 
> @@ -8565,7 +8565,7 @@ void tet_direct_send_all_tp_1()
>   /*SNDRACK*/
>   printf("\n Direct send with response ack\n");
>   if
> (tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_all_rack_thread,
> - gl_tet_vdest[1].svc[1].task.t_handle) ==
> + gl_tet_vdest[1].svc[0].task.t_handle) ==
>   NCSCC_RC_SUCCESS) {
>   printf("\nTask has been Created\n");
>   fflush(stdout);
> @@ -8573,7 +8573,7 @@ void tet_direct_send_all_tp_1()
>   /*Sender */
>   if (mds_direct_send_message(
>   gl_tet_adest.mds_pwe1_hdl,
> NCSMDS_SVC_ID_EXTERNAL_MIN,
> - NCSMDS_SVC_ID_EXTERNAL_MIN,
> gl_set_msg_fmt_ver,
> + NCSMDS_SVC_ID_INTERNAL_MIN,
> gl_set_msg_fmt_ver,
>   MDS_SENDTYPE_SNDRSP, gl_tet_vdest[1].vdest, 0,
>   MDS_SEND_PRIORITY_LOW, message) ==
> NCSCC_RC_FAILURE) {
>   printf("\nFail\n");
> @@ -8581,7 +8581,7 @@ void tet_direct_send_all_tp_1()
>   } else
>   printf("\nSuccess\n");
>   /*Now Stop and Release the Receiver Thread*/
> - if (tet_release_task(gl_tet_vdest[1].svc[1].task.t_handle) ==
> + if (tet_release_task(gl_tet_vdest[1].svc[0].task.t_handle) ==
>   NCSCC_RC_SUCCESS)
>   printf("\nTASK is released\n");
> 
> @@ -8656,7 +8656,7 @@ void tet_direct_send_all_tp_2()
>   /*SNDRSP*/
>   printf("\nDirect send with rsp\n");
>   if
> (tet_create_task((NCS_OS_CB)tet_Dvdest_rcvr_all_thread,
> - gl_tet_vdest[1].svc[1].task.t_handle) ==
> + gl_tet_vdest[1].svc[0].task.t_handle) ==
>   NCSCC_RC_SUCCESS) {
>   printf("\nTask has been Created\n");
>   fflush(stdout);
> @@ -8664,7 +8664,7 @@ void tet_direct_send_all_tp_2()
>   /*Sender*/
>   if (mds_direct_send_message(
>   gl_tet_adest.mds_pwe1_hdl,
> NCSMDS_SVC_ID_EXTERNAL_MIN,
> - NCSMDS_SVC_ID_EXTERNAL_MIN,
> gl_set_msg_fmt_ver,
> + NCSMDS_SVC_ID_INTERNAL_MIN,
> gl_set_msg_fmt_ver,
>   MDS_SENDTYPE_SNDRSP, gl_tet_vdes

Re: [devel] [PATCH 1/1] mds: Correct timing issues in mdstest [#2798]

2018-04-19 Thread Lennart Lund
Hi,

I have reviewed your fix instead of Hans N.
I have a few comments. See the attached diff file. It can be applied on a clone 
of your review.

Thanks
Lennart

> -Original Message-
> From: Hoa Le [mailto:hoa...@dektech.com.au]
> Sent: den 26 mars 2018 06:58
> To: Anders Widell ; Hans Nordebäck
> 
> Cc: opensaf-devel@lists.sourceforge.net
> Subject: [devel] [PATCH 1/1] mds: Correct timing issues in mdstest [#2798]
> 
> In some bad thread scheduling situations, the API service request
> on the testing thread may be executed before the corresponding
> event being received on the MDS thread. This will lead to
> unexpected behavior of the service request and cause the failure
> of this test case.
> 
> This patch adds a sleep period for mdstest to wait for the expected
> event being received on MDS thread before invoking the testing
> service request.
> ---
>  src/mds/apitest/mdstipc_api.c | 142
> ++
>  1 file changed, 102 insertions(+), 40 deletions(-)
> 
> diff --git a/src/mds/apitest/mdstipc_api.c b/src/mds/apitest/mdstipc_api.c
> index 669c770..3a6f4ed 100644
> --- a/src/mds/apitest/mdstipc_api.c
> +++ b/src/mds/apitest/mdstipc_api.c
> @@ -1715,6 +1715,7 @@ void tet_svc_subscr_VDEST_10()
>   FAIL = 1;
>   }
>   // Retrieving the events
> + sleep(1);
>   if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
>SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS)
> {
>   printf("\nRetrieve servive 500 Fail\n");
> @@ -1735,6 +1736,7 @@ void tet_svc_subscr_VDEST_10()
>   FAIL = 1;
>   }
>   // Retrieving the events
> + sleep(1);
>   if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
>SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS)
> {
>   printf("\nFail to retreive events\n");
> @@ -2001,6 +2003,7 @@ void tet_svc_subscr_VDEST_12()
>   }
> 
>   printf("\nAction: Retrieving the events\n");
> + sleep(1);
>   if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
>SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS)
> {
>   printf("Retrieve Fail\n");
> @@ -2165,6 +2168,7 @@ void tet_svc_subscr_ADEST_1()
>   FAIL = 1;
>   } else {
>   printf("\nAction: Retrieve only ONE event\n");
> + sleep(1);
>   if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
>SA_DISPATCH_ONE) !=
> NCSCC_RC_SUCCESS) {
>   printf("Fail, retrieve ONE\n");
> @@ -2492,6 +2496,7 @@ void tet_svc_subscr_ADEST_9()
>   FAIL = 1;
>   } else {
>   printf("\nAction: Retreive three times, third shall fail\n");
> + sleep(1);
>   if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl, 500,
>SA_DISPATCH_ONE) !=
> NCSCC_RC_SUCCESS) {
>   printf("\nFail mds_service_retrieve\n");
> @@ -6056,6 +6061,41 @@ void tet_adest_all_rcvr_thread()
>   free(mesg);
>  }
> 
> +uint32_t tet_mds_retrieve_for_change(MDS_HDL mds_hdl, MDS_SVC_ID
> your_scv_id,
> + SaDispatchFlagsT dispatchFlags, NCSMDS_SVC_ID
> req_svc_id,
> + MDS_SVC_PVT_SUB_PART_VER svc_pvt_ver, NCSMDS_CHG
> change)
> +{
> + unsigned int num_tries = 1;
> + unsigned int max_tries = 30;
> + uint32_t rc = NCSCC_RC_FAILURE;
> +
> + while (1) {
> + if (mds_service_retrieve(mds_hdl, your_scv_id,
> + dispatchFlags) != NCSCC_RC_SUCCESS) {
> + printf("\nFail mds_service_retrieve\n");
> + break;
> + }
> + // Verify if the correct service event was retrieved.
> + if (tet_verify_version(mds_hdl, your_scv_id, req_svc_id,
> + svc_pvt_ver, change) == 1) {
> + rc = NCSCC_RC_SUCCESS;
> + break;
> + }
> + if (num_tries > max_tries) {
> + printf("\nCould not retrieve the expected event\n");
> + break;
> + }
> + else {
> + printf("\nExpected event was still not retrieved,"
> + " try again\n");
> + usleep(10);
> + num_tries++;
> + }
> + }
> +
> + return rc;
> +}
> +
>  void tet_send_all_tp_1()
>  {
>   int FAIL = 0;
> @@ -6093,12 +6133,14 @@ void tet_send_all_tp_1()
>   FAIL = 1;
>   }
> 
> - if (mds_service_retrieve(gl_tet_adest.mds_pwe1_hdl,
> -  NCSMDS_SVC_ID_EXTERNAL_MIN,
> -  SA_DISPATCH_ALL) != NCSCC_RC_SUCCESS)
> {
> + if (tet_mds_retrieve_for_change(gl_tet_adest.mds_pwe1_hdl,
> + NCSMDS_SVC_ID_EXTERNAL_MIN,
> SA_DISPATCH_ALL,
> + NCSMDS_SVC_ID