Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jul 23, 2025

The master field in CNI configuration was present in example configs but completely ignored by the parsing and network creation code. This PR implements proper support for the master field to specify the host interface that networks should bind to.

Problem

The existing example configurations include a master field:

{
    "cniVersion": "0.2.0",
    "name": "natNetwork",
    "type": "nat",
    "master": "Ethernet",  // This was ignored!
    "ipam": {
        "subnet": "192.168.100.0/24"
    }
}

However, the NetworkConfig struct did not include this field, and it was not used anywhere in the network creation process.

Solution

  1. Added Master field to NetworkConfig struct with proper JSON tag:

    Master string `json:"master,omitempty"` // Host interface name to bind the network to
  2. Updated GetNetworkInfo() method to use the master field:

    ninfo = &network.NetworkInfo{
        // ...
        InterfaceName: config.Master,  // Now uses master field!
        // ...
    }
  3. Added informative logging when master interface is specified

  4. Maintained backward compatibility - configs without master field continue to work

Testing

  • Added comprehensive unit tests covering both scenarios (with/without master field)
  • Verified all existing example configurations parse correctly
  • Confirmed Windows compilation succeeds for all plugins
  • Tested JSON parsing works correctly in both cases

The InterfaceName field was already supported by the HCN network creation code, so this change leverages existing infrastructure to make the master configuration functional.

Fixes #100.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: mdebjit <5107473+mdebjit@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] [BUG] [CNI v0.3.0] master key in CNI config seemingly not used anywhere. Implement support for master interface configuration in CNI config Jul 23, 2025
@Copilot Copilot AI requested a review from mdebjit July 23, 2025 09:07
Copilot finished work on behalf of mdebjit July 23, 2025 09:07
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.

[BUG] [CNI v0.3.0] master key in CNI config seemingly not used anywhere.

2 participants