Help Center> Virtual Private Cloud> FAQ> Connectivity> How Do I Handle the Cloud-init Connection Failure?

How Do I Handle the Cloud-init Connection Failure?

Cloud-init Network

Figure 1 shows the process for an ECS to obtain metadata using the cloud-init.

Figure 1 Process for obtaining metadata

Troubleshooting Procedure

  1. Check whether the ECS has obtained an IP address.

    If no IP address is obtained, run the dhclient command to obtain the IP address (this command varies depending on the ECS OSs). Alternatively, you can run the ifdown ethx command to disable the network port and then run the ifup ethx command to enable it to allow the ECS NIC to automatically obtain an IP address again.

    Figure 2 ECS IP address
  1. Ping IP address 169.254.169.254/32 from the ECS. If the IP address cannot be pinged, perform the following steps:
    1. Check the exact route configured on the ECS for IP address 169.254.169.254/32.

      In most cases, the next hop of the exact route for IP address 169.254.169.254/32 is the same as that of the default route for the IP address.

      Figure 3 Route for IP address 169.254.169.254/32
    2. If there is no exact route for IP address 169.254.169.254/32, the cause is as follows:

      Images with CentOS 5 OSs do not support the cloud-init function. To use this function, change the ECS OS.

    3. If the next hop of the exact route for IP address 169.254.169.254/32 is different from that of the default route for the IP address, handle the issue based on the following information:
      • If the ECS was created before the cloud-init function is enabled, run the service network restart command to obtain the correct route.
      • If the ECS was created after the cloud-init function is enabled, go to step 6.
  2. The cloud-init connection failure may also be caused by the metadata obtaining fault on the ECS.

    Run the following command on the ECS to enable it to obtain the metadata:

    curl http://169.254.169.254/openstack/latest/meta_data.json

    If information similar to that shown in Figure 4 is displayed, the ECS successfully obtains the metadata.

    Figure 4 Command output
  1. If you cannot log in to the ECS or cannot create a non-root user after cloud-init is configured and when the service is running properly, the cause may be as follows:

    Check whether the /etc/cloud/cloud.cfg configuration file format is correct. For details, see the file format requirements posed by Linux OS providers. The following figure shows the example /etc/cloud/cloud.cfg configuration file for the Ubuntu OSs.

    Figure 5 Configuration file
  1. If you cannot use an obtained private key to log in to an ECS after the ECS starts or you cannot obtain the ECS login password, restart the ECS to rectify the fault.
  2. If you still cannot use the cloud-init function after the preceding steps, contact technical support for assistance.

    You need to provide the technical support engineer with the following information.

    Item

    Description

    Example

    Your Value

    VPC CIDR block

    Required for customer gateway configuration

    Example: 10.0.0.0/16

    N/A

    VPC ID

    N/A

    Example: 120b71c7-94ac-45b8-8ed6-30aafc8fbdba

    N/A

    CIDR block of subnet 1 (can be the same as the VPC CIDR block)

    N/A

    Example: 10.0.1.0/24

    N/A

    ECS ID

    N/A

    N/A

    N/A

    ECS IP address

    N/A

    Example: 192.168.1.192/24

    N/A

    ECS route information

    N/A

    N/A

    N/A