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

Commit 5d50664

Browse files
authored
Merge pull request #140 from spodila/fixScalarResCloning
fix cloning of scalar resources
2 parents d09a44a + 1c68206 commit 5d50664

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

fenzo-core/src/main/java/com/netflix/fenzo/InternalVMCloner.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,14 @@
6262
final Map<String, Double> maxScalars = avm.getMaxScalars();
6363
if (maxScalars != null && !maxScalars.isEmpty()) {
6464
for (String k: maxScalars.keySet())
65-
scalars.compute(k, (s, oldVal) -> oldVal + maxScalars.get(k));
65+
scalars.compute(k, (s, oldVal) -> {
66+
if (oldVal == null)
67+
oldVal = 0.0;
68+
Double aDouble = maxScalars.get(k);
69+
if (aDouble == null)
70+
aDouble = 0.0;
71+
return oldVal + aDouble;
72+
});
6673
}
6774
final Map<String, Protos.Attribute> attrs = avm.getCurrTotalLease().getAttributeMap();
6875
if (attrs != null && !attrs.isEmpty()) {

fenzo-core/src/test/java/com/netflix/fenzo/ShortfallAutoscalerTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,14 @@ public void testShortfallScaleup2groups() throws Exception {
176176
// create 3 VMs for group1 and 1 VM for group2
177177
int hostIdx=0;
178178
final List<VirtualMachineLease> leases = new ArrayList<>();
179-
leases.add(LeaseProvider.getLeaseOffer("host" + hostIdx++, cpus1, cpus1 * memMultiplier, ports, attributes1));
180-
leases.add(LeaseProvider.getLeaseOffer("host" + hostIdx++, cpus1, cpus1 * memMultiplier, ports, attributes1));
181-
leases.add(LeaseProvider.getLeaseOffer("host" + hostIdx++, cpus1, cpus1 * memMultiplier, ports, attributes1));
182-
leases.add(LeaseProvider.getLeaseOffer("host" + hostIdx++, cpus2, cpus2 * memMultiplier, ports, attributes2));
179+
leases.add(LeaseProvider.getLeaseOffer("host" + hostIdx++, cpus1, cpus1 * memMultiplier,
180+
0, 0, ports, attributes1, Collections.singletonMap("GPU", 1.0)));
181+
leases.add(LeaseProvider.getLeaseOffer("host" + hostIdx++, cpus1, cpus1 * memMultiplier,
182+
0, 0, ports, attributes1, Collections.singletonMap("GPU", 1.0)));
183+
leases.add(LeaseProvider.getLeaseOffer("host" + hostIdx++, cpus1, cpus1 * memMultiplier,
184+
0, 0, ports, attributes1, Collections.singletonMap("GPU", 1.0)));
185+
leases.add(LeaseProvider.getLeaseOffer("host" + hostIdx++, cpus2, cpus2 * memMultiplier,
186+
0, 0, ports, attributes2, Collections.singletonMap("GPU", 2.0)));
183187
// create 1-cpu tasks to fill VMS equal to two times the max size of group1, and also group2
184188
for (int i=0; i < (cpus1*rule1.getMaxSize() + cpus2* rule2.getMaxSize()); i++) {
185189
queue.queueTask(QueuableTaskProvider.wrapTask(qA1, TaskRequestProvider.getTaskRequest(1, memMultiplier, 1)));

0 commit comments

Comments
 (0)