Skip to content

Fixing the clean-slate-deployment of new VM base preview-environments #8748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions .werft/jobs/build/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,30 @@ function configureCoreDevAccess() {
}

function decideHarvesterVMCreation(werft: Werft, config: JobConfig) {
if (config.withVM && !VM.vmExists({ name: config.previewEnvironment.destname })) {
prepareVM(werft, config)
if (shouldCreateVM(config)) {
createVM(werft, config)
} else {
werft.currentPhaseSpan.setAttribute("werft.harvester.created_vm", false)
}
werft.done(prepareSlices.BOOT_VM)
}

function prepareVM(werft: Werft, config: JobConfig) {
function shouldCreateVM(config: JobConfig) {
return config.withVM && (
!VM.vmExists({ name: config.previewEnvironment.destname }) ||
config.cleanSlateDeployment
)
}

// createVM only triggers the VM creation.
// Readiness is not guaranted.
function createVM(werft: Werft, config: JobConfig) {
if (config.cleanSlateDeployment) {
werft.log(prepareSlices.BOOT_VM, "Cleaning previously created VM")
VM.deleteVM({ name: config.previewEnvironment.destname })
}
createVM(werft, config, prepareSlices.BOOT_VM)
}

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