Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Cleanup autoscaler log statements #159

Merged
merged 1 commit into from
Aug 15, 2017
Merged
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
Remove the info log lines for autoscaling
Add debug logs for the autoscaler processing and executing of callbacks
  • Loading branch information
corindwyer committed Aug 15, 2017
commit 6a009e134d529cdd22fcd99e3121801cadcbabf4
36 changes: 20 additions & 16 deletions fenzo-core/src/main/java/com/netflix/fenzo/AutoScaler.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,10 @@ private List<Runnable> processScalingNeeds(HostAttributeGroup hostAttributeGroup
scalingActivity.inactiveScaleDownRequestedAt = 0L;
scalingActivity.inactiveScaleDownAt = now;
Map<String, String> hostsToTerminate = getInactiveHostsToTerminate(hostAttributeGroup.idleInactiveHosts);
StringBuilder sBuilder = new StringBuilder();
for (String host : hostsToTerminate.keySet()) {
sBuilder.append(host).append(", ");
if (logger.isDebugEnabled()) {
logger.debug("{} has an excess of {} inactive hosts ({})", rule.getRuleName(), hostsToTerminate.size(),
String.join(", ", hostsToTerminate.keySet()));
}
logger.info("Scaling down inactive hosts " + rule.getRuleName() + " by "
+ hostsToTerminate.size() + " hosts (" + sBuilder.toString() + ")");
allHostsToTerminate.addAll(hostsToTerminate.values());
}
}
Expand All @@ -224,14 +222,14 @@ private List<Runnable> processScalingNeeds(HostAttributeGroup hostAttributeGroup
Map<String, String> hostsToTerminate = getHostsToTerminate(hostAttributeGroup.idleHosts, excess);
scalingActivity.scaledNumInstances = hostsToTerminate.size();
scalingActivity.type = AutoScaleAction.Type.Down;
StringBuilder sBuilder = new StringBuilder();
for (String host : hostsToTerminate.keySet()) {
sBuilder.append(host).append(", ");
long disabledDurationInSecs = Math.max(disabledVmDurationInSecs, rule.getCoolDownSecs());
assignableVMs.disableUntil(host, now + disabledDurationInSecs * 1000);
}
logger.info("Scaling down " + rule.getRuleName() + " by "
+ hostsToTerminate.size() + " hosts (" + sBuilder.toString() + ")");
if (logger.isDebugEnabled()) {
logger.debug("{} has an excess of {} hosts ({})", rule.getRuleName(), hostsToTerminate.size(),
String.join(", ", hostsToTerminate.keySet()));
}
allHostsToTerminate.addAll(hostsToTerminate.values());
}
}
Expand All @@ -245,8 +243,7 @@ private List<Runnable> processScalingNeeds(HostAttributeGroup hostAttributeGroup
scalingActivity.scaleUpRequestedAt = now;
} else if (delayScaleUpBySecs == 0L || lastReqstAge > delayScaleUpBySecs) {
int shortage = (excess <= 0 && shouldScaleUp(now, prevScalingActivity, rule)) ?
rule.getMaxIdleHostsToKeep() - hostAttributeGroup.idleHosts.size() :
0;
rule.getMaxIdleHostsToKeep() - hostAttributeGroup.idleHosts.size() : 0;
shortage = Math.max(shortage, hostAttributeGroup.shortFall);
final int size = vmCollection.size(rule.getRuleName());
if (shortage + size > rule.getMaxSize())
Expand All @@ -257,17 +254,24 @@ private List<Runnable> processScalingNeeds(HostAttributeGroup hostAttributeGroup
scalingActivity.shortfall = hostAttributeGroup.shortFall;
scalingActivity.scaledNumInstances = shortage;
scalingActivity.type = AutoScaleAction.Type.Up;
logger.info("Scaling up " + rule.getRuleName() + " by "
+ shortage + " hosts");
int finalShortage = shortage;
callbacks.add(() -> callback.call(new ScaleUpAction(rule.getRuleName(), finalShortage)));
logger.debug("{} has a shortage of {} hosts", rule.getRuleName(), finalShortage);
callbacks.add(() -> {
logger.debug("Executing callback to scale up {} by {} hosts", rule.getRuleName(), finalShortage);
callback.call(new ScaleUpAction(rule.getRuleName(), finalShortage));
});
}
}
}
}
// Run scale-down action after scale up (if any)
if (!allHostsToTerminate.isEmpty()) {
callbacks.add(() -> callback.call(new ScaleDownAction(rule.getRuleName(), allHostsToTerminate)));
callbacks.add(() -> {
if (logger.isDebugEnabled()) {
logger.debug("Executing callback to scale down {} by {} hosts ({})", rule.getRuleName(), allHostsToTerminate.size(),
String.join(", ", allHostsToTerminate));
}
callback.call(new ScaleDownAction(rule.getRuleName(), allHostsToTerminate));
});
}

return callbacks;
Expand Down