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.
Verified this bug with devenv_stage_146, and PASS.