Skip to content

Commit 3e35224

Browse files
ArthurSensroboquat
authored andcommitted
.werft/prepare: Make sure we respect cleanSlateDeployment annotation
Signed-off-by: ArthurSens <[email protected]>
1 parent 99dcc8b commit 3e35224

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

.werft/jobs/build/prepare.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,30 @@ function configureCoreDevAccess() {
6363
}
6464

6565
function decideHarvesterVMCreation(werft: Werft, config: JobConfig) {
66-
if (config.withVM && !VM.vmExists({ name: config.previewEnvironment.destname })) {
67-
prepareVM(werft, config)
66+
if (shouldCreateVM(config)) {
67+
createVM(werft, config)
6868
} else {
6969
werft.currentPhaseSpan.setAttribute("werft.harvester.created_vm", false)
7070
}
7171
werft.done(prepareSlices.BOOT_VM)
7272
}
7373

74-
function prepareVM(werft: Werft, config: JobConfig) {
74+
function shouldCreateVM(config: JobConfig) {
75+
return config.withVM && (
76+
!VM.vmExists({ name: config.previewEnvironment.destname }) ||
77+
config.cleanSlateDeployment
78+
)
79+
}
80+
81+
// createVM only triggers the VM creation.
82+
// Readiness is not guaranted.
83+
function createVM(werft: Werft, config: JobConfig) {
7584
if (config.cleanSlateDeployment) {
7685
werft.log(prepareSlices.BOOT_VM, "Cleaning previously created VM")
7786
VM.deleteVM({ name: config.previewEnvironment.destname })
7887
}
79-
createVM(werft, config, prepareSlices.BOOT_VM)
80-
}
8188

82-
// createVM only triggers the VM creation.
83-
// Readiness is not guaranted.
84-
function createVM(werft: Werft, config: JobConfig, slice: string) {
85-
werft.log(slice, 'Booting VM')
89+
werft.log(prepareSlices.BOOT_VM, 'Creating VM')
8690
VM.startVM({ name: config.previewEnvironment.destname })
8791
werft.currentPhaseSpan.setAttribute("werft.harvester.created_vm", true)
8892
}

0 commit comments

Comments
 (0)