Forum: CFEngine Help
Subject: Re: Why it's necessary to restart defined service one time.
Author: juriskrumins
Link to topic: https://cfengine.com/forum/read.php?3,27210,27219#msg-27219

neilhwatson Wrote:
-------------------------------------------------------
> This is a regex that goes to the processes
> promise: .*/sshd.  I"ll bet that no such process
> exists.

sshd process exists when we've executeed this policy. I've tested this regex 
one more time. This what I got:


# service sshd status 
openssh-daemon (pid  1440) is running...
# ps -ef | grep ".*/sshd"
root        1440       1  0 21:33 ?        00:00:00 /usr/sbin/sshd
root        2722    2083  0 21:36 ?        00:00:00 /usr/sbin/sshd
root        3000    2063  0 21:38 pts/0    00:00:00 grep .*/sshd

# ps -ef | grep ".*/sshd"
root        1440       1  0 21:33 ?        00:00:00 /usr/sbin/sshd
root        2722    2083  0 21:36 ?        00:00:00 /usr/sbin/sshd
root        3079    2063  0 21:40 pts/0    00:00:00 grep .*/sshd
# service sshd status 
openssh-daemon (pid  1440) is running...

cf3>       * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
cf3>       BUNDLE generic_services( 
{'$(this.promiser)','$(this.service_policy)','.*/sshd','1'} )
cf3>       * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
cf3> 
cf3> Initiate variable convergence...
cf3>     ? Augment scope generic_services with service (s)
cf3>     ? Augment scope generic_services with state (s)
cf3>     ? Augment scope generic_services with proc_name (s)
cf3>     ? Augment scope generic_services with proc_ppid (s)
cf3> 
cf3>    =========================================================
cf3>    vars in bundle generic_services (1)
cf3>    =========================================================
cf3> 
cf3> 
cf3>    =========================================================
cf3>    classes in bundle generic_services (1)
cf3>    =========================================================
cf3> 
cf3>  ?> defining explicit local bundle class start
cf3> Initiate variable convergence...
cf3> 
cf3>      +  Private classes augmented:
cf3>      +       start
cf3> 
cf3>      -  Private classes diminished:
cf3> 
cf3> 
cf3> 
cf3>    =========================================================
cf3>    processes in bundle generic_services (1)
cf3>    =========================================================
cf3> 
cf3> Observe process table with /bin/ps -eo 
user,pid,ppid,pgid,pcpu,pmem,vsz,pri,rss,nlwp,stime,time,args
cf3> 
cf3>     .........................................................
cf3>     Promise's handle: 
cf3>     Promise made by: ".*/sshd"
cf3> 
cf3>     Comment:  Verify that the service appears in the process table
cf3>     .........................................................
cf3> 
cf3>  !! Matched: root        1440       1    1440  0.0  0.1  64072  19  1088   
 1 21:33 00:00:00 /usr/sbin/sshd
cf3>  ->  Found matching pid 1440
     (root        1440       1    1440  0.0  0.1  64072  19  1088    1 21:33 
00:00:00 /usr/sbin/sshd)
cf3>  -> No signals to send for .*/sshd
cf3>  -> No restart promised for .*/sshd
cf3> 
cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . .
cf3> Skipping whole next promise (.*/sshd), as context stop is not relevant
cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . .
cf3> 
cf3>    =========================================================
cf3>    commands in bundle generic_services (1)
cf3>    =========================================================
cf3> 
cf3> 
cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . .
cf3> Skipping whole next promise (/sbin/service sshd start), as var-context 
start_sshd is not relevant
cf3> . . . . . . . . . . . . . . . . . . . . . . . . . . . .
cf3> 



Maybe this issue is more about process cache and since I tend to run cf-agent 
with -KI options (at least while testing policies), then maybe cache was not 
updated that moment.

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to