Re: [Lxc-users] shutting down CentOS6 container

2011-10-18 Thread Greg Kurz
On Mon, 2011-10-17 at 23:04 +0300, Iliyan ilf Stoyanov wrote:
 Hi again,
 
 what about lxc-execute?
 
 br,
 --ilf
 

Hi,

lxc-execute is the lxc-start variant to run application containers.
Use lxc-attach if you need to issue a command in an already running
container.

Cheers.

 On Mon, 2011-10-17 at 21:02 +0100, Milos Negovanovic wrote:
  On Mon, Oct 17, 2011 at 10:36:24PM +0300, Iliyan ilf Stoyanov wrote:
   Hi Milos,
   
   have you tried doing lxc-console --name $NAME_OF_YOUR_CENTOS6_CONTAINER,
   then loging in and issuing shutdown -h now. It works for me on Fedora
   15/SL6.1.
   
   BR,
   --ilf 
  
  I am looking for a way to automatically shutdown container. Something I
  can use from my rc scripts on the host to orderly shutdown containers on
  host OS reboot/shutdown. I know I can ssh into the container and issue
  shutdown command, that works, but thats not what I am looking for.
  
  Regards
 
 
 
 --
 All the data continuously generated in your IT infrastructure contains a
 definitive record of customers, application performance, security
 threats, fraudulent activity and more. Splunk takes this data and makes
 sense of it. Business sense. IT sense. Common sense.
 http://p.sf.net/sfu/splunk-d2d-oct
 ___
 Lxc-users mailing list
 Lxc-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/lxc-users
 

-- 
Gregory Kurz gk...@fr.ibm.com
Software Engineer @ IBM/Meiosys  http://www.ibm.com
Tel +33 (0)534 638 479   Fax +33 (0)561 400 420

Anarchy is about taking complete responsibility for yourself.
Alan Moore.


--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] shutting down CentOS6 container

2011-10-18 Thread Brian K. White
On 10/17/2011 5:01 PM, Papp Tamas wrote:
 On 10/17/2011 10:54 PM, Derek Simkowiak wrote:
  /I tried the python script, it just works fine./

 Q1: How does the kill -INT init method affect running processes,
 especially MySQL and other databases that may need to shutdown
 gracefully to avoid data corruption?

 I believe that the child processes (incl. mysqld, apache, etc.) would
 be able to shutdown gracefully without data corruption, because they'd
 be killed with a signal that will invoke their internal signal
 handlers. But, I am looking for independent confirmation.

 That's right.

 Q2: How is lxc-stop -n $CONTAINERNAME different from the Python script
 mentioned below? Will lxc-stop on a container cause an unclean
 shutdown, or does it also use a Unix signal?

 lxc-stop is part of the script.
 If I'm right it's equivalent of pushing the power button of the machine.

I would say it's like pulling the power cord.

Not just being a pedant. The terminology matters since you are trying 
specifically to clarify and nail down exactly that all-important 
behavioral detail.

Pressing the power button is ambiguous since pressing the power button 
can be either a polite signal resulting in a graceful and orderly 
shutdown, OR not, depending on the machine. And that difference is all 
the difference in the world.

Just in case someone asks I guess you could also say lxc-destroy is like 
removing everything but the hard drive.

-- 
bkw

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] shutting down CentOS6 container

2011-10-17 Thread Milos Negovanovic
On Mon, Oct 17, 2011 at 10:36:24PM +0300, Iliyan ilf Stoyanov wrote:
 Hi Milos,
 
 have you tried doing lxc-console --name $NAME_OF_YOUR_CENTOS6_CONTAINER,
 then loging in and issuing shutdown -h now. It works for me on Fedora
 15/SL6.1.
 
 BR,
 --ilf 

I am looking for a way to automatically shutdown container. Something I
can use from my rc scripts on the host to orderly shutdown containers on
host OS reboot/shutdown. I know I can ssh into the container and issue
shutdown command, that works, but thats not what I am looking for.

Regards
-- 
Milos Negovanovic
milos.negovano...@gmail.com

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] shutting down CentOS6 container

2011-10-17 Thread Papp Tamas
On 10/17/2011 10:02 PM, Milos Negovanovic wrote:
 On Mon, Oct 17, 2011 at 10:36:24PM +0300, Iliyan ilf Stoyanov wrote:
 Hi Milos,

 have you tried doing lxc-console --name $NAME_OF_YOUR_CENTOS6_CONTAINER,
 then loging in and issuing shutdown -h now. It works for me on Fedora
 15/SL6.1.

 BR,
 --ilf
 I am looking for a way to automatically shutdown container. Something I
 can use from my rc scripts on the host to orderly shutdown containers on
 host OS reboot/shutdown. I know I can ssh into the container and issue
 shutdown command, that works, but thats not what I am looking for.


kill -INT init

I use this diff on ubuntu host:

--- lxc.orig2011-10-16 22:59:24.186322805 +0200
+++ lxc2011-10-17 22:10:17.974920307 +0200
@@ -52,6 +52,37 @@
fi
  }

+stop_one() {
+name=$1
+#dir_cgroup=`grep -w cgroup /proc/mounts|awk '{ print $2 }'`
+#if [ ! -d $dir_cgroup/$name ]; then
+#log_failure_msg $name is not running.
+#return
+#fi
+if ! is_running $name;then
+log_failure_msg $name is not running.
+fi
+
+echo -n Stopping $name
+pid_init=`lxc-ps --name $name | grep init$ | awk '{ print $2 }'`
+
+kill -INT $pid_init
+count=0
+while lxc-ps --name $name | egrep -qv '(init$|CONTAINERPID 
TTY  TIME CMD)';do
+if [ $count -ge 600 ];then
+log_failure_msg Container $name cannot be stopped on the 
proper way.
+return
+fi
+echo -n '.';
+sleep 1;
+count=$(($count+1))
+done
+
+lxc-stop -n $name
+echo  done.
+log_success_msg Container $name has been stopped successfully.
+}
+
  action_all() {
action=$1
nolog=$2
@@ -80,7 +111,8 @@
  ;;
stop)
  log_daemon_msg Stopping $DESC
-action_all lxc-stop -n
+#action_all lxc-stop -n
+action_all stop_one
  ;;
restart|force-reload)
  log_daemon_msg Restarting $DESC


tamas

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] shutting down CentOS6 container

2011-10-17 Thread Papp Tamas
On 10/17/2011 10:26 PM, Milos Negovanovic wrote:

 If I am not mistaken thats similar approach to using this script:

 http://pastie.org/2713689

 Ive tried using that python script, but instead of shutting down my
 container restarts! Can you paste your container /etc/inittab by any
 chance?


There is no inittab, Ubuntu and also CentOS 6 uses upstart.
I tried the python script, it just works fine.

tamas

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] shutting down CentOS6 container

2011-10-17 Thread Derek Simkowiak

 /I tried the python script, it just works fine./

Q1: How does the kill -INT init method affect running processes, 
especially MySQL and other databases that may need to shutdown 
gracefully to avoid data corruption?


I believe that the child processes (incl. mysqld, apache, etc.) 
would be able to shutdown gracefully without data corruption, because 
they'd be killed with a signal that will invoke their internal signal 
handlers.  But, I am looking for independent confirmation.



Q2: How is lxc-stop -n $CONTAINERNAME different from the Python 
script mentioned below?  Will lxc-stop on a container cause an unclean 
shutdown, or does it also use a Unix signal?



Thanks,
Derek

On 10/17/2011 01:37 PM, Papp Tamas wrote:

On 10/17/2011 10:26 PM, Milos Negovanovic wrote:

If I am not mistaken thats similar approach to using this script:

http://pastie.org/2713689

Ive tried using that python script, but instead of shutting down my
container restarts! Can you paste your container /etc/inittab by any
chance?


There is no inittab, Ubuntu and also CentOS 6 uses upstart.
I tried the python script, it just works fine.

tamas

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] shutting down CentOS6 container

2011-10-17 Thread Papp Tamas

On 10/17/2011 10:54 PM, Derek Simkowiak wrote:

 /I tried the python script, it just works fine./

Q1: How does the kill -INT init method affect running processes, 
especially MySQL and other databases that may need to shutdown 
gracefully to avoid data corruption?


I believe that the child processes (incl. mysqld, apache, etc.) 
would be able to shutdown gracefully without data corruption, because 
they'd be killed with a signal that will invoke their internal signal 
handlers.  But, I am looking for independent confirmation.


That's right.

Q2: How is lxc-stop -n $CONTAINERNAME different from the Python 
script mentioned below?  Will lxc-stop on a container cause an unclean 
shutdown, or does it also use a Unix signal?


lxc-stop is part of the script.
If I'm right it's equivalent of pushing the power button of the machine.

t
--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] shutting down CentOS6 container

2011-10-17 Thread Milos Negovanovic
On Mon, Oct 17, 2011 at 10:37:04PM +0200, Papp Tamas wrote:
 On 10/17/2011 10:26 PM, Milos Negovanovic wrote:
 
 If I am not mistaken thats similar approach to using this script:
 
 http://pastie.org/2713689
 
 Ive tried using that python script, but instead of shutting down my
 container restarts! Can you paste your container /etc/inittab by any
 chance?
 
 
 There is no inittab, Ubuntu and also CentOS 6 uses upstart.
 I tried the python script, it just works fine.
 
 tamas

OK got it working by tweaking the following config file inside centos6
container:

/etc/init/control-alt-delete.conf

After I modified the behavior of ctrl-alt-del handling, container shuts
down using that python script.

Thanks for all the suggestions. :)

Regards
-- 
Milos Negovanovic
milos.negovano...@gmail.com

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] shutting down CentOS6 container

2011-10-17 Thread Papp Tamas
On 10/17/2011 11:05 PM, Milos Negovanovic wrote:
 OK got it working by tweaking the following config file inside centos6
 container:

 /etc/init/control-alt-delete.conf

 After I modified the behavior of ctrl-alt-del handling, container shuts
 down using that python script.

 Thanks for all the suggestions. :)


This file is the same on ubuntu doesn't need the modification.

tamas

--
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2d-oct
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users