Skip to content

Conversation

@winiciusallan
Copy link
Contributor

This PR adds the binding:host field as hostID field on spec.

Notes:

  • The API reference says that we can filter ports using the hostID, but Gophercloud doesn't support it at the time.

Partial: #616

@github-actions github-actions bot added the semver:minor Backwards-compatible change label Jan 6, 2026
// hostID is the ID of host where the port resides.
// +kubebuilder:validation:MaxLength=36
// +optional
HostID string `json:"hostID,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wished there was a way to represent a Host resource in ORC so that we could have a HostRef rather than a HostID.
In that case, HostID is an ID that is exposed to a user via the nova API in the server object and that is hashed from the project ID.

According to the nova docs:

An ID string representing the host. This is a hashed value so will not actually look like a hostname, and is hashed with data from the project_id, so the same physical host as seen by two different project_ids, will be different. It is useful when within the same project you need to determine if two instances are on the same or different physical hosts for the purposes of availability or performance.

I don't think there's a way to list all host IDs for a given project as a user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a HostRef instead of simply the HostID. The only thing that we have is os-hypervisor but it is not project-scoped, so we can't the get the hashed value directly from the API =/.

- celExpr: "!has(port.status.resource.description)"
# Following the network API reference, the default value for
# hostID field is an empty string.
- celExpr: "portAdmin.status.resource.hostID == ''"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny, I would have expected the binding host_id to be returned always to the admin, but according to what you're saying (and the tests) it's only shown when a binding host_id was set in the request?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's right. I made a few tests using curl to avoid meta commands hiding the output, and the binding:host_id was only returned when set in the request.

I believe it is because we explicitly specify which host we want to bind to that port. On the other hand, I think it will be defined when binding to a device (e.g., server or router), or via Port Binding, like we are doing here.

Passing hostID:

❯ curl -s -X GET -H "X-Auth-Token: $TOKEN" http://10.5.11.133/networking/v2.0/ports/$(k get port port-create-minimal -ojsonpath='{.status.id}') | jq .
{
   "port":{
      "mac_address":"fa:16:3e:f4:f8:3c",
      "admin_state_up":true,
      "status":"DOWN",
      "binding:vnic_type":"normal",
      "binding:profile":{},
      "binding:host_id":"devstack",
      "binding:vif_type":"ovs",
      "binding:vif_details":{
         "port_filter":true,
         "connectivity":"l2",
         "bridge_name":"br-int",
         "datapath_type":"system",
         "bound_drivers":{
            "0":"ovn"
         }
      }
   }
}

Not passing hostID:

{
  "port": {
    "mac_address": "fa:16:3e:44:a0:7d",
    "admin_state_up": true,
    "status": "DOWN",
    "binding:vnic_type": "normal",
    "binding:profile": {},
    "binding:host_id": "",
    "binding:vif_type": "unbound",
    "binding:vif_details": {},
    "port_security_enabled": true,
    "trusted": null,
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver:minor Backwards-compatible change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants