@@ -19,8 +19,9 @@ export async function prepare(werft: Werft, config: JobConfig) {
19
19
configureDocker ( )
20
20
configureCoreDevAccess ( )
21
21
werft . done ( prepareSlices . CONFIGURE_CORE_DEV )
22
-
23
- decideHarvesterVMCreation ( werft , config )
22
+ if ( config . withVM ) {
23
+ prepareVM ( werft , config )
24
+ }
24
25
} catch ( err ) {
25
26
werft . fail ( phaseName , err ) ;
26
27
}
@@ -63,7 +64,9 @@ function configureCoreDevAccess() {
63
64
}
64
65
65
66
function decideHarvesterVMCreation ( werft : Werft , config : JobConfig ) {
66
- if ( config . withVM && ! VM . vmExists ( { name : config . previewEnvironment . destname } ) ) {
67
+ werft . log ( `prepare` , VM . vmExists ( { name : config . previewEnvironment . destname } ) )
68
+ && {
69
+ werft. log ( `prepare` , `Prepare VM` )
67
70
prepareVM ( werft , config )
68
71
} else {
69
72
werft . currentPhaseSpan . setAttribute ( "werft.harvester.created_vm" , false )
@@ -72,11 +75,14 @@ function decideHarvesterVMCreation(werft: Werft, config: JobConfig) {
72
75
}
73
76
74
77
function prepareVM ( werft : Werft , config : JobConfig ) {
75
- if ( config . cleanSlateDeployment ) {
78
+ if ( config . cleanSlateDeployment && VM . vmExists ( { name : config . previewEnvironment . destname } ) ) {
76
79
werft . log ( prepareSlices . BOOT_VM , "Cleaning previously created VM" )
77
80
VM . deleteVM ( { name : config . previewEnvironment . destname } )
78
81
}
79
- createVM ( werft , config , prepareSlices . BOOT_VM )
82
+ if ( ! VM . vmExists ( { name : config . previewEnvironment . destname } ) ) {
83
+ werft . log ( prepareSlices . BOOT_VM , "Creating VM" )
84
+ createVM ( werft , config , prepareSlices . BOOT_VM )
85
+ }
80
86
}
81
87
82
88
// createVM only triggers the VM creation.
0 commit comments