NIC id changes in VM

Please, describe the problem here and provide additional information below (if applicable) …
After the power cycle of VM instance, it changes nic order if I had nic 0 as private, nic 1 as public, nic 2 as storage and eth0 assigned to private IP, eth1 assigned to public IP, eth2 assigned to storage IP (statically inside the VM). Opennebula changes the assignment making eth2 assigned with public IP and eth1 assigned with storage IP. The only recourse for this is to shut down the instance and remove/recreate the nic cards, applying proper security policies

Versions of the related components and OS (frontend, hypervisors, VMs):
One, 5.8.1, Ubuntu 18.0.4.2

Steps to reproduce:
Power cycle VM. It doesn’t happen all the time but it happened to me twice during the same evening

Current results:
NICs internally out of order

Expected results:

NIC ids order match ethernet IDS order inside the VM
0 -> eth0
1 -> eth1
2 -> eth2

Hello @Alexander_Litvak

Could you please send me the VM template and the ip a when the problem occurs?

Do you want template vm based on in general or how one sees template when the problem occurs?

Send me the template onetemplate show <TEMPLATE_ID> -x and the the problematic vm onevm show <VM_ID> -x

<VMTEMPLATE>
  <ID>25</ID>
  <UID>4</UID>
  <GID>0</GID>
  <UNAME>alitvak</UNAME>
  <GNAME>oneadmin</GNAME>
  <NAME>CentOS 7 - WebApps</NAME>
  <PERMISSIONS>
    <OWNER_U>1</OWNER_U>
    <OWNER_M>1</OWNER_M>
    <OWNER_A>0</OWNER_A>
    <GROUP_U>0</GROUP_U>
    <GROUP_M>0</GROUP_M>
    <GROUP_A>0</GROUP_A>
    <OTHER_U>0</OTHER_U>
    <OTHER_M>0</OTHER_M>
    <OTHER_A>0</OTHER_A>
  </PERMISSIONS>
  <REGTIME>1540932589</REGTIME>
  <TEMPLATE>
    <CONTEXT>
      <KVM><![CDATA[<devices><serial type="pty"><source path="/dev/pts/5"/><target port="0"/></serial><console type="pty" tty="/dev/pts/5"><source path="/dev/pts/5"/><target port="0"/></console></devices>]]></KVM>
      <NETWORK><![CDATA[YES]]></NETWORK>
      <SSH_PUBLIC_KEY><![CDATA[$USER[SSH_PUBLIC_KEY]]]></SSH_PUBLIC_KEY>
    </CONTEXT>
    <CPU><![CDATA[2]]></CPU>
    <CPU_MODEL>
      <MODEL><![CDATA[Westmere]]></MODEL>
    </CPU_MODEL>
    <DESCRIPTION><![CDATA[Web Servers template]]></DESCRIPTION>
    <DISK>
      <CACHE><![CDATA[writeback]]></CACHE>
      <DEV_PREFIX><![CDATA[sd]]></DEV_PREFIX>
      <IMAGE_ID><![CDATA[18]]></IMAGE_ID>
    </DISK>
    <DISK>
      <DEV_PREFIX><![CDATA[sd]]></DEV_PREFIX>
      <FORMAT><![CDATA[raw]]></FORMAT>
      <SIZE><![CDATA[4096]]></SIZE>
      <TYPE><![CDATA[swap]]></TYPE>
    </DISK>
    <FEATURES>
      <ACPI><![CDATA[yes]]></ACPI>
      <APIC><![CDATA[yes]]></APIC>
      <LOCALTIME><![CDATA[yes]]></LOCALTIME>
      <VIRTIO_SCSI_QUEUES><![CDATA[4]]></VIRTIO_SCSI_QUEUES>
    </FEATURES>
    <GRAPHICS>
      <LISTEN><![CDATA[0.0.0.0]]></LISTEN>
      <TYPE><![CDATA[VNC]]></TYPE>
    </GRAPHICS>
    <INPUTS_ORDER><![CDATA[]]></INPUTS_ORDER>
    <LOGO><![CDATA[images/logos/centos.png]]></LOGO>
    <MEMORY><![CDATA[4096]]></MEMORY>
    <MEMORY_UNIT_COST><![CDATA[MB]]></MEMORY_UNIT_COST>
    <NIC>
      <NETWORK><![CDATA[private]]></NETWORK>
      <NETWORK_UNAME><![CDATA[oneadmin]]></NETWORK_UNAME>
      <SECURITY_GROUPS><![CDATA[100]]></SECURITY_GROUPS>
    </NIC>
    <NIC>
      <NETWORK><![CDATA[public]]></NETWORK>
      <NETWORK_UNAME><![CDATA[alitvak]]></NETWORK_UNAME>
      <SECURITY_GROUPS><![CDATA[104]]></SECURITY_GROUPS>
    </NIC>
    <NIC>
      <NETWORK><![CDATA[storage]]></NETWORK>
      <NETWORK_UNAME><![CDATA[alitvak]]></NETWORK_UNAME>
      <SECURITY_GROUPS><![CDATA[0]]></SECURITY_GROUPS>
    </NIC>
    <OS>
      <ARCH><![CDATA[x86_64]]></ARCH>
      <BOOT><![CDATA[]]></BOOT>
    </OS>
    <SCHED_DS_RANK><![CDATA[FREE_MB]]></SCHED_DS_RANK>
    <SCHED_RANK><![CDATA[FREE_CPU]]></SCHED_RANK>
    <VCPU><![CDATA[2]]></VCPU>
  </TEMPLATE>
</VMTEMPLATE>

I couldn’t reproduce problem again but template is here.

Looking at the template I actually wonder if there is a way to insert a tag that would anchor each NIC to a specific order id? I tried inserting eth1 in the device name and VM couldn’t boot.

No, you can’t do that. The way that it is doing is the following:

  • You have a list of nics in the template.
  • The core will take that list and will generate the context variables.
  • Inside the VM there are some contextualisation scripts under /etc/one-context.d.
  • Those scripts are going to take the context variables stored in the context cd-rom and will contextualise the VM.

So you can check in that cd-rom which is the order, but you can’t change it, because is the core who generates it. Usually the order is the same as the template, I don’t why it changed in your case, maybe you did a detach/attach or some operations with nics.

Alejandro,

Where this cd-rom is being stored? I don’t see it mounted on VM.

Hello @Alexander_Litvak

You can find the cd-rom with label CONTEXT so you can mount it and check it.