Skip to content

Untie the HCS NetworkType from the network name #57

Open
@TBBle

Description

@TBBle

Currently, the network.NetworkInfo.Type value passed through to HCS (which must be one of network.NetworkType, i.e. hcn.NetworkType values) is simply the network name. This is pretty surprising, and also breaks the CNI spec if you want multiple networks of the same type, as each plugin or plugin-list must have a host-unique name.

It also means none of the example configs work, as they will all complain with something like the below:

hcnCreateNetwork failed in Win32: Invalid JSON document string. (0x803b001b) {"Success":false,"Error":"Invalid JSON document string. {{Type,UnknownEnumValue}}","ErrorCode":2151350299}

This appears to be deliberate, but it's not very user-friendly.

The obvious approach seems to me to have each of the executables specify their own NetworkType when they call into core.Core, since the network type used appears to be the only intended distinction between the executables. I started trying to plumb this approach through, but got lost in the abstraction layers, trying to work out how to carry that value without needing to put a hard-coded [string]NetworkType map somewhere in the system, or pull a bunch of stuff into the core package.

Another option would be to expose the network type as an additional parameter, and just produce one executable that covers all the use-cases, which is really what we have now anyway, but be intentional about it.

Another option is to have the executables named to match the NetworkType, and then we can just use config.Type instead of config.Name, and there's little-to-no surprise, as long as no one renames their own executable. Again, this is really just one executable compiled three times, so not really a great approach, I feel.

So I'm interested in guidance and suggestions. This has come up while working on porting BuildKit to Windows, as the only network layer it supports natively is CNI, so I needed minimally-functional CNI with NAT, ala the nat CNI plugin I found here. I used the lattermost option as my workaround, but without renaming binaries it only works for nat, not sdnoverlay or sdnbridge, as those are not NetworkType values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions