admin管理员组

文章数量:1187854

I'm using Terraform to manage OpenStack resources and I'm encountering an issue where a port is apparently in a "DOWN" state after attaching it to an instance using the openstack_compute_interface_attach_v2 resource.

Here's a simplified version of my Terraform configuration:

resource "openstack_networking_port_v2" "port" {
  network_id = "<network_id>"

  fixed_ip {
    subnet_id = "<subnet_id>"
  }

  security_group_ids = "<security_group_ids>"
}

resource "openstack_compute_interface_attach_v2" "attachment" {
  instance_id = "<instance_id>"
  port_id     = "<port_id>"
}

The port is created successfully, however after attaching it to the instance the port appears to not work correctly. In the OpenStack dashboard, the port status shows as active and using the openstack-cli to inspect the port also confirms that the port is active. However, when I SSH into the VM and check the network interfaces, the attached port shows as DOWN.

root@test:~# ip addr
...
...
3: ens7: <BROADCAST,MULTICAST> mtu 8900 qdisc noop state DOWN group default qlen 1000
    link/ether ...
    altname enp0s7

The interface ens7 corresponds to the port that was attached via Terraform.

Inside the VM, I manually ran the following commands to fix the issue temporarily:

Set the interface to the UP state.

  1. ip link set ens7 up

Obtain the IP address for ens7, which matches the fixed IP to the port.

  1. dhclient ens7

After running these commands, the ens7 interface is now fully functional.

Questions:

Why does the attached port not work out of the box without manually bringing it up and requesting an IP address using DHCP? Is this a configuration issue in OpenStack, the instance OS, or Terraform (provider)?

How can I ensure the interface is fully functional automatically after attachment without requiring manual intervention?

本文标签: terraformWhy is my OpenStack port down after attaching it to an instanceStack Overflow