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

process_select and stime_range doesn't seem to work as expected

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.6.2
    • Labels:
      None

      Description

      I'm trying to select a process if it was started within last 24hours:

      <pre>
      [root@vsie1d085 ~]# cat /tmp/test.cf
      bundle agent test {
      processes:
      "init"
      process_select => init_older_than,
      restart_class => "host_up_more_than";
      reports:
      cfengine.!host_up_more_than::
      "Host is up < 1day";
      host_up_more_than::
      "Host is up > 1day";
      }

      body process_select init_older_than {
      stime_range => irange(ago(0,0,0,24,0,0),now());
      process_result => "stime";
      }
      </pre>

      Host is up for 15 hours, so all processes have been started within last 24h:
      <pre>
      [root@vsie1d085 ~]# uptime
      09:14:47 up 15:46, 1 user, load average: 0.01, 0.02, 0.00
      [root@vsie1d085 ~]# ps -eo pid,etime,args | grep init
      1 15:46:55 init [3]
      2660 00:00 grep init
      </pre>

      However cfengine does not match the process and sets restart_class:
      <pre>
      [root@vsie1d085 ~]# cf-agent -Kf /tmp/test.cf -b test
      R: Host is up > 1day
      </pre>

      If I change process_result to "!stime", which should not match any process as host has been up for 15 hours only, it matches the process however:

      <pre>
      [root@vsie1d085 ~]# cf-agent -Kf /tmp/test.cf -b test
      R: Host is up < 1day
      </pre>

      Here is relevant verbose output:
      <pre>
      nova> =========================================================
      nova> processes in bundle test (1)
      nova> =========================================================
      nova>
      nova> Observe process table with /bin/ps -eo user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,nlwp,stime,time,args
      nova>
      nova> .........................................................
      nova> Promise's handle: promise_test_cf_4
      nova> Promise made by: "init"
      nova> .........................................................
      nova>
      nova> !! Matched: root 1 0 1 0.0 0.0 10364 24 740 1 Jan21 00:00:00 init [3]
      nova> -> Found matching pid 1
      (root 1 0 1 0.0 0.0 10364 24 740 1 Jan21 00:00:00 init [3])
      nova> -> No signals to send for init
      nova> -> No restart promised for init
      nova>
      </pre>

        Attachments

        1. stime.patch
          5 kB
        2. stime.patch
          5 kB
        3. stime.patch
          3 kB

          Activity

            People

            • Assignee:
              a10050 Edward Welbourne (Inactive)
              Reporter:
              ipesin Ivan Pesin
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel