import-stx: Avoid divide by zero
Fix a divide by zero error seen when the number_of_users function returns zero. At issue is that 'users' only counts logins, and can miss builds running under automation such as jenkins. Add code to detect potential automation accounts, just jenkins so far, and to always return a value greater than zero. Also adding a few .gitignore entries for files generated by stx build related scripts. Closes-bug: 1959606 Signed-off-by: Scott Little <scott.little@windriver.com> Change-Id: I1369aa159088a17c24cc996be1ef2d36ecdc9cf6
This commit is contained in:
parent
09ec170ed9
commit
d98a34ad1b
|
@ -12,3 +12,7 @@ doc/build/
|
|||
|
||||
# Release Notes documentation
|
||||
releasenotes/build
|
||||
|
||||
# stx init/config/controller files
|
||||
stx.conf
|
||||
minikube_history.log
|
||||
|
|
18
import-stx
18
import-stx
|
@ -41,7 +41,23 @@ if [ ! -f "stx.conf" ]; then
|
|||
fi
|
||||
|
||||
number_of_users () {
|
||||
users | tr ' ' '\n' | sort --uniq | wc -l
|
||||
local count
|
||||
|
||||
count=$(users | tr ' ' '\n' | sort --uniq | wc -l)
|
||||
|
||||
# Add in non-login users that might trigger a parallel build
|
||||
# based on a timer, or other trigger.
|
||||
if getent passwd | grep -q jenkins; then
|
||||
count=$((count+1))
|
||||
fi
|
||||
|
||||
# Always return at least one. i.e. someone is
|
||||
# running this script.
|
||||
if [ $count -le 0 ]; then
|
||||
count=1
|
||||
fi
|
||||
|
||||
echo $count
|
||||
}
|
||||
|
||||
number_of_cpus () {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
__pycache__
|
Loading…
Reference in New Issue