hashicorp / hashicorp/packer-plugin-oracle

Intermittent 409 Conflict with another image operation

Open
#102 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
14
Forks
16
PR merge metrics
No merged PRs in 30d

Description

#### Overview of the Issue

Packer occasionally gets a 409 response when telling OCI to create the image

This is the error:

```txt
==> oracle-oci.oracle: Creating image from instance...
==> oracle-oci.oracle: Error creating image from instance: Error returned by Compute Service. Http Status Code: 409. Error Code: Conflict. Opc request id: xxxxx/xxxxxx. Message: Conflict with another image operation, try again later
==> oracle-oci.oracle: Operation Name: CreateImage
==> oracle-oci.oracle: Timestamp: 2023-09-15 17:36:21 +0000 GMT
==> oracle-oci.oracle: Client Version: Oracle-GoSDK/65.4.0
==> oracle-oci.oracle: Request Endpoint: POST https://iaas.us-ashburn-1.oraclecloud.com/20160918/images
==> oracle-oci.oracle: Troubleshooting Tips: See https://docs.oracle.com/iaas/Content/API/References/apierrors.htm#apierrors_409__409_conflict for more information about resolving this error.
==> oracle-oci.oracle: Also see https://docs.oracle.com/iaas/api/#/en/iaas/20160918/Image/CreateImage for details on this operation's requirements.
==> oracle-oci.oracle: To get more info on the failing request, you can set OCI_GO_SDK_DEBUG env var to info or higher level to log the request/response details.
==> oracle-oci.oracle: If you are unable to resolve this Compute issue, please contact Oracle support and provide them this full error message.
```

This seems like the sort of thing that some retry logic, maybe exponential backoff for this 409 error could help. Having to redo the whole packer build in a retry loop (which may not even work), just because the final create image failed is quite annoying.

#### Reproduction Steps

I cannot reproduce this reliably. It seems to be because of something else happening in OCI so it doesn't always happen. I can retry the exact same image build without any changes.

### Plugin and Packer version

packer: 1.9.2
packer oracle plugin 1.0.4

### Simplified Packer Buildfile

There's nothing special here. I won't give all the variable definitions or provisioners, but something like this:

```hcl
source "oracle-oci" "oracle" {
access_cfg_file_account = var.oci_profile
tenancy_ocid = var.oci_tenancy_ocid
user_ocid = var.oci_user_ocid
key_file = var.oci_key_file
fingerprint = var.oci_fingerprint

region = var.oci_region
compartment_ocid = var.oci_compartment
availability_domain = var.oci_ad
subnet_ocid = var.oci_subnet

base_image_filter {
display_name_search = "^oracle-8-.*$"
}

ssh_username = "opc"
image_name = local.image_name
instance_name = "packer-${local.image_name}"

shape = "VM.Standard.E4.Flex"
shape_config {
ocpus = 2
memory_in_gbs = 8
}

create_vnic_details {
hostname_label = "packer-${formatdate("YYYYMMDDHHmmss", timestamp())}"
}

tags = {
Name = "example"
}
}

build {
sources = ["source.oracle-oci.oracle"]

provisioner "shell" {
inline = ["echo example"]
}

post-processor "manifest" {
output = "pkg/manifest.json"
strip_path = true
}
}
```

### Operating system and Environment details

Building from a CentOS 8 steam docker image with `packer` and various other tools. Build sets all these environment variables to get packer and/or other oci tooling to auth: `TF_VAR_private_key_path`, `TF_VAR_user_ocid`, `TF_VAR_fingerprint`, `TF_VAR_tenancy_ocid`, `OCI_CLI_KEY_FILE`, `OCI_CLI_USER`, `OCI_CLI_FINGERPRINT`, `OCI_CLI_TENANCY`, `OCI_CLI_AUTH=api_key`, `OCI_CLI_REGION`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.