Skip to content

Prevent infinite autoscaling #11244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ public interface AutoScaleVmGroupVmMapDao extends GenericDao<AutoScaleVmGroupVmM
public boolean removeByVm(long vmId);

public boolean removeByGroup(long vmGroupId);

int getErroredInstanceCount(long vmGroupId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,13 @@ public boolean removeByGroup(long vmGroupId) {
sc.setParameters("vmGroupId", vmGroupId);
return remove(sc) >= 0;
}

@Override
public int getErroredInstanceCount(long vmGroupId) {
SearchCriteria<Integer> sc = CountBy.create();
sc.setParameters("vmGroupId", vmGroupId);
sc.setJoinParameters("vmSearch", "states", State.Error);
final List<Integer> results = customSearch(sc, null);
return results.get(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@


import com.cloud.hypervisor.HypervisorGuru;
import com.cloud.network.as.AutoScaleManager;
import com.cloud.user.AccountManagerImpl;
import com.cloud.utils.crypt.DBEncryptionUtil;
import com.cloud.host.HostTagVO;
Expand Down Expand Up @@ -570,6 +571,7 @@ protected void populateConfigValuesForValidationSet() {
configValuesForValidation.add(UserDataManager.VM_USERDATA_MAX_LENGTH_STRING);
configValuesForValidation.add(UnmanagedVMsManager.RemoteKvmInstanceDisksCopyTimeout.key());
configValuesForValidation.add(UnmanagedVMsManager.ConvertVmwareInstanceToKvmTimeout.key());
configValuesForValidation.add(AutoScaleManager.AutoScaleErroredInstanceThreshold.key());
}

private void weightBasedParametersForValidation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public interface AutoScaleManager extends AutoScaleService {
"The Number of worker threads to scan the autoscale vm groups.",
false);

ConfigKey<Integer> AutoScaleErroredInstanceThreshold = new ConfigKey<>(ConfigKey.CATEGORY_ADVANCED, Integer.class,
"autoscale.errored.instance.threshold",
"10",
"The number of Error Instances allowed in autoscale vm groups for scale up.",
true);

void checkAutoScaleUser(Long autoscaleUserId, long accountId);

boolean deleteAutoScaleVmGroupsByAccount(Long accountId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,11 @@ private boolean checkConditionUp(AutoScaleVmGroupVO asGroup, Integer numVm) {
s_logger.warn("number of VM will greater than the maximum in this group if scaling up, so do nothing more");
return false;
}
int erroredInstanceCount = autoScaleVmGroupVmMapDao.getErroredInstanceCount(asGroup.getId());
if (erroredInstanceCount > AutoScaleManager.AutoScaleErroredInstanceThreshold.value()) {
s_logger.warn("Number of Errored Instances are greater than the threshold in this group for scaling up, so do nothing more");
return false;
}
return true;
}

Expand Down Expand Up @@ -2202,7 +2207,8 @@ public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] {
AutoScaleStatsInterval,
AutoScaleStatsCleanupDelay,
AutoScaleStatsWorker
AutoScaleStatsWorker,
AutoScaleErroredInstanceThreshold
};
}

Expand Down
Loading