summaryrefslogtreecommitdiffstats
path: root/meta/classes/useradd_base.bbclass
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2014-04-03 17:32:16 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-04-05 23:24:01 +0100
commita8ab7a1159944629b117162bcea38d326ef95b6c (patch)
treedd26e15b44a1f06da13b9176caa70b6ab2d6b853 /meta/classes/useradd_base.bbclass
parent396e2153a99c7ec742ec5432d471e8b0d88c0a3f (diff)
downloadpoky-a8ab7a1159944629b117162bcea38d326ef95b6c.tar.gz
useradd_base.bbclass: avoid the traffic crowding
Currently, it would sleep 1 second when fail to add the user, this maybe not enough when we use the sstate cache, as my test shows below, nearly all the useradd actions are doing in the same minute when mirror from ssate cache, and it would fail when the load is high, I got these time by adding strace before the useradd for debugging: 2014-03-31 14:48:22.978079781 +0800 /tmp/log/pulseaudio.4.c 2014-03-31 14:48:22.028079813 +0800 /tmp/log/pulseaudio.1.c 2014-03-31 14:48:21.949079816 +0800 /tmp/log/pulseaudio.3.c 2014-03-31 14:48:20.903079852 +0800 /tmp/log/pulseaudio.2.c 2014-03-31 14:48:20.006079883 +0800 /tmp/log/nfs-utils.9.c 2014-03-31 14:48:18.876079923 +0800 /tmp/log/xuser-account.9.c 2014-03-31 14:48:18.824079924 +0800 /tmp/log/pulseaudio.0.c 2014-03-31 14:48:17.826079959 +0800 /tmp/log/xuser-account.8.c 2014-03-31 14:48:17.766079961 +0800 /tmp/log/nfs-utils.8.c 2014-03-31 14:48:16.794079995 +0800 /tmp/log/xuser-account.7.c 2014-03-31 14:48:16.735079997 +0800 /tmp/log/nfs-utils.7.c 2014-03-31 14:48:14.719080066 +0800 /tmp/log/xuser-account.5.c 2014-03-31 14:48:14.677080068 +0800 /tmp/log/nfs-utils.5.c 2014-03-31 14:48:12.621080139 +0800 /tmp/log/nfs-utils.3.c 2014-03-31 14:48:11.589080175 +0800 /tmp/log/nfs-utils.2.c 2014-03-31 14:48:10.242080221 +0800 /tmp/log/builder.0.c 2014-03-31 14:48:09.523080246 +0800 /tmp/log/nfs-utils.0.c 2014-03-31 14:48:09.488080248 +0800 /tmp/log/openssh.0.c 2014-03-31 14:48:09.485080248 +0800 /tmp/log/rpcbind.1.c 2014-03-31 14:48:07.590080313 +0800 /tmp/log/rpcbind.0.c 2014-03-31 14:28:15.437121590 +0800 /tmp/log/avahi.0.c 2014-03-31 14:18:19.067142238 +0800 /tmp/log/dbus.0.c The nfs-utils and xuser-account are failed to add the user. The useradd command needs two locks, passwd.lock and group.lock, it may get one, but can't get another one if we look into these .c files, sleep 1 second is not enough, it needs more seconds, the reason is that, if succeed, it doesn't have any side effects, if failed, we need wait for more seconds rather than make it more crowding. I've tried to use "sleep 5", but it didn't make much better since they would sleep and wake up nearly at the same time, I also tried to use "sleep <RANDOM seconds between 1 and 10>", that didn't make much better ,either. I think that a better ways is sleep more and more seconds (up to 10 seconds) when failed, this can't fix the problem that they may do the actions at the same time, but the logic is: if it is not crowding, sleep less time should be OK, otherwise sleep more and more time. Here is the testing result which seems much better: 2014-04-03 14:09:56.605185284 +0800 dbus.0.c 2014-04-03 14:09:39.899185862 +0800 rpcbind.5.c 2014-04-03 14:09:38.400185914 +0800 distcc.4.c 2014-04-03 14:09:35.206186025 +0800 pulseaudio.1.c 2014-04-03 14:09:33.979186067 +0800 rpcbind.4.c 2014-04-03 14:09:33.364186089 +0800 pulseaudio.0.c 2014-04-03 14:09:33.360186089 +0800 distcc.3.c 2014-04-03 14:09:30.996186171 +0800 avahi-ui.0.c 2014-04-03 14:09:30.298186195 +0800 distcc.2.c 2014-04-03 14:09:29.905186208 +0800 rpcbind.3.c 2014-04-03 14:09:29.410186226 +0800 avahi-ui.2.c 2014-04-03 14:09:28.239186266 +0800 distcc.1.c 2014-04-03 14:09:27.298186299 +0800 xuser-account.0.c 2014-04-03 14:09:27.032186308 +0800 distcc.0.c 2014-04-03 14:09:26.836186315 +0800 rpcbind.2.c 2014-04-03 14:09:25.846186349 +0800 nfs-utils.1.c 2014-04-03 14:09:25.752186352 +0800 avahi-ui.1.c 2014-04-03 14:09:24.779186386 +0800 builder.0.c 2014-04-03 14:09:24.746186387 +0800 rpcbind.1.c 2014-04-03 14:09:23.916186416 +0800 openssh.1.c 2014-04-03 14:09:23.848186418 +0800 nfs-utils.0.c 2014-04-03 14:09:23.594186427 +0800 rpcbind.0.c 2014-04-03 14:09:22.609186461 +0800 ppp-dialin.0.c 2014-04-03 14:09:21.817186488 +0800 openssh.0.c [YOCTO #6085] (From OE-Core rev: 9cedc786ba132935748bdca8bc33b56c366b531e) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/useradd_base.bbclass')
-rw-r--r--meta/classes/useradd_base.bbclass14
1 files changed, 7 insertions, 7 deletions
diff --git a/meta/classes/useradd_base.bbclass b/meta/classes/useradd_base.bbclass
index 7aafe29a4a..c47b1eb810 100644
--- a/meta/classes/useradd_base.bbclass
+++ b/meta/classes/useradd_base.bbclass
@@ -24,7 +24,6 @@ perform_groupadd () {
24 group_exists="`grep "^$groupname:" $rootdir/etc/group || true`" 24 group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
25 if test "x$group_exists" = "x"; then 25 if test "x$group_exists" = "x"; then
26 bbwarn "groupadd command did not succeed. Retrying..." 26 bbwarn "groupadd command did not succeed. Retrying..."
27 sleep 1
28 else 27 else
29 break 28 break
30 fi 29 fi
@@ -32,6 +31,7 @@ perform_groupadd () {
32 if test $count = $retries; then 31 if test $count = $retries; then
33 bbfatal "Tried running groupadd command $retries times without scucess, giving up" 32 bbfatal "Tried running groupadd command $retries times without scucess, giving up"
34 fi 33 fi
34 sleep $count
35 done 35 done
36 else 36 else
37 bbwarn "group $groupname already exists, not re-creating it" 37 bbwarn "group $groupname already exists, not re-creating it"
@@ -52,7 +52,6 @@ perform_useradd () {
52 user_exists="`grep "^$username:" $rootdir/etc/passwd || true`" 52 user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
53 if test "x$user_exists" = "x"; then 53 if test "x$user_exists" = "x"; then
54 bbwarn "useradd command did not succeed. Retrying..." 54 bbwarn "useradd command did not succeed. Retrying..."
55 sleep 1
56 else 55 else
57 break 56 break
58 fi 57 fi
@@ -60,6 +59,7 @@ perform_useradd () {
60 if test $count = $retries; then 59 if test $count = $retries; then
61 bbfatal "Tried running useradd command $retries times without scucess, giving up" 60 bbfatal "Tried running useradd command $retries times without scucess, giving up"
62 fi 61 fi
62 sleep $count
63 done 63 done
64 else 64 else
65 bbwarn "user $username already exists, not re-creating it" 65 bbwarn "user $username already exists, not re-creating it"
@@ -90,7 +90,6 @@ perform_groupmems () {
90 mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group || true`" 90 mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group || true`"
91 if test "x$mem_exists" = "x"; then 91 if test "x$mem_exists" = "x"; then
92 bbwarn "groupmems command did not succeed. Retrying..." 92 bbwarn "groupmems command did not succeed. Retrying..."
93 sleep 1
94 else 93 else
95 break 94 break
96 fi 95 fi
@@ -102,6 +101,7 @@ perform_groupmems () {
102 fi 101 fi
103 bbfatal "Tried running groupmems command $retries times without scucess, giving up" 102 bbfatal "Tried running groupmems command $retries times without scucess, giving up"
104 fi 103 fi
104 sleep $count
105 done 105 done
106 else 106 else
107 bbwarn "group $groupname already contains $username, not re-adding it" 107 bbwarn "group $groupname already contains $username, not re-adding it"
@@ -126,7 +126,6 @@ perform_groupdel () {
126 group_exists="`grep "^$groupname:" $rootdir/etc/group || true`" 126 group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
127 if test "x$group_exists" != "x"; then 127 if test "x$group_exists" != "x"; then
128 bbwarn "groupdel command did not succeed. Retrying..." 128 bbwarn "groupdel command did not succeed. Retrying..."
129 sleep 1
130 else 129 else
131 break 130 break
132 fi 131 fi
@@ -134,6 +133,7 @@ perform_groupdel () {
134 if test $count = $retries; then 133 if test $count = $retries; then
135 bbfatal "Tried running groupdel command $retries times without scucess, giving up" 134 bbfatal "Tried running groupdel command $retries times without scucess, giving up"
136 fi 135 fi
136 sleep $count
137 done 137 done
138 else 138 else
139 bbwarn "group $groupname doesn't exist, not removing it" 139 bbwarn "group $groupname doesn't exist, not removing it"
@@ -154,7 +154,6 @@ perform_userdel () {
154 user_exists="`grep "^$username:" $rootdir/etc/passwd || true`" 154 user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
155 if test "x$user_exists" != "x"; then 155 if test "x$user_exists" != "x"; then
156 bbwarn "userdel command did not succeed. Retrying..." 156 bbwarn "userdel command did not succeed. Retrying..."
157 sleep 1
158 else 157 else
159 break 158 break
160 fi 159 fi
@@ -162,6 +161,7 @@ perform_userdel () {
162 if test $count = $retries; then 161 if test $count = $retries; then
163 bbfatal "Tried running userdel command $retries times without scucess, giving up" 162 bbfatal "Tried running userdel command $retries times without scucess, giving up"
164 fi 163 fi
164 sleep $count
165 done 165 done
166 else 166 else
167 bbwarn "user $username doesn't exist, not removing it" 167 bbwarn "user $username doesn't exist, not removing it"
@@ -184,7 +184,6 @@ perform_groupmod () {
184 eval $PSEUDO groupmod $opts 184 eval $PSEUDO groupmod $opts
185 if test $? != 0; then 185 if test $? != 0; then
186 bbwarn "groupmod command did not succeed. Retrying..." 186 bbwarn "groupmod command did not succeed. Retrying..."
187 sleep 1
188 else 187 else
189 break 188 break
190 fi 189 fi
@@ -192,6 +191,7 @@ perform_groupmod () {
192 if test $count = $retries; then 191 if test $count = $retries; then
193 bbfatal "Tried running groupmod command $retries times without scucess, giving up" 192 bbfatal "Tried running groupmod command $retries times without scucess, giving up"
194 fi 193 fi
194 sleep $count
195 done 195 done
196 else 196 else
197 bbwarn "group $groupname doesn't exist, unable to modify it" 197 bbwarn "group $groupname doesn't exist, unable to modify it"
@@ -214,7 +214,6 @@ perform_usermod () {
214 eval $PSEUDO usermod $opts 214 eval $PSEUDO usermod $opts
215 if test $? != 0; then 215 if test $? != 0; then
216 bbwarn "usermod command did not succeed. Retrying..." 216 bbwarn "usermod command did not succeed. Retrying..."
217 sleep 1
218 else 217 else
219 break 218 break
220 fi 219 fi
@@ -222,6 +221,7 @@ perform_usermod () {
222 if test $count = $retries; then 221 if test $count = $retries; then
223 bbfatal "Tried running usermod command $retries times without scucess, giving up" 222 bbfatal "Tried running usermod command $retries times without scucess, giving up"
224 fi 223 fi
224 sleep $count
225 done 225 done
226 else 226 else
227 bbwarn "user $username doesn't exist, unable to modify it" 227 bbwarn "user $username doesn't exist, unable to modify it"