Overview
When I tried to launch a Centos 8 image (see Launch Compute Instance), I get a lifecycle state of TERMINATED.
Status
RESOLVED
Workaround
None found
Resolution
I will have to delete the VCN and associated resources before recreating the VCN as the oci network vcn update
command does not update DNS fields.
Diagnosis
Summary
The Sandbox VCN was created without DNS being specified. To change the DNS settings, the VCN has to be recreated from scratch.
Get Error Message
The oci compute instance launch
command returns the following (in part):
Action completed. Waiting until the resource has entered state: ('RUNNING', 'TERMINATED') { "data": { … "lifecycle-state": "TERMINATED", … }, "etag": "04fa80d21b9967ef6c068ef87fa79d8c477f9090d46f383cb0c7e17402fd94e6" }
Using the procedure described in Get Work Request Error, I find the error message to be:
A problem occurred while preparing the instance's VNIC. ((400, InvalidParameter, false) Cannot create a VNIC with hostnameLabel. Subnet ocid1.subnet.oc1.ap-sydney-1.aaaaaaaabfb6tyssv2t4dxci5mhymomqmrhwdq2nmagdtezfp4ifmbca7c5q does not have DNS enabled (opc-request-id: dummyRequestId))
Display DNS Settings for Subnet
There are two (2) fields in the Subnet definition that appear to be related to DNS. Run the following commands to get those fields.
export subnet_ocid=ocid1.subnet.oc1.ap-sydney-1.aaaaaaaabfb6tyssv2t4dxci5mhymomqmrhwdq2nmagdtezfp4ifmbca7c5q oci network subnet get \ --subnet-id ${subnet_ocid} \ --query 'data.{"Display Name":"display-name","DNS Label":"dns-label","Subnet Domain Name":"subnet-domain-name"}' \ --output table
The output is:
+-----------+---------------------------+--------------------+ | DNS Label | Display Name | Subnet Domain Name | +-----------+---------------------------+--------------------+ | None | public subnet-sandbox-vcn | None | +-----------+---------------------------+--------------------+ etag: 5f69be5e
A full output is uploaded as subnet-orig.json
Investigate Remedies
Editing a Subnet says that the following attributes of a subnet can be changed:
- Name
- Route Table
- DHCP Options
- Security Lists
- Tags
There is no option to change the DNS options directly for a subnet.
Examine DHCP Options
There are fields within the DHCP Options document. Run the following commands to find the OCID for the DHCP Options associated with a subnet, and to dump the contents of the DHCP Options document:
export subnet_ocid=ocid1.subnet.oc1.ap-sydney-1.aaaaaaaabfb6tyssv2t4dxci5mhymomqmrhwdq2nmagdtezfp4ifmbca7c5q export dhcp_ocid=$( \ oci network subnet get \ --subnet-id ${subnet_ocid} \ --query 'data."dhcp-options-id"' \ --raw-output \ ) oci network dhcp-options get \ --dhcp-id ${dhcp_ocid} \ >dhcp-options-orig.json
The output was (in part - the full output is uploaded as dhcp-options-orig.json):
… "domain-name-type": "CUSTOM_DOMAIN", … "options": [ { "custom-dns-servers": [], "server-type": "VcnLocalPlusInternet", "type": "DomainNameServer" } ], …
It looks like it is possible to update the DHCP Options to fix the DNS issue.
Change DHCP Options to Use VCN DNS
Run the following commands to change the Domain Name Type field to 'VCN_DOMAIN' from 'CUSTOM_DOMAIN' in the DHCP Options for the selected Subnet:
export subnet_ocid=ocid1.subnet.oc1.ap-sydney-1.aaaaaaaabfb6tyssv2t4dxci5mhymomqmrhwdq2nmagdtezfp4ifmbca7c5q export dhcp_ocid=$( \ oci network subnet get \ --subnet-id ${subnet_ocid} \ --query 'data."dhcp-options-id"' \ --raw-output \ ) oci network dhcp-options update \ --dhcp-id ${dhcp_ocid} \ --domain-name-type VCN_DOMAIN \ --query 'data."domain-name-type"'
The output is:
"VCN_DOMAIN"
Retry Compute Launch
Now that I have updated the DHCP Options for the subnet, I tried launch again using Launch Compute Instance. This failed with the same error:
+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ | code | message | timestamp | +-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+ | vcn-error | A problem occurred while preparing the instance's VNIC. ((400, InvalidParameter, false) Cannot create a VNIC with hostnameLabel. Subnet ocid1.subnet.oc1.ap-sydney-1.aaaaaaaabfb6tyssv2t4dxci5mhymomqmrhwdq2nmagdtezfp4ifmbca7c5q does not have DNS enabled (opc-request-id: dummyRequestId)) | 2024-06-17T20:00:55.491000+00:00 | +-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------+
Examine VCN DNS Fields
Run the following commands to get the DNS fields for the Sandbox VCN:
export subnet_ocid=ocid1.subnet.oc1.ap-sydney-1.aaaaaaaabfb6tyssv2t4dxci5mhymomqmrhwdq2nmagdtezfp4ifmbca7c5q export sandbox_ocid=$( \ oci network subnet get \ --subnet-id ${subnet_ocid} \ --query 'data."vcn-id"' \ --raw-output \ ) oci network vcn list \ --compartment-id ${sandbox_ocid} \ --query 'data[*].{"VCN Name":"display-name","DNS":"dns-label","VCN Domain Name":"vcn-domain-name"}' \ --output table
The output is:
+------+-----------------+-------------+ | DNS | VCN Domain Name | VCN Name | +------+-----------------+-------------+ | None | None | sandbox-vcn | +------+-----------------+-------------+
The changes to the DHCP Options for the subnet are not propagated upwards to the VCN. I will have to delete the VCN and associated resources before recreating the VCN as the oci network vcn update
command does not update DNS fields.