v1.1.7 or later fails when building images in parallel
Overview of the Issue
Ever since v1.1.7, some of our windows builds have been failing with the error
"Error creating windows password: time out while waiting for the password to be created"
On a hunch, instead of having packer use oslogin to create the packer user we created the packer user in a startup script. We then started getting the error
"errored after 12 seconds 726 milliseconds: Error importing SSH public key for OSLogin: googleapi: Error 409: Multiple concurrent mutations were attempted. Please retry the request."
Reverting back to v1.1.6 of the plugin avoids all these errors.
Reproduction Steps
Run this template provided
Plugin and Packer version
1.12.0 or later
Simplified Packer Buildfile
packer {
required_plugins {
googlecompute = {
source = "github.com/hashicorp/googlecompute"
version = "~> 1.0"
}
}
}
source "googlecompute" "windows" {
project_id = var.project_id
ssh_username = "packer"
zone = "us-central1-a"
subnetwork = var.subnetwork
network_project_id = var.project_id
use_internal_ip = true
enable_secure_boot = true
omit_external_ip = true
use_iap = false
image_labels = {}
disk_size = 50
machine_type = "n2d-standard-2"
tags = ["packer", "allow-internet-egress"]
metadata = {
windows-startup-script-cmd = <<EOF
winrm quickconfig -quiet & winrm set winrm/config/service/auth @{Basic=\"true\"}
EOF
communicator = "winrm"
winrm_username = "packer_user"
winrm_insecure = true
winrm_use_ssl = true
windows_password_timeout = "15m"
# Limit source images to official Windows source projects
source_image_project_id = ["windows-cloud", "windows-sql-cloud"]
service_account_email = "packer-builder@${var.project_id}.iam.gserviceaccount.com"
scopes = [
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.full_control",
"https://www.googleapis.com/auth/cloud-platform", # Required to allow secret access
]
state_timeout = "15m" # Give it some extra time in case it takes longer than usual.
}
locals {
variants = {
"core-2025" = {
year = "2025"
flavor = "core"
description = "Core"
source_family = "windows-2025-core"
}
"full-2025" = {
year = "2025"
flavor = "full"
description = "Full"
source_family = "windows-2025"
}
"sql-standard-2022-win-2025" = {
year = "2025"
flavor = "sql-standard-2022"
description = "SQL Server Standard 2022"
source_family = "sql-std-2022-win-2025"
}
"sql-ent-2022-win-2025" = {
year = "2025"
flavor = "sql-enterprise-2022"
description = "SQL Server Enterprise 2022"
source_family = "sql-ent-2022-win-2025"
}
"core-2022" = {
year = "2022"
flavor = "core"
description = "Core"
source_family = "windows-2022-core"
}
"full-2022" = {
year = "2022"
flavor = "full"
description = "Full"
source_family = "windows-2022"
}
"sql-standard-2019-win-2022" = {
year = "2022"
flavor = "sql-standard-2019"
description = "SQL Server Standard 2022"
source_family = "sql-std-2019-win-2022"
}
"sql-ent-2019-win-2022" = {
year = "2022"
flavor = "sql-enterprise-2019"
description = "SQL Server Enterprise 2019"
source_family = "sql-ent-2019-win-2022"
}
"sql-ent-2022-win-2022" = {
year = "2022"
flavor = "sql-enterprise-2022"
description = "SQL Server Enterprise 2022"
source_family = "sql-ent-2022-win-2022"
}
"core-2019" = {
year = "2019"
flavor = "core"
description = "Core"
source_family = "windows-2019-core"
}
"sql-dev-2016-win-2019" = {
year = "2019"
flavor = "sql-developer-2016"
description = "2019 SQL Server 2016 Developer"
source_family = "windows-2019"
}
"sql-standard-2019-win-2019" = {
year = "2019"
flavor = "sql-standard-2019"
description = "SQL Server Standard 2019"
source_family = "sql-std-2019-win-2019"
}
"sql-ent-2019-win-2019" = {
year = "2019"
flavor = "sql-enterprise-2019"
description = "SQL Server Enterprise 2019"
source_family = "sql-ent-2019-win-2019"
}
"full-2019" = {
year = "2019"
flavor = "full"
description = "Full"
source_family = "windows-2019"
}
"full-2016" = {
year = "2016"
flavor = "full"
description = "Full"
source_family = "windows-2016"
}
"core-2016" = {
year = "2016"
flavor = "core"
description = "Core"
source_family = "windows-2016-core"
}
"sql-standard-2017-win-2016" = {
year = "2016"
flavor = "sql-standard-2017"
description = "SQL Server 2017 Standard"
source_family = "sql-std-2017-win-2016"
}
"sql-enterprise-2016-win-2016" = {
year = "2016"
flavor = "sql-enterprise-2016"
description = "SQL Server 2016 Enterprise"
source_family = "sql-ent-2016-win-2016"
}
"r2-full-2012" = {
year = "2012"
flavor = "r2-full"
description = "R2 Full"
source_family = "windows-2012-r2"
}
"citrix-daas-win2019" = {
year = "2019"
flavor = "citrix-daas"
description = "citrix-daas-win2019-single-vda-v20220819"
source_family = "windows-2019"
}
"sql-dev-2017-win-2022" = {
year = "2022"
flavor = "sql-developer-2017"
description = "2022 SQL Server 2017 Developer"
source_family = "windows-2022"
}
"sql-dev-2022-win-2022" = {
year = "2022"
flavor = "sql-developer-2022"
description = "2022 SQL Server 2022 Developer"
source_family = "windows-2022"
}
}
}
build {
name = "windows-server"
dynamic "source" {
for_each = local.variants
labels = ["source.googlecompute.windows"]
content {
name = source.key
image_name = "windows-server-${source.value.year}-${source.value.flavor}"
image_description = "Windows Server ${source.value.year} ${source.value.description}"
image_family = "windows-server-${source.value.year}-${source.value.flavor}"
source_image_family = source.value.source_family
}
}
# Prepare the instance to be turned into an image
provisioner "powershell" {
inline = [
"GCESysprep -NoShutdown"
]
}
}
This seems to happen with Linux hosts too. Well, not the "windows password" error, but the "Multiple concurrent mutations were attempted" one. :)
I've tried the newest 1.2.1 of the plugin and then downgraded 1.1.6 as suggested above, but that didn't seem to help.
Packer version is 1.13.1.