On testing, I found there is a bug in Aliyun CLI which affects the sizing tool. With the bug, the sizing script would just return all 0 in the counting.
Expected behavior
The Aliyun Sizing Script is reading the "Total Count" attribute from the json obtained by "aliyun ecs describeinstances". The "Total Count" should report the total ECS (VM) instances number.
Current behavior
But perhaps an API bug from Alicloud side, the "Total Count" is always 0 even there are vm listed.
Possible solution
Amend the script function "get_instance_count()", skip relying on the "Total Count" attribute. Instead, add the new lines to count the instances number instead.
get_instance_count() {
COUNT=0
RESULT=$(abc_compute_instances_list "${1}")
// COUNT=$(echo "${RESULT}" | jq -r '.TotalCount' 2>/dev/null) //commented this original line
INSTANCES=($(echo "${RESULT}" | jq -r '.Instances.Instance[].InstanceId' 2>/dev/null)) //add new line 1
COUNT=$((COUNT + ${#INSTANCES[@]})) //add new line 2
echo "${COUNT}"
}
Describe the bug
On testing, I found there is a bug in Aliyun CLI which affects the sizing tool. With the bug, the sizing script would just return all 0 in the counting.
Expected behavior
The Aliyun Sizing Script is reading the "Total Count" attribute from the json obtained by "aliyun ecs describeinstances". The "Total Count" should report the total ECS (VM) instances number.
Current behavior
But perhaps an API bug from Alicloud side, the "Total Count" is always 0 even there are vm listed.![image](https://user-images.githubusercontent.com/28106000/195825713-f59b9ae5-060d-4262-9f4b-8e2f4ad334f5.png)
Possible solution
Amend the script function "get_instance_count()", skip relying on the "Total Count" attribute. Instead, add the new lines to count the instances number instead.
get_instance_count() { COUNT=0 RESULT=$(abc_compute_instances_list "${1}") // COUNT=$(echo "${RESULT}" | jq -r '.TotalCount' 2>/dev/null) //commented this original line INSTANCES=($(echo "${RESULT}" | jq -r '.Instances.Instance[].InstanceId' 2>/dev/null)) //add new line 1 COUNT=$((COUNT + ${#INSTANCES[@]})) //add new line 2 echo "${COUNT}" }