@@ -63,26 +63,30 @@ function configureCoreDevAccess() {
63
63
}
64
64
65
65
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 )
68
68
} else {
69
69
werft . currentPhaseSpan . setAttribute ( "werft.harvester.created_vm" , false )
70
70
}
71
71
werft . done ( prepareSlices . BOOT_VM )
72
72
}
73
73
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 ) {
75
84
if ( config . cleanSlateDeployment ) {
76
85
werft . log ( prepareSlices . BOOT_VM , "Cleaning previously created VM" )
77
86
VM . deleteVM ( { name : config . previewEnvironment . destname } )
78
87
}
79
- createVM ( werft , config , prepareSlices . BOOT_VM )
80
- }
81
88
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' )
86
90
VM . startVM ( { name : config . previewEnvironment . destname } )
87
91
werft . currentPhaseSpan . setAttribute ( "werft.harvester.created_vm" , true )
88
92
}
0 commit comments