Debian: automated build crashes on num_users 0

Bug #1959606 reported by Jason
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
StarlingX
Fix Released
High
Scott Little

Bug Description

Brief Description
-----------------
The Debian build stx import command can crash during a build when there are no logged in users on the system.

Severity
--------
Critical: Causes build failure on empty build machine

Steps to Reproduce
------------------
Start a Debian build while there are no logged in users

Expected Behavior
------------------
stx import command should check for logged in users while calculating cpu but
should never use 0 in that determination

Actual Behavior
----------------
0 logged in users causes divide by zero error

02:09:06 ++ NUM_USERS=0
02:09:06 +++ number_of_cpus
02:09:06 +++ /usr/bin/nproc
02:09:06 ./import-stx: line 57: 64/0: division by 0 (error token is "0")

Code
------
Issue located in
https://opendev.org/starlingx/tools/src/branch/master/import-stx

Reproducibility
---------------
Reproducible

Jason (jatwind-20)
summary: - Debian build crashes on num_users 0
+ Debian: build crashes on num_users 0
summary: - Debian: build crashes on num_users 0
+ Debian: automated build crashes on num_users 0
Scott Little (slittle1)
Changed in starlingx:
assignee: nobody → Scott Little (slittle1)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tools (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/starlingx/tools/+/827162

Changed in starlingx:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tools (master)

Reviewed: https://review.opendev.org/c/starlingx/tools/+/827162
Committed: https://opendev.org/starlingx/tools/commit/d98a34ad1b4f55bac4ce39ddd100e1c8b0fcb6e1
Submitter: "Zuul (22348)"
Branch: master

commit d98a34ad1b4f55bac4ce39ddd100e1c8b0fcb6e1
Author: Scott Little <email address hidden>
Date: Mon Jan 31 13:16:38 2022 -0500

    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 <email address hidden>
    Change-Id: I1369aa159088a17c24cc996be1ef2d36ecdc9cf6

Changed in starlingx:
status: In Progress → Fix Released
Ghada Khalil (gkhalil)
Changed in starlingx:
importance: Undecided → High
tags: added: stx.7.0 stx.build
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.