summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2020-04-13 17:28:22 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-04-13 17:37:42 +0200
commitfacf2a785ff7c7cd4f904b4b42af415bb85ea7a0 (patch)
treefccbcd3ca40ef702dd11da1e3772fbb329ef711d
parent5db71b206f6bb77d6bb77c5f58c299bc87d1414b (diff)
bug: Restrict provisioning to 5 minute batches
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt13
1 files changed, 12 insertions, 1 deletions
diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt
index 2d467e92..6200ad7c 100644
--- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt
+++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt
@@ -106,8 +106,14 @@ class SimpleVirtProvisioningService(
return
}
+ val quantum = 300000 // 5 minutes in milliseconds
+ // We assume that the provisioner runs at a fixed slot every time quantum (e.g t=0, t=60, t=120).
+ // This is important because the slices of the VMs need to be aligned.
+ // We calculate here the delay until the next scheduling slot.
+ val delay = quantum - (ctx.clock.millis() % quantum)
+
val call = launch {
- delay(1)
+ delay(delay)
this@SimpleVirtProvisioningService.call = null
schedule()
}
@@ -148,6 +154,11 @@ class SimpleVirtProvisioningService(
if (event.server.state == ServerState.SHUTOFF) {
activeImages -= imageInstance
selectedHv.provisionedCores -= server.flavor.cpuCount
+
+ // Try to reschedule if needed
+ if (incomingImages.isNotEmpty()) {
+ requestCycle()
+ }
}
}
}