Project

General

Profile

Anomalie #2089

/etc/init.d/lxc ne se termine pas si un conteneur ne démarre pas + screen n'est pas très utile

Added by Emmanuel GARETTE (2) over 11 years ago. Updated over 11 years ago.

Status:
Fermé
Priority:
Normal
Assigned To:
-
Category:
-
Start date:
09/21/2011
Due date:
% Done:

100%

Spent time:
Distribution:
EOLE 2.3

Description

Si un conteneur a un problème, le script ne se termine jamais et on ne sait pas pourquoi.

Si on utilise la méthode screen, le screen se ferme si le conteneur ne démarre pas, ce n'est pas utile pour le déboggage.

Dans le patch ci-dessus je fais un boucle de xx seconds (30 par défaut). Si le conteneur n'est pas démarré, un message apparait. A savoir que le conteneur est marqué comme étant "RUNNING" très rapidement normalement. Evidement si le serveur est "RUNNING" le script sort rapidement de la boucle.

De plus si lxc-start s'arrête par une erreur, screen ne se ferme pas (reste bloqué par la commande "read") mais le screen se ferme si le serveur est arrêté normalement.

Il faudrait peut être ajouter un fichier /etc/default/lxc pour modifier les options (durée en seconds ou le support de screen, ...).

Il faudrait voir si on utilise screen par défaut ou non aussi.

--- lxc    2011-09-21 20:57:28.000000000 +0200
+++ /etc/init.d/lxc    2011-09-21 23:20:34.000000000 +0200
@@ -17,7 +17,8 @@
 DESC="linux containers" 
 NAME=lxc
 SCRIPTNAME=/etc/init.d/$NAME
 SCREEN=FALSE
+TIMEOUT=30

 # Exit if the package is not installed
 [ -x /usr/bin/lxc-start ] || exit 0
@@ -46,17 +47,29 @@
     check_read_only
     for C in $(ls -1 /var/lib/lxc); do
         if [ -r /var/lib/lxc/$C/on_boot ]; then
-            if [ "$(cat /var/lib/lxc/$C/on_boot)" = "1" ]; then
-                log_progress_msg "$C" 
-                if lxc-info -n $C | grep STOPPED > /dev/null 2>&1; then
-                if [ ! "$SCREEN" = "FALSE" ]; then
-                    /usr/bin/screen -dmS init-${C} /usr/bin/lxc-start -n $C
-                else
-                        lxc-start -n $C -d
-                    fi
-                    lxc-wait -n $C -s RUNNING
-                    if [ $? -gt 0 ]; then
-                        return 2
+            if [ ! "$(lxc-info -n $C)" = "'$C' is RUNNING" ]; then
+                if [ "$(cat /var/lib/lxc/$C/on_boot)" = "1" ]; then
+                    log_progress_msg "$C" 
+                    if [ "$(lxc-info -n $C)" = "'$C' is STOPPED" ]; then
+                        if [ ! "$SCREEN" = "FALSE" ]; then
+                            #stop old screen session
+                            /usr/bin/screen -dr ${C} -X quit > /dev/null 2>&1
+                            /usr/bin/screen -dmS ${C} /bin/bash -c "{ /usr/bin/lxc-start -n $C; read; }" 
+                        else
+                            lxc-start -n $C -d
+                        fi
+                        starttime=$(date "+%s")
+                        curtime=$(date "+%s")
+                        stop="FALSE" 
+                        while [ ! "$(lxc-info -n $C)" = "'$C' is RUNNING" ] && [ $stop = "FALSE" ]; do
+                            sleep .25
+                            curtime=$(date "+%s")
+                            if [ $(( $curtime - $starttime )) -gt $TIMEOUT ]; then
+                                echo "Container $C is starting for longer than $TIMEOUT seconds" >&2
+                                [ ! "$SCREEN" = "FALSE" ] && echo "Try to do 'screen -dr $C' for more informations" 
+                                stop="TRUE" 
+                            fi
+                        done
                     fi
                 fi
             fi

Associated revisions

Revision a704a0cc (diff)
Added by moyooo about 13 years ago

be able to reset running state of a cron job
see #2089

Revision 5151b5d0 (diff)
Added by Joël Cuissinat over 11 years ago

creole/cfgparser.py : affichage du résutat de "/etc/init.d/lxc force-start" (ref #2089)

Revision 06671cd1 (diff)
Added by Joël Cuissinat over 11 years ago

lxc : application du patch "lxc ne se termine pas si un conteneur ne démarre pas" (fixes #2089)

Revision 2e99b659 (diff)
Added by Johan Cwiklinski over 5 years ago

Rework solutions; fixes #2089

Add solution object, form, add solution from ticket timeline
Set solved adding solution, set solution rejected on status change
Add schema and migration script for solutions (thanks to @tomolimo)
Visual distinction beetween accepted and rejected solution
Add ComonITILObject::maySolve() similar to canSolve() but not checking actuel status
Add unit tests
Use unicity on table for migration only
Drop images on solutions background and use fa instead
Do not rely only on ticket
Rework display in tab (looks like timeline)
Add approval form on solutions tab; invert approval buttons

History

#1 Updated by Joël Cuissinat over 11 years ago

  • Target version set to Mises à jour 2.3 - 02 RC

#2 Updated by Emmanuel GARETTE (2) over 11 years ago

Ca serait bien d'avoir les infos a l'instance/reconfigure :

--- cfgparser.py    2011-09-26 18:57:52.919456080 +0200
+++ /usr/share/pyshared/creole/cfgparser.py    2011-09-26 19:11:58.427548865 +0200
@@ -560,7 +560,7 @@
         if config.VIRTDISABLED == True:
             return
         cmd=['/etc/init.d/lxc', 'force-start']
-        system_out(cmd)
+        system_code(cmd)

     def write_config(self):
         #vider et creer le fichier containers_bridge_file

#3 Updated by Joël Cuissinat over 11 years ago

  • Project changed from creole to eole-common

#4 Updated by Joël Cuissinat over 11 years ago

  • % Done changed from 0 to 20

#5 Updated by Joël Cuissinat over 11 years ago

  • Status changed from Nouveau to Résolu
  • % Done changed from 20 to 100

#6 Updated by Fabrice Barconnière over 11 years ago

  • Status changed from Résolu to Fermé
  • Distribution set to EOLE 2.3

Also available in: Atom PDF