Bug 803581 - active_capacity factor maybe a negative number when turn on CREATE_APP_SYMLINKS flag.
active_capacity factor maybe a negative number when turn on CREATE_APP_SYMLIN...
Status: CLOSED CURRENTRELEASE
Product: OpenShift Origin
Classification: Red Hat
Component: Containers (Show other bugs)
1.x
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Dan McPherson
libra bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-15 02:38 EDT by Johnny Liu
Modified: 2012-03-19 14:22 EDT (History)
0 users

See Also:
Fixed In Version: rhc-node-0.88.8
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-03-19 14:22:36 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Johnny Liu 2012-03-15 02:38:45 EDT
Description of problem:
Set CREATE_APP_SYMLINKS=1, create app, stop or idle it, then run the following command:
# mc-facts active_capacity
Report for fact: active_capacity

        -2.0                                    found 1 times
        0.0                                     found 2 times

Finished processing 3 / 3 hosts in 114.90 ms


Version-Release number of selected component (if applicable):
devenv_1662

How reproducible:
Always

Steps to Reproduce:
1. Log into instance, make sure CREATE_APP_SYMLINKS=1 in stickshift-node.conf
2. Create an app, stop or idle it.
3. Run the following command in instance.
# mc-facts active_capacity
  
Actual results:
active_capacity factor is a negative number.

# mc-facts active_capacity
Report for fact: active_capacity

        -2.0                                    found 1 times
        0.0                                     found 2 times


Expected results:
active_capacity factor should NOT be a negative number.

Additional info:
The root cause is the logic error in <li.repo>/node/facter/libra.rb:
Facter.add(:active_capacity) do
    git_repos =  Facter.value(:git_repos).to_f
    max_active_apps = Facter.value(:max_active_apps).to_f
    stopped_app_count = 0
    Dir.glob("/var/lib/stickshift/*").each { |app_dir|
        if File.directory?(app_dir)
            active = true
            Dir.glob(File.join(app_dir, '*', 'runtime', '.state')).each {|file|
                state = File.read(file).chomp
                if 'idle' == state || 'stopped' == state
                    active = false
                end
            }
            if not active
                stopped_app_count += 1
            end
        end
    }
    active_capacity = ( (git_repos - stopped_app_count) / max_active_apps ) * 100
    setcode { active_capacity.to_s }
end


If symlink file is created in /var/lib/stickshift/ as following,
[root@ip-10-72-238-117 stickshift]# ll
total 4
drwxr-x---. 8 root e7e4c375aba54abc98cef4c445d8226b 4096 Mar 15 01:10 e7e4c375aba54abc98cef4c445d8226b
-rw-r--r--. 1 root root                                0 Mar 15 02:00 last_access.log
lrwxrwxrwx. 1 root root                               52 Mar 15 02:16 phptest-jialiu -> /var/lib/stickshift/e7e4c375aba54abc98cef4c445d8226b

one app will be counted twice, it is a duplicate counting, but for git_repos factor, factor only count one app for one time.
Comment 1 Johnny Liu 2012-03-19 07:27:38 EDT
Verified this bug with devenv_stage_146, and PASS.

Note You need to log in before you can comment on or make changes to this bug.