Skip to content

Implement automatic retries for HTTP 409 errors from ImportOSLoginSSHKey #320

@Jalle19

Description

@Jalle19

We're constantly running into issues where we start two completely unrelated builds simultaneously, and one of them fails with the following error:

googlecompute.sc-rocky-baseimage: Checking image does not exist...
googlecompute.sc-rocky-baseimage: Creating temporary RSA SSH key for instance...
googlecompute.sc-rocky-baseimage: no persistent disk to create
googlecompute.sc-rocky-baseimage: Importing SSH public key for OSLogin...
googlecompute.sc-rocky-baseimage: Error importing SSH public key for OSLogin: googleapi: Error 409: Multiple concurrent mutations were attempted. Please retry the request.
googlecompute.sc-rocky-baseimage: Deleting SSH public key for OSLogin...
googlecompute.sc-rocky-baseimage: SSH public key for OSLogin has been deleted!
googlecompute.sc-rocky-baseimage' errored after 3 seconds 304 milliseconds: Error importing SSH public key for OSLogin: googleapi: Error 409: Multiple concurrent mutations were attempted. Please retry the request.

The code where the error originates is here: https://docs.cloud.google.com/go/docs/reference/cloud.google.com/go/oslogin/latest/apiv1#cloud_google_com_go_oslogin_apiv1_Client_ImportSshPublicKey

It would be preferable if Packer could retry the operation in these cases, since retrying the build will almost certainly make the error "go away". As far as I can tell the Go library used to interface with Google Cloud Platform doesn't support any retry mechanism though, so I'm not confident in trying to implement this myself.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions