Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2207

Signalling in processes promise does not wait between the signals

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None

      Description

          processes:
             "snmpd"
                  signals         => { "term" , "kill" };
      

      This sends term after kill instantaneously, not leaving time to the process to clean-up.

      Ideally I would want a configurable timeout in-between the signals, unless the target PID dies earlier:

          processes:
             "snmpd"
                  signals          => { "term" , "kill" },
                  signals_timeout  => "1s";
      

      We also have the machinery to do that, called @GracefulTerminate()@ but the relevant code does not use it. From verify_processes.c:DoAllSignals():

          for (ip = siglist; ip != NULL; ip = ip->next)
          {
              pid = ip->counter;
      
              for (rp = a.signals; rp != NULL; rp = rp->next)
              {
                  int signal = SignalFromString(RlistScalarValue(rp));
      
                  if (!DONTDO)
                  {
                      if ((signal == SIGKILL) || (signal == SIGTERM))
                      {
                          killed = true;
                      }
      
                      if (kill((pid_t) pid, signal) < 0)
                      {
                          cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_FAIL, pp, a,
                               "Couldn't send promised signal '%s' (%d) to pid %jd (might be dead) (kill: %s)",
                               RlistScalarValue(rp), signal, (intmax_t) pid, GetErrorStr());
                          failure = true;
                      }
                      else
                      {
                          cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, a,
                               "Signalled '%s' (%d) to process %jd (%s)",
                               RlistScalarValue(rp), signal, (intmax_t) pid, ip->name);
                          *result = PromiseResultUpdate(*result, PROMISE_RESULT_CHANGE);
                          failure = false;
                      }
                  }
                  else
                  {
                      Log(LOG_LEVEL_ERR, "Need to keep signal promise '%s' in process entry '%s'",
                          RlistScalarValue(rp), ip->name);
                  }
              }
          }
      

      EDIT: This was brought up again. A possible solution is to introduce a default delay of 2-3 seconds after sending the first signal. But that would be maximum delay. The agent should watch the signalled process, and not wait nor send the second signal if the PID disappears.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              a10038 jimis (Dimitrios Apostolou)
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:

                Summary Panel