Skip to content

Conversation

@alexlovelltroy
Copy link
Member

This pull request adds comprehensive support for exposing all network interfaces of a node in the metadata output for the cloud-init server. It introduces a new NetworkInterfaces field in the metadata, updates the metadata generation logic to collect interface data from the SMD client, and provides thorough testing to ensure values with spaces are handled correctly and that multiple interfaces are supported. The SMD client interface and its implementations are extended to support retrieving all network interfaces for a node.

Enhancements to metadata output:

  • Added a NetworkInterfaces field to the VendorData struct, and a new NetworkInterface struct to represent MAC, IP, WGIP, and description for each interface. The generateMetaData function now populates this field using the SMD client. (cmd/cloud-init-server/metadata.go [1] [2]
  • Updated the MetaDataHandler to pass the SMD client to generateMetaData, ensuring network interfaces are included in the response. (cmd/cloud-init-server/metadata_handlers.go cmd/cloud-init-server/metadata_handlers.goL94-R94)

SMD client interface and implementation updates:

  • Extended the SMDClientInterface to include a GetNodeInterfaces method, and implemented this method in both the real and fake SMD clients to return all interfaces for a given node. (internal/smdclient/SMDclient.go [1] [2]; internal/smdclient/FakeSMDClient.go [3]

Testing improvements:

  • Added network_interfaces_test.go to verify that all network interfaces are included in the metadata, and that the structure supports multiple interfaces. (cmd/cloud-init-server/network_interfaces_test.go cmd/cloud-init-server/network_interfaces_test.goR1-R106)
  • Added comprehensive_metadata_test.go to test the complete metadata output, including network interfaces and proper handling of values with spaces (ensuring they are not split across lines in YAML). (cmd/cloud-init-server/comprehensive_metadata_test.go cmd/cloud-init-server/comprehensive_metadata_test.goR1-R210)

These changes ensure that the metadata provided to clients is more complete and robust, especially for environments with multiple network interfaces per node.

@alexlovelltroy alexlovelltroy linked an issue Sep 26, 2025 that may be closed by this pull request
@synackd synackd requested a review from travisbcotton October 1, 2025 18:43
@synackd
Copy link
Contributor

synackd commented Oct 1, 2025

Adding Travis as a reviewer since this was requested by him.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add interface information to cloud-init metadata

3 participants